move oauth common things
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -10,10 +10,10 @@ from rest_framework.exceptions import AuthenticationFailed
|
|||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
|
from authentik.common.oauth.constants import SCOPE_AUTHENTIK_API
|
||||||
from authentik.core.middleware import CTX_AUTH_VIA
|
from authentik.core.middleware import CTX_AUTH_VIA
|
||||||
from authentik.core.models import Token, TokenIntents, User
|
from authentik.core.models import Token, TokenIntents, User
|
||||||
from authentik.outposts.models import Outpost
|
from authentik.outposts.models import Outpost
|
||||||
from authentik.providers.oauth2.constants import SCOPE_AUTHENTIK_API
|
|
||||||
|
|
||||||
LOGGER = get_logger()
|
LOGGER = get_logger()
|
||||||
|
|
||||||
|
|||||||
@ -10,12 +10,12 @@ from rest_framework.exceptions import AuthenticationFailed
|
|||||||
|
|
||||||
from authentik.api.authentication import bearer_auth
|
from authentik.api.authentication import bearer_auth
|
||||||
from authentik.blueprints.tests import reconcile_app
|
from authentik.blueprints.tests import reconcile_app
|
||||||
|
from authentik.common.oauth.constants import SCOPE_AUTHENTIK_API
|
||||||
from authentik.core.models import Token, TokenIntents, User, UserTypes
|
from authentik.core.models import Token, TokenIntents, User, UserTypes
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.outposts.apps import MANAGED_OUTPOST
|
from authentik.outposts.apps import MANAGED_OUTPOST
|
||||||
from authentik.outposts.models import Outpost
|
from authentik.outposts.models import Outpost
|
||||||
from authentik.providers.oauth2.constants import SCOPE_AUTHENTIK_API
|
|
||||||
from authentik.providers.oauth2.models import AccessToken, OAuth2Provider
|
from authentik.providers.oauth2.models import AccessToken, OAuth2Provider
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
0
authentik/common/oauth/__init__.py
Normal file
0
authentik/common/oauth/__init__.py
Normal file
@ -9,15 +9,15 @@ from django.http import HttpRequest
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from authentik.core.models import default_token_duration
|
from authentik.common.oauth.constants import (
|
||||||
from authentik.events.signals import get_login_event
|
|
||||||
from authentik.lib.generators import generate_id
|
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
ACR_AUTHENTIK_DEFAULT,
|
ACR_AUTHENTIK_DEFAULT,
|
||||||
AMR_MFA,
|
AMR_MFA,
|
||||||
AMR_PASSWORD,
|
AMR_PASSWORD,
|
||||||
AMR_WEBAUTHN,
|
AMR_WEBAUTHN,
|
||||||
)
|
)
|
||||||
|
from authentik.core.models import default_token_duration
|
||||||
|
from authentik.events.signals import get_login_event
|
||||||
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.stages.password.stage import PLAN_CONTEXT_METHOD, PLAN_CONTEXT_METHOD_ARGS
|
from authentik.stages.password.stage import PLAN_CONTEXT_METHOD, PLAN_CONTEXT_METHOD_ARGS
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|||||||
@ -7,13 +7,13 @@ from django.urls import reverse
|
|||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
|
from authentik.common.oauth.constants import TOKEN_TYPE
|
||||||
|
from authentik.common.oauth.errors import AuthorizeError, ClientIdError, RedirectUriError
|
||||||
from authentik.core.models import Application
|
from authentik.core.models import Application
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
from authentik.events.models import Event, EventAction
|
from authentik.events.models import Event, EventAction
|
||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.lib.utils.time import timedelta_from_string
|
from authentik.lib.utils.time import timedelta_from_string
|
||||||
from authentik.providers.oauth2.constants import TOKEN_TYPE
|
|
||||||
from authentik.providers.oauth2.errors import AuthorizeError, ClientIdError, RedirectUriError
|
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
AccessToken,
|
AccessToken,
|
||||||
AuthorizationCode,
|
AuthorizationCode,
|
||||||
|
|||||||
@ -7,10 +7,10 @@ from dataclasses import asdict
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
from authentik.common.oauth.constants import ACR_AUTHENTIK_DEFAULT
|
||||||
from authentik.core.models import Application
|
from authentik.core.models import Application
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_cert, create_test_flow
|
from authentik.core.tests.utils import create_test_admin_user, create_test_cert, create_test_flow
|
||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.providers.oauth2.constants import ACR_AUTHENTIK_DEFAULT
|
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
AccessToken,
|
AccessToken,
|
||||||
IDToken,
|
IDToken,
|
||||||
|
|||||||
@ -8,16 +8,16 @@ from django.urls import reverse
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
from authentik.core.models import Application
|
from authentik.common.oauth.constants import (
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
|
||||||
from authentik.events.models import Event, EventAction
|
|
||||||
from authentik.lib.generators import generate_id, generate_key
|
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
GRANT_TYPE_AUTHORIZATION_CODE,
|
GRANT_TYPE_AUTHORIZATION_CODE,
|
||||||
GRANT_TYPE_REFRESH_TOKEN,
|
GRANT_TYPE_REFRESH_TOKEN,
|
||||||
TOKEN_TYPE,
|
TOKEN_TYPE,
|
||||||
)
|
)
|
||||||
from authentik.providers.oauth2.errors import TokenError
|
from authentik.common.oauth.errors import TokenError
|
||||||
|
from authentik.core.models import Application
|
||||||
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
|
from authentik.events.models import Event, EventAction
|
||||||
|
from authentik.lib.generators import generate_id, generate_key
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
AccessToken,
|
AccessToken,
|
||||||
AuthorizationCode,
|
AuthorizationCode,
|
||||||
|
|||||||
@ -9,17 +9,17 @@ from django.utils.timezone import now
|
|||||||
from jwt import decode
|
from jwt import decode
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
from authentik.core.models import Application, Group
|
from authentik.common.oauth.constants import (
|
||||||
from authentik.core.tests.utils import create_test_cert, create_test_flow, create_test_user
|
|
||||||
from authentik.lib.generators import generate_id
|
|
||||||
from authentik.policies.models import PolicyBinding
|
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
GRANT_TYPE_CLIENT_CREDENTIALS,
|
GRANT_TYPE_CLIENT_CREDENTIALS,
|
||||||
SCOPE_OPENID,
|
SCOPE_OPENID,
|
||||||
SCOPE_OPENID_EMAIL,
|
SCOPE_OPENID_EMAIL,
|
||||||
SCOPE_OPENID_PROFILE,
|
SCOPE_OPENID_PROFILE,
|
||||||
TOKEN_TYPE,
|
TOKEN_TYPE,
|
||||||
)
|
)
|
||||||
|
from authentik.core.models import Application, Group
|
||||||
|
from authentik.core.tests.utils import create_test_cert, create_test_flow, create_test_user
|
||||||
|
from authentik.lib.generators import generate_id
|
||||||
|
from authentik.policies.models import PolicyBinding
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
AccessToken,
|
AccessToken,
|
||||||
OAuth2Provider,
|
OAuth2Provider,
|
||||||
|
|||||||
@ -8,17 +8,17 @@ from django.urls import reverse
|
|||||||
from jwt import decode
|
from jwt import decode
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
from authentik.core.models import Application, Group
|
from authentik.common.oauth.constants import (
|
||||||
from authentik.core.tests.utils import create_test_cert, create_test_flow
|
|
||||||
from authentik.lib.generators import generate_id
|
|
||||||
from authentik.policies.models import PolicyBinding
|
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
GRANT_TYPE_CLIENT_CREDENTIALS,
|
GRANT_TYPE_CLIENT_CREDENTIALS,
|
||||||
SCOPE_OPENID,
|
SCOPE_OPENID,
|
||||||
SCOPE_OPENID_EMAIL,
|
SCOPE_OPENID_EMAIL,
|
||||||
SCOPE_OPENID_PROFILE,
|
SCOPE_OPENID_PROFILE,
|
||||||
TOKEN_TYPE,
|
TOKEN_TYPE,
|
||||||
)
|
)
|
||||||
|
from authentik.core.models import Application, Group
|
||||||
|
from authentik.core.tests.utils import create_test_cert, create_test_flow
|
||||||
|
from authentik.lib.generators import generate_id
|
||||||
|
from authentik.policies.models import PolicyBinding
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
OAuth2Provider,
|
OAuth2Provider,
|
||||||
RedirectURI,
|
RedirectURI,
|
||||||
|
|||||||
@ -7,10 +7,7 @@ from django.urls import reverse
|
|||||||
from jwt import decode
|
from jwt import decode
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
from authentik.core.models import Application, Group, Token, TokenIntents, UserTypes
|
from authentik.common.oauth.constants import (
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_cert, create_test_flow
|
|
||||||
from authentik.policies.models import PolicyBinding
|
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
GRANT_TYPE_CLIENT_CREDENTIALS,
|
GRANT_TYPE_CLIENT_CREDENTIALS,
|
||||||
GRANT_TYPE_PASSWORD,
|
GRANT_TYPE_PASSWORD,
|
||||||
SCOPE_OPENID,
|
SCOPE_OPENID,
|
||||||
@ -18,7 +15,10 @@ from authentik.providers.oauth2.constants import (
|
|||||||
SCOPE_OPENID_PROFILE,
|
SCOPE_OPENID_PROFILE,
|
||||||
TOKEN_TYPE,
|
TOKEN_TYPE,
|
||||||
)
|
)
|
||||||
from authentik.providers.oauth2.errors import TokenError
|
from authentik.common.oauth.errors import TokenError
|
||||||
|
from authentik.core.models import Application, Group, Token, TokenIntents, UserTypes
|
||||||
|
from authentik.core.tests.utils import create_test_admin_user, create_test_cert, create_test_flow
|
||||||
|
from authentik.policies.models import PolicyBinding
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
AccessToken,
|
AccessToken,
|
||||||
OAuth2Provider,
|
OAuth2Provider,
|
||||||
|
|||||||
@ -8,10 +8,7 @@ from django.urls import reverse
|
|||||||
from jwt import decode
|
from jwt import decode
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
from authentik.core.models import Application, Group, Token, TokenIntents, UserTypes
|
from authentik.common.oauth.constants import (
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_cert, create_test_flow
|
|
||||||
from authentik.policies.models import PolicyBinding
|
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
GRANT_TYPE_CLIENT_CREDENTIALS,
|
GRANT_TYPE_CLIENT_CREDENTIALS,
|
||||||
GRANT_TYPE_PASSWORD,
|
GRANT_TYPE_PASSWORD,
|
||||||
SCOPE_OPENID,
|
SCOPE_OPENID,
|
||||||
@ -19,7 +16,10 @@ from authentik.providers.oauth2.constants import (
|
|||||||
SCOPE_OPENID_PROFILE,
|
SCOPE_OPENID_PROFILE,
|
||||||
TOKEN_TYPE,
|
TOKEN_TYPE,
|
||||||
)
|
)
|
||||||
from authentik.providers.oauth2.errors import TokenError
|
from authentik.common.oauth.errors import TokenError
|
||||||
|
from authentik.core.models import Application, Group, Token, TokenIntents, UserTypes
|
||||||
|
from authentik.core.tests.utils import create_test_admin_user, create_test_cert, create_test_flow
|
||||||
|
from authentik.policies.models import PolicyBinding
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
OAuth2Provider,
|
OAuth2Provider,
|
||||||
RedirectURI,
|
RedirectURI,
|
||||||
|
|||||||
@ -7,10 +7,7 @@ from django.urls import reverse
|
|||||||
from jwt import decode
|
from jwt import decode
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
from authentik.core.models import Application, Group, Token, TokenIntents, UserTypes
|
from authentik.common.oauth.constants import (
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_cert, create_test_flow
|
|
||||||
from authentik.policies.models import PolicyBinding
|
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
GRANT_TYPE_CLIENT_CREDENTIALS,
|
GRANT_TYPE_CLIENT_CREDENTIALS,
|
||||||
GRANT_TYPE_PASSWORD,
|
GRANT_TYPE_PASSWORD,
|
||||||
SCOPE_OPENID,
|
SCOPE_OPENID,
|
||||||
@ -18,7 +15,10 @@ from authentik.providers.oauth2.constants import (
|
|||||||
SCOPE_OPENID_PROFILE,
|
SCOPE_OPENID_PROFILE,
|
||||||
TOKEN_TYPE,
|
TOKEN_TYPE,
|
||||||
)
|
)
|
||||||
from authentik.providers.oauth2.errors import TokenError
|
from authentik.common.oauth.errors import TokenError
|
||||||
|
from authentik.core.models import Application, Group, Token, TokenIntents, UserTypes
|
||||||
|
from authentik.core.tests.utils import create_test_admin_user, create_test_cert, create_test_flow
|
||||||
|
from authentik.policies.models import PolicyBinding
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
OAuth2Provider,
|
OAuth2Provider,
|
||||||
RedirectURI,
|
RedirectURI,
|
||||||
|
|||||||
@ -6,14 +6,14 @@ from django.test import RequestFactory
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
from authentik.core.models import Application
|
from authentik.common.oauth.constants import (
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_cert, create_test_flow
|
|
||||||
from authentik.lib.generators import generate_code_fixed_length, generate_id
|
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
GRANT_TYPE_DEVICE_CODE,
|
GRANT_TYPE_DEVICE_CODE,
|
||||||
SCOPE_OPENID,
|
SCOPE_OPENID,
|
||||||
SCOPE_OPENID_EMAIL,
|
SCOPE_OPENID_EMAIL,
|
||||||
)
|
)
|
||||||
|
from authentik.core.models import Application
|
||||||
|
from authentik.core.tests.utils import create_test_admin_user, create_test_cert, create_test_flow
|
||||||
|
from authentik.lib.generators import generate_code_fixed_length, generate_id
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
AccessToken,
|
AccessToken,
|
||||||
DeviceToken,
|
DeviceToken,
|
||||||
|
|||||||
@ -6,10 +6,10 @@ from hashlib import sha256
|
|||||||
from django.test import RequestFactory
|
from django.test import RequestFactory
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
|
from authentik.common.oauth.constants import GRANT_TYPE_AUTHORIZATION_CODE
|
||||||
from authentik.core.models import Application
|
from authentik.core.models import Application
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.providers.oauth2.constants import GRANT_TYPE_AUTHORIZATION_CODE
|
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
AuthorizationCode,
|
AuthorizationCode,
|
||||||
OAuth2Provider,
|
OAuth2Provider,
|
||||||
|
|||||||
@ -11,9 +11,9 @@ from django.http.response import HttpResponseRedirect
|
|||||||
from django.utils.cache import patch_vary_headers
|
from django.utils.cache import patch_vary_headers
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
|
from authentik.common.oauth.errors import BearerTokenError
|
||||||
from authentik.core.middleware import CTX_AUTH_VIA, KEY_USER
|
from authentik.core.middleware import CTX_AUTH_VIA, KEY_USER
|
||||||
from authentik.events.models import Event, EventAction
|
from authentik.events.models import Event, EventAction
|
||||||
from authentik.providers.oauth2.errors import BearerTokenError
|
|
||||||
from authentik.providers.oauth2.models import AccessToken, OAuth2Provider
|
from authentik.providers.oauth2.models import AccessToken, OAuth2Provider
|
||||||
|
|
||||||
LOGGER = get_logger()
|
LOGGER = get_logger()
|
||||||
|
|||||||
@ -15,6 +15,23 @@ from django.utils import timezone
|
|||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
|
from authentik.common.oauth.constants import (
|
||||||
|
PKCE_METHOD_PLAIN,
|
||||||
|
PKCE_METHOD_S256,
|
||||||
|
PROMPT_CONSENT,
|
||||||
|
PROMPT_LOGIN,
|
||||||
|
PROMPT_NONE,
|
||||||
|
SCOPE_GITHUB,
|
||||||
|
SCOPE_OFFLINE_ACCESS,
|
||||||
|
SCOPE_OPENID,
|
||||||
|
TOKEN_TYPE,
|
||||||
|
)
|
||||||
|
from authentik.common.oauth.errors import (
|
||||||
|
AuthorizeError,
|
||||||
|
ClientIdError,
|
||||||
|
OAuth2Error,
|
||||||
|
RedirectUriError,
|
||||||
|
)
|
||||||
from authentik.core.models import Application
|
from authentik.core.models import Application
|
||||||
from authentik.events.models import Event, EventAction
|
from authentik.events.models import Event, EventAction
|
||||||
from authentik.events.signals import get_login_event
|
from authentik.events.signals import get_login_event
|
||||||
@ -31,23 +48,6 @@ from authentik.lib.utils.time import timedelta_from_string
|
|||||||
from authentik.lib.views import bad_request_message
|
from authentik.lib.views import bad_request_message
|
||||||
from authentik.policies.types import PolicyRequest
|
from authentik.policies.types import PolicyRequest
|
||||||
from authentik.policies.views import PolicyAccessView, RequestValidationError
|
from authentik.policies.views import PolicyAccessView, RequestValidationError
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
PKCE_METHOD_PLAIN,
|
|
||||||
PKCE_METHOD_S256,
|
|
||||||
PROMPT_CONSENT,
|
|
||||||
PROMPT_LOGIN,
|
|
||||||
PROMPT_NONE,
|
|
||||||
SCOPE_GITHUB,
|
|
||||||
SCOPE_OFFLINE_ACCESS,
|
|
||||||
SCOPE_OPENID,
|
|
||||||
TOKEN_TYPE,
|
|
||||||
)
|
|
||||||
from authentik.providers.oauth2.errors import (
|
|
||||||
AuthorizeError,
|
|
||||||
ClientIdError,
|
|
||||||
OAuth2Error,
|
|
||||||
RedirectUriError,
|
|
||||||
)
|
|
||||||
from authentik.providers.oauth2.id_token import IDToken
|
from authentik.providers.oauth2.id_token import IDToken
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
AccessToken,
|
AccessToken,
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from django.utils.text import slugify
|
|||||||
from django.views import View
|
from django.views import View
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
|
||||||
from authentik.providers.oauth2.constants import SCOPE_GITHUB_ORG_READ, SCOPE_GITHUB_USER_EMAIL
|
from authentik.common.oauth.constants import SCOPE_GITHUB_ORG_READ, SCOPE_GITHUB_USER_EMAIL
|
||||||
from authentik.providers.oauth2.models import RefreshToken
|
from authentik.providers.oauth2.models import RefreshToken
|
||||||
from authentik.providers.oauth2.utils import protected_resource_view
|
from authentik.providers.oauth2.utils import protected_resource_view
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from django.views import View
|
|||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.providers.oauth2.errors import TokenIntrospectionError
|
from authentik.common.oauth.errors import TokenIntrospectionError
|
||||||
from authentik.providers.oauth2.models import AccessToken, IDToken, OAuth2Provider, RefreshToken
|
from authentik.providers.oauth2.models import AccessToken, IDToken, OAuth2Provider, RefreshToken
|
||||||
from authentik.providers.oauth2.utils import TokenResponse, authenticate_provider
|
from authentik.providers.oauth2.utils import TokenResponse, authenticate_provider
|
||||||
|
|
||||||
|
|||||||
@ -8,9 +8,7 @@ from django.views import View
|
|||||||
from guardian.shortcuts import get_anonymous_user
|
from guardian.shortcuts import get_anonymous_user
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.core.expression.exceptions import PropertyMappingExpressionException
|
from authentik.common.oauth.constants import (
|
||||||
from authentik.core.models import Application
|
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
ACR_AUTHENTIK_DEFAULT,
|
ACR_AUTHENTIK_DEFAULT,
|
||||||
GRANT_TYPE_AUTHORIZATION_CODE,
|
GRANT_TYPE_AUTHORIZATION_CODE,
|
||||||
GRANT_TYPE_CLIENT_CREDENTIALS,
|
GRANT_TYPE_CLIENT_CREDENTIALS,
|
||||||
@ -22,6 +20,8 @@ from authentik.providers.oauth2.constants import (
|
|||||||
PKCE_METHOD_S256,
|
PKCE_METHOD_S256,
|
||||||
SCOPE_OPENID,
|
SCOPE_OPENID,
|
||||||
)
|
)
|
||||||
|
from authentik.core.expression.exceptions import PropertyMappingExpressionException
|
||||||
|
from authentik.core.models import Application
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
OAuth2Provider,
|
OAuth2Provider,
|
||||||
ResponseMode,
|
ResponseMode,
|
||||||
|
|||||||
@ -20,6 +20,20 @@ from jwt import PyJWK, PyJWT, PyJWTError, decode
|
|||||||
from sentry_sdk import start_span
|
from sentry_sdk import start_span
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
|
from authentik.common.oauth.constants import (
|
||||||
|
CLIENT_ASSERTION,
|
||||||
|
CLIENT_ASSERTION_TYPE,
|
||||||
|
CLIENT_ASSERTION_TYPE_JWT,
|
||||||
|
GRANT_TYPE_AUTHORIZATION_CODE,
|
||||||
|
GRANT_TYPE_CLIENT_CREDENTIALS,
|
||||||
|
GRANT_TYPE_DEVICE_CODE,
|
||||||
|
GRANT_TYPE_PASSWORD,
|
||||||
|
GRANT_TYPE_REFRESH_TOKEN,
|
||||||
|
PKCE_METHOD_S256,
|
||||||
|
SCOPE_OFFLINE_ACCESS,
|
||||||
|
TOKEN_TYPE,
|
||||||
|
)
|
||||||
|
from authentik.common.oauth.errors import DeviceCodeError, TokenError, UserAuthError
|
||||||
from authentik.core.middleware import CTX_AUTH_VIA
|
from authentik.core.middleware import CTX_AUTH_VIA
|
||||||
from authentik.core.models import (
|
from authentik.core.models import (
|
||||||
USER_ATTRIBUTE_EXPIRES,
|
USER_ATTRIBUTE_EXPIRES,
|
||||||
@ -37,20 +51,6 @@ from authentik.events.signals import get_login_event
|
|||||||
from authentik.flows.planner import PLAN_CONTEXT_APPLICATION
|
from authentik.flows.planner import PLAN_CONTEXT_APPLICATION
|
||||||
from authentik.lib.utils.time import timedelta_from_string
|
from authentik.lib.utils.time import timedelta_from_string
|
||||||
from authentik.policies.engine import PolicyEngine
|
from authentik.policies.engine import PolicyEngine
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
CLIENT_ASSERTION,
|
|
||||||
CLIENT_ASSERTION_TYPE,
|
|
||||||
CLIENT_ASSERTION_TYPE_JWT,
|
|
||||||
GRANT_TYPE_AUTHORIZATION_CODE,
|
|
||||||
GRANT_TYPE_CLIENT_CREDENTIALS,
|
|
||||||
GRANT_TYPE_DEVICE_CODE,
|
|
||||||
GRANT_TYPE_PASSWORD,
|
|
||||||
GRANT_TYPE_REFRESH_TOKEN,
|
|
||||||
PKCE_METHOD_S256,
|
|
||||||
SCOPE_OFFLINE_ACCESS,
|
|
||||||
TOKEN_TYPE,
|
|
||||||
)
|
|
||||||
from authentik.providers.oauth2.errors import DeviceCodeError, TokenError, UserAuthError
|
|
||||||
from authentik.providers.oauth2.id_token import IDToken
|
from authentik.providers.oauth2.id_token import IDToken
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
AccessToken,
|
AccessToken,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from django.views import View
|
|||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.providers.oauth2.errors import TokenRevocationError
|
from authentik.common.oauth.errors import TokenRevocationError
|
||||||
from authentik.providers.oauth2.models import AccessToken, ClientTypes, OAuth2Provider, RefreshToken
|
from authentik.providers.oauth2.models import AccessToken, ClientTypes, OAuth2Provider, RefreshToken
|
||||||
from authentik.providers.oauth2.utils import (
|
from authentik.providers.oauth2.utils import (
|
||||||
TokenResponse,
|
TokenResponse,
|
||||||
|
|||||||
@ -11,16 +11,16 @@ from django.views import View
|
|||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.core.expression.exceptions import PropertyMappingExpressionException
|
from authentik.common.oauth.constants import (
|
||||||
from authentik.events.models import Event, EventAction
|
|
||||||
from authentik.flows.challenge import PermissionDict
|
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
SCOPE_GITHUB_ORG_READ,
|
SCOPE_GITHUB_ORG_READ,
|
||||||
SCOPE_GITHUB_USER,
|
SCOPE_GITHUB_USER,
|
||||||
SCOPE_GITHUB_USER_EMAIL,
|
SCOPE_GITHUB_USER_EMAIL,
|
||||||
SCOPE_GITHUB_USER_READ,
|
SCOPE_GITHUB_USER_READ,
|
||||||
SCOPE_OPENID,
|
SCOPE_OPENID,
|
||||||
)
|
)
|
||||||
|
from authentik.core.expression.exceptions import PropertyMappingExpressionException
|
||||||
|
from authentik.events.models import Event, EventAction
|
||||||
|
from authentik.flows.challenge import PermissionDict
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
BaseGrantModel,
|
BaseGrantModel,
|
||||||
OAuth2Provider,
|
OAuth2Provider,
|
||||||
|
|||||||
@ -7,6 +7,7 @@ and https://docs.gitlab.com/ee/integration/openid_connect_provider.html
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from authentik.common.oauth.constants import SCOPE_OPENID, SCOPE_OPENID_EMAIL, SCOPE_OPENID_PROFILE
|
||||||
from authentik.sources.oauth.models import AuthorizationCodeAuthMethod, OAuthSource
|
from authentik.sources.oauth.models import AuthorizationCodeAuthMethod, OAuthSource
|
||||||
from authentik.sources.oauth.types.registry import SourceType, registry
|
from authentik.sources.oauth.types.registry import SourceType, registry
|
||||||
from authentik.sources.oauth.views.redirect import OAuthRedirect
|
from authentik.sources.oauth.views.redirect import OAuthRedirect
|
||||||
@ -17,7 +18,7 @@ class GitLabOAuthRedirect(OAuthRedirect):
|
|||||||
|
|
||||||
def get_additional_parameters(self, source: OAuthSource):
|
def get_additional_parameters(self, source: OAuthSource):
|
||||||
return {
|
return {
|
||||||
"scope": ["read_user", "openid", "profile", "email"],
|
"scope": ["read_user", SCOPE_OPENID, SCOPE_OPENID_PROFILE, SCOPE_OPENID_EMAIL],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from authentik.common.oauth.constants import SCOPE_OPENID_EMAIL, SCOPE_OPENID_PROFILE
|
||||||
from authentik.sources.oauth.models import AuthorizationCodeAuthMethod
|
from authentik.sources.oauth.models import AuthorizationCodeAuthMethod
|
||||||
from authentik.sources.oauth.types.registry import SourceType, registry
|
from authentik.sources.oauth.types.registry import SourceType, registry
|
||||||
from authentik.sources.oauth.views.redirect import OAuthRedirect
|
from authentik.sources.oauth.views.redirect import OAuthRedirect
|
||||||
@ -12,7 +13,7 @@ class GoogleOAuthRedirect(OAuthRedirect):
|
|||||||
|
|
||||||
def get_additional_parameters(self, source): # pragma: no cover
|
def get_additional_parameters(self, source): # pragma: no cover
|
||||||
return {
|
return {
|
||||||
"scope": ["email", "profile"],
|
"scope": [SCOPE_OPENID_PROFILE, SCOPE_OPENID_EMAIL],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ from typing import Any
|
|||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
|
from authentik.common.oauth.constants import SCOPE_OPENID_PROFILE
|
||||||
from authentik.sources.oauth.clients.oauth2 import OAuth2Client
|
from authentik.sources.oauth.clients.oauth2 import OAuth2Client
|
||||||
from authentik.sources.oauth.models import AuthorizationCodeAuthMethod
|
from authentik.sources.oauth.models import AuthorizationCodeAuthMethod
|
||||||
from authentik.sources.oauth.types.registry import SourceType, registry
|
from authentik.sources.oauth.types.registry import SourceType, registry
|
||||||
@ -19,7 +20,7 @@ class MailcowOAuthRedirect(OAuthRedirect):
|
|||||||
|
|
||||||
def get_additional_parameters(self, source): # pragma: no cover
|
def get_additional_parameters(self, source): # pragma: no cover
|
||||||
return {
|
return {
|
||||||
"scope": ["profile"],
|
"scope": [SCOPE_OPENID_PROFILE],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ from typing import Any
|
|||||||
|
|
||||||
from requests.auth import AuthBase, HTTPBasicAuth
|
from requests.auth import AuthBase, HTTPBasicAuth
|
||||||
|
|
||||||
|
from authentik.common.oauth.constants import SCOPE_OPENID, SCOPE_OPENID_EMAIL, SCOPE_OPENID_PROFILE
|
||||||
from authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient
|
from authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient
|
||||||
from authentik.sources.oauth.models import AuthorizationCodeAuthMethod, OAuthSource
|
from authentik.sources.oauth.models import AuthorizationCodeAuthMethod, OAuthSource
|
||||||
from authentik.sources.oauth.types.registry import SourceType, registry
|
from authentik.sources.oauth.types.registry import SourceType, registry
|
||||||
@ -16,7 +17,7 @@ class OpenIDConnectOAuthRedirect(OAuthRedirect):
|
|||||||
|
|
||||||
def get_additional_parameters(self, source: OAuthSource): # pragma: no cover
|
def get_additional_parameters(self, source: OAuthSource): # pragma: no cover
|
||||||
return {
|
return {
|
||||||
"scope": ["openid", "email", "profile"],
|
"scope": [SCOPE_OPENID, SCOPE_OPENID_PROFILE, SCOPE_OPENID_EMAIL],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from authentik.common.oauth.constants import SCOPE_OPENID, SCOPE_OPENID_EMAIL, SCOPE_OPENID_PROFILE
|
||||||
from authentik.sources.oauth.models import OAuthSource
|
from authentik.sources.oauth.models import OAuthSource
|
||||||
from authentik.sources.oauth.types.oidc import OpenIDConnectOAuth2Callback
|
from authentik.sources.oauth.types.oidc import OpenIDConnectOAuth2Callback
|
||||||
from authentik.sources.oauth.types.registry import SourceType, registry
|
from authentik.sources.oauth.types.registry import SourceType, registry
|
||||||
@ -13,7 +14,7 @@ class OktaOAuthRedirect(OAuthRedirect):
|
|||||||
|
|
||||||
def get_additional_parameters(self, source: OAuthSource): # pragma: no cover
|
def get_additional_parameters(self, source: OAuthSource): # pragma: no cover
|
||||||
return {
|
return {
|
||||||
"scope": ["openid", "email", "profile"],
|
"scope": [SCOPE_OPENID, SCOPE_OPENID_PROFILE, SCOPE_OPENID_EMAIL],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -7,18 +7,18 @@ from selenium.webdriver.common.by import By
|
|||||||
from selenium.webdriver.support import expected_conditions as ec
|
from selenium.webdriver.support import expected_conditions as ec
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint, reconcile_app
|
from authentik.blueprints.tests import apply_blueprint, reconcile_app
|
||||||
|
from authentik.common.oauth.constants import (
|
||||||
|
SCOPE_OFFLINE_ACCESS,
|
||||||
|
SCOPE_OPENID,
|
||||||
|
SCOPE_OPENID_EMAIL,
|
||||||
|
SCOPE_OPENID_PROFILE,
|
||||||
|
)
|
||||||
from authentik.core.models import Application
|
from authentik.core.models import Application
|
||||||
from authentik.core.tests.utils import create_test_cert
|
from authentik.core.tests.utils import create_test_cert
|
||||||
from authentik.flows.models import Flow
|
from authentik.flows.models import Flow
|
||||||
from authentik.lib.generators import generate_id, generate_key
|
from authentik.lib.generators import generate_id, generate_key
|
||||||
from authentik.policies.expression.models import ExpressionPolicy
|
from authentik.policies.expression.models import ExpressionPolicy
|
||||||
from authentik.policies.models import PolicyBinding
|
from authentik.policies.models import PolicyBinding
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
SCOPE_OFFLINE_ACCESS,
|
|
||||||
SCOPE_OPENID,
|
|
||||||
SCOPE_OPENID_EMAIL,
|
|
||||||
SCOPE_OPENID_PROFILE,
|
|
||||||
)
|
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
ClientTypes,
|
ClientTypes,
|
||||||
OAuth2Provider,
|
OAuth2Provider,
|
||||||
|
|||||||
@ -7,18 +7,18 @@ from selenium.webdriver.common.by import By
|
|||||||
from selenium.webdriver.support import expected_conditions as ec
|
from selenium.webdriver.support import expected_conditions as ec
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint, reconcile_app
|
from authentik.blueprints.tests import apply_blueprint, reconcile_app
|
||||||
|
from authentik.common.oauth.constants import (
|
||||||
|
SCOPE_OFFLINE_ACCESS,
|
||||||
|
SCOPE_OPENID,
|
||||||
|
SCOPE_OPENID_EMAIL,
|
||||||
|
SCOPE_OPENID_PROFILE,
|
||||||
|
)
|
||||||
from authentik.core.models import Application
|
from authentik.core.models import Application
|
||||||
from authentik.core.tests.utils import create_test_cert
|
from authentik.core.tests.utils import create_test_cert
|
||||||
from authentik.flows.models import Flow
|
from authentik.flows.models import Flow
|
||||||
from authentik.lib.generators import generate_id, generate_key
|
from authentik.lib.generators import generate_id, generate_key
|
||||||
from authentik.policies.expression.models import ExpressionPolicy
|
from authentik.policies.expression.models import ExpressionPolicy
|
||||||
from authentik.policies.models import PolicyBinding
|
from authentik.policies.models import PolicyBinding
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
SCOPE_OFFLINE_ACCESS,
|
|
||||||
SCOPE_OPENID,
|
|
||||||
SCOPE_OPENID_EMAIL,
|
|
||||||
SCOPE_OPENID_PROFILE,
|
|
||||||
)
|
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
ClientTypes,
|
ClientTypes,
|
||||||
OAuth2Provider,
|
OAuth2Provider,
|
||||||
|
|||||||
@ -7,18 +7,18 @@ from selenium.webdriver.common.by import By
|
|||||||
from selenium.webdriver.support import expected_conditions as ec
|
from selenium.webdriver.support import expected_conditions as ec
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint, reconcile_app
|
from authentik.blueprints.tests import apply_blueprint, reconcile_app
|
||||||
|
from authentik.common.oauth.constants import (
|
||||||
|
SCOPE_OFFLINE_ACCESS,
|
||||||
|
SCOPE_OPENID,
|
||||||
|
SCOPE_OPENID_EMAIL,
|
||||||
|
SCOPE_OPENID_PROFILE,
|
||||||
|
)
|
||||||
from authentik.core.models import Application
|
from authentik.core.models import Application
|
||||||
from authentik.core.tests.utils import create_test_cert
|
from authentik.core.tests.utils import create_test_cert
|
||||||
from authentik.flows.models import Flow
|
from authentik.flows.models import Flow
|
||||||
from authentik.lib.generators import generate_id, generate_key
|
from authentik.lib.generators import generate_id, generate_key
|
||||||
from authentik.policies.expression.models import ExpressionPolicy
|
from authentik.policies.expression.models import ExpressionPolicy
|
||||||
from authentik.policies.models import PolicyBinding
|
from authentik.policies.models import PolicyBinding
|
||||||
from authentik.providers.oauth2.constants import (
|
|
||||||
SCOPE_OFFLINE_ACCESS,
|
|
||||||
SCOPE_OPENID,
|
|
||||||
SCOPE_OPENID_EMAIL,
|
|
||||||
SCOPE_OPENID_PROFILE,
|
|
||||||
)
|
|
||||||
from authentik.providers.oauth2.models import (
|
from authentik.providers.oauth2.models import (
|
||||||
ClientTypes,
|
ClientTypes,
|
||||||
OAuth2Provider,
|
OAuth2Provider,
|
||||||
|
|||||||
Reference in New Issue
Block a user