<@U04UQ68083H> a long shot, but is it possible to ...
# ory-copilot
w
@chilly-king-10285 a long shot, but is it possible to enforce 2fa from an identity schema?
b
A message from kapa.ai
No, it is not possible to enforce 2FA (two-factor authentication) directly from the identity schema in Ory Kratos. The identity schema is used to define which fields are identifiers for various authentication methods (such as password, TOTP, WebAuthn, code, etc.) and to specify how those fields are used (e.g., for login, recovery, verification), but it does not control enforcement of 2FA. Enforcement of 2FA is managed through the Ory configuration (either via the Ory Console or configuration files), where you set the required Authenticator Assurance Level (AAL) for specific flows or endpoints. For example, you can require AAL2 (which means 2FA) for login or settings flows by setting the appropriate configuration keys, such as
selfservice.flows.settings.required_aal
or
session.whoami.required_aal
to
highest_available
or
aal2
in your configuration file or through the Console. This is where you control whether and when 2FA is enforced—not in the identity schema itself [Step-up authentication](https://www.ory.sh/docs/kratos/mfa/step-up-authentication) [Configure multi-factor authentication in Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mfa). The identity schema only tells Ory which traits to use for authentication, recovery, or verification, but does not enforce the use of 2FA. Enforcement is always a configuration-level concern.