Skip to content

Commit

Permalink
move
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
BeryJu committed Mar 12, 2024
1 parent 2b021ba commit 3078664
Show file tree
Hide file tree
Showing 17 changed files with 197 additions and 180 deletions.
1 change: 1 addition & 0 deletions authentik/enterprise/settings.py
Expand Up @@ -15,6 +15,7 @@
TENANT_APPS = [
"authentik.enterprise.audit",
"authentik.enterprise.providers.rac",
"authentik.enterprise.stages.source",
]

MIDDLEWARE = ["authentik.enterprise.middleware.EnterpriseMiddleware"]
File renamed without changes.
@@ -1,14 +1,16 @@
"""Source Stage API Views"""

from rest_framework.exceptions import ValidationError
from rest_framework.viewsets import ModelViewSet

from authentik.core.api.used_by import UsedByMixin
from authentik.core.models import Source
from authentik.enterprise.api import EnterpriseRequiredMixin
from authentik.enterprise.stages.source.models import SourceStage
from authentik.flows.api.stages import StageSerializer
from authentik.stages.source.models import SourceStage


class SourceStageSerializer(StageSerializer):
class SourceStageSerializer(EnterpriseRequiredMixin, StageSerializer):
"""SourceStage Serializer"""

def validate_source(self, _source: Source) -> Source:
Expand Down
12 changes: 12 additions & 0 deletions authentik/enterprise/stages/source/apps.py
@@ -0,0 +1,12 @@
"""authentik stage app config"""

from authentik.enterprise.apps import EnterpriseConfig


class AuthentikEnterpriseStageSourceConfig(EnterpriseConfig):
"""authentik source stage config"""

name = "authentik.enterprise.stages.source"
label = "authentik_stages_source"
verbose_name = "authentik Enterprise.Stages.Source"
default = True
@@ -1,16 +1,16 @@
# Generated by Django 5.0.1 on 2024-01-27 17:17
# Generated by Django 5.0.2 on 2024-02-25 20:44

import authentik.lib.utils.time
import django.db.models.deletion
from django.db import migrations, models

import authentik.lib.utils.time


class Migration(migrations.Migration):

initial = True

dependencies = [
("authentik_core", "0032_group_roles"),
("authentik_core", "0033_alter_user_options"),
("authentik_flows", "0027_auto_20231028_1424"),
]

Expand Down
Empty file.
@@ -1,4 +1,5 @@
"""Source stage models"""

from django.db import models
from django.utils.translation import gettext_lazy as _
from django.views import View
Expand All @@ -25,13 +26,13 @@ class SourceStage(Stage):

@property
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.source.api import SourceStageSerializer
from authentik.enterprise.stages.source.api import SourceStageSerializer

return SourceStageSerializer

@property
def type(self) -> type[View]:
from authentik.stages.source.stage import SourceStageView
def view(self) -> type[View]:
from authentik.enterprise.stages.source.stage import SourceStageView

return SourceStageView

Expand Down
@@ -1,4 +1,5 @@
"""Source stage logic"""

from typing import Any
from uuid import uuid4

Expand All @@ -10,12 +11,12 @@
from authentik.core.models import Source, User
from authentik.core.sources.flow_manager import SESSION_KEY_OVERRIDE_FLOW_TOKEN
from authentik.core.types import UILoginButton
from authentik.enterprise.stages.source.models import SourceStage
from authentik.flows.challenge import Challenge, ChallengeResponse
from authentik.flows.models import FlowToken
from authentik.flows.planner import PLAN_CONTEXT_IS_RESTORED
from authentik.flows.stage import ChallengeStageView
from authentik.lib.utils.time import timedelta_from_string
from authentik.stages.source.models import SourceStage

PLAN_CONTEXT_RESUME_TOKEN = "resume_token" # nosec

Expand Down
@@ -1,7 +1,9 @@
"""Source stage tests"""

from django.urls import reverse

from authentik.core.tests.utils import create_test_flow, create_test_user
from authentik.enterprise.stages.source.models import SourceStage
from authentik.flows.models import FlowDesignation, FlowStageBinding, FlowToken
from authentik.flows.planner import PLAN_CONTEXT_IS_RESTORED, FlowPlan
from authentik.flows.tests import FlowTestCase
Expand All @@ -11,7 +13,6 @@
from authentik.stages.identification.models import IdentificationStage, UserFields
from authentik.stages.password import BACKEND_INBUILT
from authentik.stages.password.models import PasswordStage
from authentik.stages.source.models import SourceStage
from authentik.stages.user_login.models import UserLoginStage


Expand Down
@@ -1,4 +1,5 @@
"""API URLs"""
from authentik.stages.source.api import SourceStageViewSet

from authentik.enterprise.stages.source.api import SourceStageViewSet

api_urlpatterns = [("stages/source", SourceStageViewSet)]
2 changes: 2 additions & 0 deletions authentik/flows/api/stages.py
Expand Up @@ -13,6 +13,7 @@
from authentik.core.api.used_by import UsedByMixin
from authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer
from authentik.core.types import UserSettingSerializer
from authentik.enterprise.apps import EnterpriseConfig
from authentik.flows.api.flows import FlowSetSerializer
from authentik.flows.models import ConfigurableStage, Stage
from authentik.lib.utils.reflection import all_subclasses
Expand Down Expand Up @@ -75,6 +76,7 @@ def types(self, request: Request) -> Response:
"description": subclass.__doc__,
"component": subclass().component,
"model_name": subclass._meta.model_name,
"requires_enterprise": isinstance(subclass._meta.app_config, EnterpriseConfig),
}
)
data = sorted(data, key=lambda x: x["name"])
Expand Down
1 change: 0 additions & 1 deletion authentik/root/settings.py
Expand Up @@ -106,7 +106,6 @@
"authentik.stages.invitation",
"authentik.stages.password",
"authentik.stages.prompt",
"authentik.stages.source",
"authentik.stages.user_delete",
"authentik.stages.user_login",
"authentik.stages.user_logout",
Expand Down
10 changes: 0 additions & 10 deletions authentik/stages/source/apps.py

This file was deleted.

0 comments on commit 3078664

Please sign in to comment.