authentik.common.oauth.constants
OAuth/OpenID Constants
1"""OAuth/OpenID Constants""" 2 3from django.db import models 4from django.utils.translation import gettext_lazy as _ 5 6GRANT_TYPE_AUTHORIZATION_CODE = "authorization_code" 7GRANT_TYPE_IMPLICIT = "implicit" 8GRANT_TYPE_HYBRID = "hybrid" 9GRANT_TYPE_REFRESH_TOKEN = "refresh_token" # nosec 10GRANT_TYPE_CLIENT_CREDENTIALS = "client_credentials" 11GRANT_TYPE_PASSWORD = "password" # nosec 12GRANT_TYPE_DEVICE_CODE = "urn:ietf:params:oauth:grant-type:device_code" 13GRANT_TYPE_TOKEN_EXCHANGE = "urn:ietf:params:oauth:grant-type:token-exchange" # nosec 14 15# Token type identifiers for the token exchange grant 16# https://datatracker.ietf.org/doc/html/rfc8693#section-3 17TOKEN_TYPE_URI_ACCESS_TOKEN = "urn:ietf:params:oauth:token-type:access_token" # nosec 18TOKEN_TYPE_URI_JWT = "urn:ietf:params:oauth:token-type:jwt" # nosec 19# Only valid as requested_token_type, with a federated SAML provider as `audience` 20TOKEN_TYPE_URI_SAML2 = "urn:ietf:params:oauth:token-type:saml2" # nosec 21# authentik's own built-in Token model (e.g. API tokens), not part of RFC 8693 -- only 22# meaningful as an actor_token_type, never as a subject_token/requested_token_type 23TOKEN_TYPE_URI_AUTHENTIK_TOKEN = "goauthentik.io/oauth/token-type/authentik_token" # nosec 24 25# Access tokens are themselves JWTs, so both identifiers denote the same artifact 26TOKEN_EXCHANGE_TOKEN_TYPES = {TOKEN_TYPE_URI_ACCESS_TOKEN, TOKEN_TYPE_URI_JWT} 27# Token types accepted for actor_token specifically (RFC 8693 ยง4.1) -- adds authentik's 28# built-in Token model on top of the JWT types accepted for subject_token 29ACTOR_TOKEN_TYPES = TOKEN_EXCHANGE_TOKEN_TYPES | {TOKEN_TYPE_URI_AUTHENTIK_TOKEN} 30 31QS_LOGIN_HINT = "login_hint" 32 33CLIENT_ASSERTION = "client_assertion" 34CLIENT_ASSERTION_TYPE = "client_assertion_type" 35CLIENT_ASSERTION_TYPE_JWT = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" 36 37PROMPT_NONE = "none" 38PROMPT_CONSENT = "consent" 39PROMPT_LOGIN = "login" 40 41PLAN_CONTEXT_OIDC_LOGOUT_IFRAME_SESSIONS = "goauthentik.io/providers/oauth2/iframe_sessions" 42PLAN_CONTEXT_POST_LOGOUT_REDIRECT_URI = "goauthentik.io/providers/oauth2/post_logout_redirect_uri" 43 44OAUTH2_BINDING = "redirect" 45 46SCOPE_OPENID = "openid" 47SCOPE_OPENID_PROFILE = "profile" 48SCOPE_OPENID_EMAIL = "email" 49SCOPE_OFFLINE_ACCESS = "offline_access" 50SCOPE_BOUND_KEY = "bound_key" 51SCOPE_AUTHENTIK_API = "goauthentik.io/api" 52SCOPE_AUTHENTIK_DCR = "goauthentik.io/oidc/dcr" 53 54UI_LOCALES = "ui_locales" 55 56# https://www.iana.org/assignments/oauth-parameters/auth-parameters.xhtml#pkce-code-challenge-method 57PKCE_METHOD_PLAIN = "plain" 58PKCE_METHOD_S256 = "S256" 59 60TOKEN_TYPE = "Bearer" # nosec 61JWT_TYPE_DPOP_ID_TOKEN = "dpop+id_token" 62 63# URI schemes that are forbidden for redirect URIs 64FORBIDDEN_URI_SCHEMES = {"javascript", "data", "vbscript"} 65 66# Read/write full user (including email) 67SCOPE_GITHUB_USER = "user" 68# Read user (without email) 69SCOPE_GITHUB_USER_READ = "read:user" 70# Read users email addresses 71SCOPE_GITHUB_USER_EMAIL = "user:email" 72# Read info about teams 73SCOPE_GITHUB_ORG_READ = "read:org" 74SCOPE_GITHUB = { 75 SCOPE_GITHUB_USER, 76 SCOPE_GITHUB_USER_READ, 77 SCOPE_GITHUB_USER_EMAIL, 78 SCOPE_GITHUB_ORG_READ, 79} 80 81ACR_AUTHENTIK_DEFAULT = "goauthentik.io/providers/oauth2/default" 82 83# https://datatracker.ietf.org/doc/html/draft-ietf-oauth-amr-values-06#section-2 84AMR_PASSWORD = "pwd" # nosec 85AMR_MFA = "mfa" 86AMR_OTP = "otp" 87AMR_WEBAUTHN = "user" 88AMR_SMART_CARD = "sc" 89 90 91class SubModes(models.TextChoices): 92 """Mode after which 'sub' attribute is generated, for compatibility reasons""" 93 94 HASHED_USER_ID = "hashed_user_id", _("Based on the Hashed User ID") 95 USER_ID = "user_id", _("Based on user ID") 96 USER_UUID = "user_uuid", _("Based on user UUID") 97 USER_USERNAME = "user_username", _("Based on the username") 98 USER_EMAIL = ( 99 "user_email", 100 _("Based on the User's Email. This is recommended over the UPN method."), 101 ) 102 USER_UPN = ( 103 "user_upn", 104 _( 105 "Based on the User's UPN, only works if user has a 'upn' attribute set. " 106 "Use this method only if you have different UPN and Mail domains." 107 ), 108 )
GRANT_TYPE_AUTHORIZATION_CODE =
'authorization_code'
GRANT_TYPE_IMPLICIT =
'implicit'
GRANT_TYPE_HYBRID =
'hybrid'
GRANT_TYPE_REFRESH_TOKEN =
'refresh_token'
GRANT_TYPE_CLIENT_CREDENTIALS =
'client_credentials'
GRANT_TYPE_PASSWORD =
'password'
GRANT_TYPE_DEVICE_CODE =
'urn:ietf:params:oauth:grant-type:device_code'
GRANT_TYPE_TOKEN_EXCHANGE =
'urn:ietf:params:oauth:grant-type:token-exchange'
TOKEN_TYPE_URI_ACCESS_TOKEN =
'urn:ietf:params:oauth:token-type:access_token'
TOKEN_TYPE_URI_JWT =
'urn:ietf:params:oauth:token-type:jwt'
TOKEN_TYPE_URI_SAML2 =
'urn:ietf:params:oauth:token-type:saml2'
TOKEN_TYPE_URI_AUTHENTIK_TOKEN =
'goauthentik.io/oauth/token-type/authentik_token'
TOKEN_EXCHANGE_TOKEN_TYPES =
{'urn:ietf:params:oauth:token-type:jwt', 'urn:ietf:params:oauth:token-type:access_token'}
ACTOR_TOKEN_TYPES =
{'urn:ietf:params:oauth:token-type:jwt', 'urn:ietf:params:oauth:token-type:access_token', 'goauthentik.io/oauth/token-type/authentik_token'}
QS_LOGIN_HINT =
'login_hint'
CLIENT_ASSERTION =
'client_assertion'
CLIENT_ASSERTION_TYPE =
'client_assertion_type'
CLIENT_ASSERTION_TYPE_JWT =
'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'
PROMPT_NONE =
'none'
PROMPT_CONSENT =
'consent'
PROMPT_LOGIN =
'login'
PLAN_CONTEXT_OIDC_LOGOUT_IFRAME_SESSIONS =
'goauthentik.io/providers/oauth2/iframe_sessions'
PLAN_CONTEXT_POST_LOGOUT_REDIRECT_URI =
'goauthentik.io/providers/oauth2/post_logout_redirect_uri'
OAUTH2_BINDING =
'redirect'
SCOPE_OPENID =
'openid'
SCOPE_OPENID_PROFILE =
'profile'
SCOPE_OPENID_EMAIL =
'email'
SCOPE_OFFLINE_ACCESS =
'offline_access'
SCOPE_BOUND_KEY =
'bound_key'
SCOPE_AUTHENTIK_API =
'goauthentik.io/api'
SCOPE_AUTHENTIK_DCR =
'goauthentik.io/oidc/dcr'
UI_LOCALES =
'ui_locales'
PKCE_METHOD_PLAIN =
'plain'
PKCE_METHOD_S256 =
'S256'
TOKEN_TYPE =
'Bearer'
JWT_TYPE_DPOP_ID_TOKEN =
'dpop+id_token'
FORBIDDEN_URI_SCHEMES =
{'vbscript', 'javascript', 'data'}
SCOPE_GITHUB_USER =
'user'
SCOPE_GITHUB_USER_READ =
'read:user'
SCOPE_GITHUB_USER_EMAIL =
'user:email'
SCOPE_GITHUB_ORG_READ =
'read:org'
SCOPE_GITHUB =
{'user:email', 'read:user', 'user', 'read:org'}
ACR_AUTHENTIK_DEFAULT =
'goauthentik.io/providers/oauth2/default'
AMR_PASSWORD =
'pwd'
AMR_MFA =
'mfa'
AMR_OTP =
'otp'
AMR_WEBAUTHN =
'user'
AMR_SMART_CARD =
'sc'
class
SubModes(django.db.models.enums.TextChoices):
92class SubModes(models.TextChoices): 93 """Mode after which 'sub' attribute is generated, for compatibility reasons""" 94 95 HASHED_USER_ID = "hashed_user_id", _("Based on the Hashed User ID") 96 USER_ID = "user_id", _("Based on user ID") 97 USER_UUID = "user_uuid", _("Based on user UUID") 98 USER_USERNAME = "user_username", _("Based on the username") 99 USER_EMAIL = ( 100 "user_email", 101 _("Based on the User's Email. This is recommended over the UPN method."), 102 ) 103 USER_UPN = ( 104 "user_upn", 105 _( 106 "Based on the User's UPN, only works if user has a 'upn' attribute set. " 107 "Use this method only if you have different UPN and Mail domains." 108 ), 109 )
Mode after which 'sub' attribute is generated, for compatibility reasons
HASHED_USER_ID =
SubModes.HASHED_USER_ID
USER_ID =
SubModes.USER_ID
USER_UUID =
SubModes.USER_UUID
USER_USERNAME =
SubModes.USER_USERNAME
USER_EMAIL =
SubModes.USER_EMAIL
USER_UPN =
SubModes.USER_UPN