การยืนยันตัวตนหลายปัจจัย (MFA)
สำรวจวิธีผสานรวม MFA เข้ากับโฟลว์ OIDC เพื่อเพิ่มชั้นความปลอดภัยให้การยืนยันตัวตนผู้ใช้
การยืนยันตัวตนหลายปัจจัย (MFA) เป็นบทเรียน OAuth2 & OpenID Connect Deep Dive ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน OAuth2 & OpenID Connect Deep Dive และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส OAuth2 & OpenID Connect Deep Dive มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
What is Multi-Factor Authentication?
Multi-Factor Authentication (MFA) adds an extra layer of security to user accounts beyond just a password.
Instead of relying on a single piece of evidence (like "something you know"), MFA requires two or more verification methods from different categories.
The "Factors" of MFA
MFA typically combines factors from these categories:
- Something you know: A password or PIN.
- Something you have: A phone, hardware token, or authenticator app.
- Something you are: A fingerprint, face scan, or voice recognition.
Using multiple factors makes it much harder for unauthorized users to gain access.
Why MFA in OIDC?
OpenID Connect (OIDC) itself doesn't perform MFA. Instead, it acts as a secure way for an Identity Provider (IdP) to tell your application whether a user authenticated with MFA.
Your application can then use this information to make informed authorization decisions.
Introducing ACR Values
In OIDC, "Authentication Context Class References" (ACR values) are used to specify how a user was authenticated.
These are unique identifiers that represent different levels or methods of authentication, including whether MFA was used.
Requesting a Specific ACR Level
When your application initiates an OIDC authorization request, it can include the acr_values parameter.
This parameter tells the Identity Provider that your application prefers or requires a specific authentication context, such as MFA.
Example: Requesting MFA
Here's a simplified example of an OIDC authorization URL requesting an MFA context. The specific acr_values like "mfa" or "https://acr.example.com/mfa" depend on the Identity Provider's configuration.
public class Main {
public static void main(String[] args) {
String authUrl = "https://idp.example.com/authorize?"
+ "response_type=code"
+ "&client_id=my_client_app"
+ "&redirect_uri=https://app.example.com/callback"
+ "&scope=openid%20profile"
+ "&acr_values=mfa";
System.out.println("Authorization URL:\n" + authUrl);
}
}Receiving MFA Status in the ID Token
After successful authentication, the Identity Provider returns an ID Token to your application. This token contains various claims about the user and their authentication session.
The acr claim within the ID Token indicates the actual authentication context class reference that was satisfied.
Example: Decoding an ID Token with 'acr'
Let's imagine an ID Token payload after a user authenticated with MFA. The acr claim would be present, confirming the authentication method used.
In a real application, you would decode and validate the JWT to read this claim.
public class Main {
public static void main(String[] args) {
// Example of a decoded ID Token payload
// In a real app, you'd parse a JWT.
String idTokenPayload = "{\n \"iss\": \"https://idp.example.com\",\n \"sub\": \"user123\",\n \"aud\": \"my_client_app\",\n \"exp\": 1678886400,\n \"iat\": 1678882800,\n \"auth_time\": 1678882700,\n \"acr\": \"mfa\",\n \"amr\": [\"pwd\", \"otp\"]\n}";
System.out.println("Simulated ID Token Payload:\n" + idTokenPayload);
}
}Enforcing MFA-Based Policies
Once your application receives and validates the ID Token, it can check the acr claim.
Based on this, you can implement conditional access policies. For example, if a user tries to access sensitive data, and the acr claim doesn't indicate MFA, you might deny access or prompt for re-authentication.
Quick Check
Which OIDC parameter is used by a client application to request that a user authenticates with Multi-Factor Authentication?
Recap: MFA & OIDC
We've learned that MFA adds critical security layers by requiring multiple authentication factors.
OIDC doesn't perform MFA itself, but it provides a standardized way (via acr_values in requests and the acr claim in ID Tokens) for applications to request and receive information about the authentication context, enabling robust, MFA-aware security policies.
คำถามที่พบบ่อย
บทเรียน “การยืนยันตัวตนหลายปัจจัย (MFA)” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การยืนยันตัวตนหลายปัจจัย (MFA)” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส OAuth2 & OpenID Connect Deep Dive ให้อัปเกรดเป็น CoddyKit PRO คอร์ส OAuth2 & OpenID Connect Deep Dive มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การยืนยันตัวตนหลายปัจจัย (MFA)”
สำรวจวิธีผสานรวม MFA เข้ากับโฟลว์ OIDC เพื่อเพิ่มชั้นความปลอดภัยให้การยืนยันตัวตนผู้ใช้ คุณปฏิบัติ OAuth2 & OpenID Connect Deep Dive ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน OAuth2 & OpenID Connect Deep Dive หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน OAuth2 & OpenID Connect Deep Dive บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “การยืนยันตัวตนหลายปัจจัย (MFA)” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน OAuth2 & OpenID Connect Deep Dive นี้ได้ไหม
ได้ บทเรียน OAuth2 & OpenID Connect Deep Dive ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- การผสานรวมกับผู้ให้บริการอัตลักษณ์
- ความปลอดภัยของไมโครเซอร์วิสและเกตเวย์ API
- การยืนยันตัวตนหลายปัจจัย (MFA)
- การเข้าสู่ระบบครั้งเดียวข้ามแอปพลิเคชัน