วิธีเชื่อมต่อ OpenID กับ Moodle และการทำ Map field

การตั้งค่าจะใช้ OAuth 2 services ซึ่งเป็น Built-in ของ Moodle เอง หรือสามารถลงปลั้กอินอื่นๆ ที่รองรับ OAuth2 ในตัวอย่างนี้จะใช้ Moodle 4.5.10+ (Build: 20260306)

จากนั้นกดปุ่ม Custom

ตั้งค่า OAuth

ใส่ข้อมูลตามนี้

Nameตั้งชื่อช่องทาง Login
Client IDClient ID ที่ได้จากการขอ OpenID
Client SecretClient Secret ที่ได้จากการขอ OpenID
Service base urlURL ที่เป็น /.well-known/openid-configuration
Logo URLใส่หรือไม่ใส่ก็ได้
Scope ทั้งสองช่องemail openid psu_profile name profile
ติ๊กถูกI understand that disabling email verification can be a security issue.

ตั้งค่า Map field

กด User field mappings บน Service ที่ตั้งค่าไว้ ตั้งค่าตามนี้

External field nameInternal field name
display_name_thdescription
emailemail
first_namefirstname
preferred_usernameidnumber
office_name_thinstitution
last_namelastname
usernameusername

ตั้งค่า IP

เข้าไปในหน้า HTTP security URL: /admin/settings.php?section=httpsecurity

ตรวจสอบว่ามี Block IP 10.0.X.X ในรายการหรือไม่ ถ้ามี ให้เอาออก

ทดสอบ Login

ปิดการใช้งาน User/pass (optional)

เข้า URL /admin/settings.php?section=manageauths หรือ Plugins > Authentication > Manage authentication แล้วเปิดแค่ OAuth 2

ขอบคุณ คุณสุวัฒน์ อนันตคุณูปกร สำหรับ Server ทดสอบ Moodle และแนวทางตั้งค่า OAuth2

About The Author

Comments

Leave a Reply