0Pricing
OAuth2 & OpenID Connect Deep Dive · Урок

Многофакторная аутентификация (MFA)

Изучите интеграцию MFA с потоками OIDC для добавления дополнительного уровня безопасности аутентификации пользователей.

«Многофакторная аутентификация (MFA)» — бесплатный урок OAuth2 & OpenID Connect Deep Dive на CoddyKit. Это урок 3 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 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)» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс OAuth2 & OpenID Connect Deep Dive, подпишись на CoddyKit PRO. Курс OAuth2 & OpenID Connect Deep Dive содержит 4 уроков всего.

Чему я научусь в уроке «Многофакторная аутентификация (MFA)»?

Изучите интеграцию MFA с потоками OIDC для добавления дополнительного уровня безопасности аутентификации пользователей. Ты практикуешь OAuth2 & OpenID Connect Deep Dive с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 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 — локальная установка не требуется.

Все уроки этого курса

  1. Интеграция с поставщиками идентификации
  2. Безопасность микросервисов и API-шлюзов
  3. Многофакторная аутентификация (MFA)
  4. Единый вход в приложения
← Назад к OAuth2 & OpenID Connect Deep Dive