mirror of
https://github.com/goauthentik/authentik.git
synced 2026-08-30 18:51:39 -07:00
providers/oauth2: move DCR to OSS (#24949)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
from authentik.enterprise.apps import EnterpriseConfig
|
||||
|
||||
|
||||
class AuthentikEnterpriseProviderOAuth2Config(EnterpriseConfig):
|
||||
|
||||
name = "authentik.enterprise.providers.oauth2"
|
||||
label = "authentik_enterprise_providers_oauth2"
|
||||
verbose_name = "authentik Enterprise.Providers.OAuth2"
|
||||
default = True
|
||||
mountpoint = "application/o/"
|
||||
@@ -1,18 +0,0 @@
|
||||
"""OAuth2 Dynamic Client Registration URLs"""
|
||||
|
||||
from django.urls import path
|
||||
|
||||
from authentik.enterprise.providers.oauth2.api import OAuth2DynamicClientRegistrationViewSet
|
||||
from authentik.enterprise.providers.oauth2.views.dcr import DynamicClientRegistrationView
|
||||
|
||||
urlpatterns = [
|
||||
path(
|
||||
"<slug:application_slug>/register/",
|
||||
DynamicClientRegistrationView.as_view(),
|
||||
name="dynamic-client-registration",
|
||||
),
|
||||
]
|
||||
|
||||
api_urlpatterns = [
|
||||
("providers/oauth2-dcr", OAuth2DynamicClientRegistrationViewSet),
|
||||
]
|
||||
@@ -10,7 +10,6 @@ TENANT_APPS = [
|
||||
"authentik.enterprise.policies.unique_password",
|
||||
"authentik.enterprise.providers.google_workspace",
|
||||
"authentik.enterprise.providers.microsoft_entra",
|
||||
"authentik.enterprise.providers.oauth2",
|
||||
"authentik.enterprise.providers.radius",
|
||||
"authentik.enterprise.providers.scim",
|
||||
"authentik.enterprise.providers.ssf",
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from authentik.core.api.utils import ModelSerializer
|
||||
from authentik.enterprise.api import EnterpriseRequiredMixin
|
||||
from authentik.providers.oauth2.models import (
|
||||
OAuth2DynamicClientRegistration,
|
||||
)
|
||||
|
||||
|
||||
class OAuth2DynamicClientRegistrationSerializer(EnterpriseRequiredMixin, ModelSerializer):
|
||||
class OAuth2DynamicClientRegistrationSerializer(ModelSerializer):
|
||||
"""Serializer for OAuth2DynamicClientRegistration"""
|
||||
|
||||
class Meta:
|
||||
@@ -4,7 +4,7 @@ from copy import copy
|
||||
from re import compile
|
||||
from re import error as RegexError
|
||||
|
||||
from django.urls import NoReverseMatch, reverse
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from drf_spectacular.types import OpenApiTypes
|
||||
@@ -185,16 +185,12 @@ class OAuth2ProviderViewSet(UsedByMixin, ModelViewSet):
|
||||
kwargs={"application_slug": provider.application.slug},
|
||||
)
|
||||
)
|
||||
try:
|
||||
data["dcr_registration"] = request.build_absolute_uri(
|
||||
reverse(
|
||||
"authentik_enterprise_providers_oauth2:dynamic-client-registration",
|
||||
kwargs={"application_slug": provider.application.slug},
|
||||
)
|
||||
data["dcr_registration"] = request.build_absolute_uri(
|
||||
reverse(
|
||||
"authentik_providers_oauth2:dynamic-client-registration",
|
||||
kwargs={"application_slug": provider.application.slug},
|
||||
)
|
||||
except NoReverseMatch:
|
||||
# No reverse match if enterprise is not available
|
||||
data["dcr_registration"] = None
|
||||
)
|
||||
except Provider.application.RelatedObjectDoesNotExist:
|
||||
pass
|
||||
return Response(data)
|
||||
|
||||
@@ -825,7 +825,7 @@ class OAuth2DynamicClientRegistration(SerializerModel, PolicyBindingModel):
|
||||
|
||||
@property
|
||||
def serializer(self) -> type[Serializer]:
|
||||
from authentik.enterprise.providers.oauth2.api import (
|
||||
from authentik.providers.oauth2.api.dcr import (
|
||||
OAuth2DynamicClientRegistrationSerializer,
|
||||
)
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class TestDynamicClientRegistration(TestCase):
|
||||
override_authorization_flow=self.flow,
|
||||
)
|
||||
self.register_url = reverse(
|
||||
"authentik_enterprise_providers_oauth2:dynamic-client-registration",
|
||||
"authentik_providers_oauth2:dynamic-client-registration",
|
||||
kwargs={"application_slug": self.app.slug},
|
||||
)
|
||||
|
||||
@@ -335,7 +335,7 @@ class TestDynamicClientRegistration(TestCase):
|
||||
)
|
||||
response = self.client.post(
|
||||
reverse(
|
||||
"authentik_enterprise_providers_oauth2:dynamic-client-registration",
|
||||
"authentik_providers_oauth2:dynamic-client-registration",
|
||||
kwargs={"application_slug": app2.slug},
|
||||
),
|
||||
json.dumps({"redirect_uris": ["https://x.com/cb"]}),
|
||||
@@ -3,6 +3,7 @@
|
||||
from django.urls import path
|
||||
from django.views.generic.base import RedirectView
|
||||
|
||||
from authentik.providers.oauth2.api.dcr import OAuth2DynamicClientRegistrationViewSet
|
||||
from authentik.providers.oauth2.api.providers import OAuth2ProviderViewSet
|
||||
from authentik.providers.oauth2.api.scopes import ScopeMappingViewSet
|
||||
from authentik.providers.oauth2.api.tokens import (
|
||||
@@ -11,6 +12,7 @@ from authentik.providers.oauth2.api.tokens import (
|
||||
RefreshTokenViewSet,
|
||||
)
|
||||
from authentik.providers.oauth2.views.authorize import AuthorizationFlowInitView
|
||||
from authentik.providers.oauth2.views.dcr import DynamicClientRegistrationView
|
||||
from authentik.providers.oauth2.views.device_backchannel import DeviceView
|
||||
from authentik.providers.oauth2.views.end_session import EndSessionView
|
||||
from authentik.providers.oauth2.views.introspection import TokenIntrospectionView
|
||||
@@ -59,10 +61,16 @@ urlpatterns = [
|
||||
ProviderInfoView.as_view(),
|
||||
name="provider-info",
|
||||
),
|
||||
path(
|
||||
"<slug:application_slug>/register/",
|
||||
DynamicClientRegistrationView.as_view(),
|
||||
name="dynamic-client-registration",
|
||||
),
|
||||
]
|
||||
|
||||
api_urlpatterns = [
|
||||
("providers/oauth2", OAuth2ProviderViewSet),
|
||||
("providers/oauth2-dcr", OAuth2DynamicClientRegistrationViewSet),
|
||||
("propertymappings/provider/scope", ScopeMappingViewSet),
|
||||
("oauth2/authorization_codes", AuthorizationCodeViewSet),
|
||||
("oauth2/refresh_tokens", RefreshTokenViewSet),
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
from typing import Any
|
||||
|
||||
from django.apps import apps
|
||||
from django.core.cache import cache
|
||||
from django.http import HttpRequest, HttpResponse, JsonResponse
|
||||
from django.shortcuts import get_object_or_404, reverse
|
||||
@@ -128,13 +127,12 @@ class ProviderInfoView(View):
|
||||
config["id_token_encryption_enc_values_supported"] = ["A256CBC-HS512"]
|
||||
try:
|
||||
_ = provider.dcr_configuration
|
||||
if apps.get_app_config("authentik_enterprise").enabled():
|
||||
config["registration_endpoint"] = self.request.build_absolute_uri(
|
||||
reverse(
|
||||
"authentik_enterprise_providers_oauth2:dynamic-client-registration",
|
||||
kwargs={"application_slug": provider.application.slug},
|
||||
)
|
||||
config["registration_endpoint"] = self.request.build_absolute_uri(
|
||||
reverse(
|
||||
"authentik_providers_oauth2:dynamic-client-registration",
|
||||
kwargs={"application_slug": provider.application.slug},
|
||||
)
|
||||
)
|
||||
except OAuth2DynamicClientRegistration.DoesNotExist:
|
||||
pass
|
||||
return config
|
||||
|
||||
@@ -11127,7 +11127,6 @@
|
||||
"authentik.enterprise.policies.unique_password",
|
||||
"authentik.enterprise.providers.google_workspace",
|
||||
"authentik.enterprise.providers.microsoft_entra",
|
||||
"authentik.enterprise.providers.oauth2",
|
||||
"authentik.enterprise.providers.radius",
|
||||
"authentik.enterprise.providers.scim",
|
||||
"authentik.enterprise.providers.ssf",
|
||||
|
||||
1
packages/client-ts/src/models/AppEnum.ts
generated
1
packages/client-ts/src/models/AppEnum.ts
generated
@@ -90,7 +90,6 @@ export const AppEnum = {
|
||||
AuthentikEnterprisePoliciesUniquePassword: "authentik.enterprise.policies.unique_password",
|
||||
AuthentikEnterpriseProvidersGoogleWorkspace: "authentik.enterprise.providers.google_workspace",
|
||||
AuthentikEnterpriseProvidersMicrosoftEntra: "authentik.enterprise.providers.microsoft_entra",
|
||||
AuthentikEnterpriseProvidersOauth2: "authentik.enterprise.providers.oauth2",
|
||||
AuthentikEnterpriseProvidersRadius: "authentik.enterprise.providers.radius",
|
||||
AuthentikEnterpriseProvidersScim: "authentik.enterprise.providers.scim",
|
||||
AuthentikEnterpriseProvidersSsf: "authentik.enterprise.providers.ssf",
|
||||
|
||||
@@ -36204,7 +36204,6 @@ components:
|
||||
- authentik.enterprise.policies.unique_password
|
||||
- authentik.enterprise.providers.google_workspace
|
||||
- authentik.enterprise.providers.microsoft_entra
|
||||
- authentik.enterprise.providers.oauth2
|
||||
- authentik.enterprise.providers.radius
|
||||
- authentik.enterprise.providers.scim
|
||||
- authentik.enterprise.providers.ssf
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import "#admin/common/ak-flow-search/ak-flow-search";
|
||||
import "#components/ak-switch-input";
|
||||
import "#components/ak-text-input";
|
||||
import "#elements/LicenseNotice";
|
||||
import "#elements/ak-checkbox-group/ak-checkbox-group";
|
||||
import "#elements/ak-dual-select/ak-dual-select-dynamic-selected-provider";
|
||||
import "#elements/forms/FormGroup";
|
||||
@@ -27,8 +26,7 @@ export interface OAuth2DCRFormProps {
|
||||
|
||||
export function renderForm({ dcr }: OAuth2DCRFormProps) {
|
||||
dcr ||= {};
|
||||
return html`<ak-license-notice></ak-license-notice>
|
||||
<ak-text-input
|
||||
return html`<ak-text-input
|
||||
name="defaultApplicationGroup"
|
||||
label=${msg("Default application group")}
|
||||
value="${ifDefined(dcr.defaultApplicationGroup)}"
|
||||
|
||||
Reference in New Issue
Block a user