Skip to content

Commit 2713b05

Browse files
committed
Merge branch 'master' into version-2021.3
Signed-off-by: Jens Langhammer <[email protected]> # Conflicts: # docker-compose.yml # helm/README.md # web/src/authentik.css # web/src/flows/FlowExecutor.ts # web/src/flows/stages/identification/IdentificationStage.ts # website/docs/installation/kubernetes.md
2 parents df7119b + fef5a5c commit 2713b05

File tree

198 files changed

+39533
-6088
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+39533
-6088
lines changed

.bumpversion.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ values =
3636
[bumpversion:file:outpost/pkg/version.go]
3737

3838
[bumpversion:file:web/src/constants.ts]
39+
40+
[bumpversion:file:website/docs/outpusts/manual-deploy-docker-compose.md]
41+
42+
[bumpversion:file:website/docs/outpusts/manual-deploy-kubernetes.md]

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ jobs:
5959
runs-on: ubuntu-latest
6060
steps:
6161
- uses: actions/checkout@v1
62+
- name: prepare ts api client
63+
run: |
64+
docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/swagger.yaml -g typescript-fetch -o /local/web/src/api --additional-properties=typescriptThreePlus=true
6265
- name: Docker Login Registry
6366
env:
6467
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ COPY ./lifecycle/ /lifecycle
4545
USER authentik
4646
STOPSIGNAL SIGINT
4747
ENV TMPDIR /dev/shm/
48+
ENV PYTHONUBUFFERED 1
4849
ENTRYPOINT [ "/lifecycle/bootstrap.sh" ]

Pipfile.lock

Lines changed: 115 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

authentik/admin/api/metrics.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from django.db.models.fields import DurationField
88
from django.db.models.functions import ExtractHour
99
from django.utils.timezone import now
10-
from drf_yasg2.utils import swagger_auto_schema
11-
from rest_framework.fields import SerializerMethodField
10+
from drf_yasg2.utils import swagger_auto_schema, swagger_serializer_method
11+
from rest_framework.fields import IntegerField, SerializerMethodField
1212
from rest_framework.permissions import IsAdminUser
1313
from rest_framework.request import Request
1414
from rest_framework.response import Response
@@ -37,23 +37,39 @@ def get_events_per_1h(**filter_kwargs) -> list[dict[str, int]]:
3737
for hour in range(0, -24, -1):
3838
results.append(
3939
{
40-
"x": time.mktime((_now + timedelta(hours=hour)).timetuple()) * 1000,
41-
"y": data[hour * -1],
40+
"x_cord": time.mktime((_now + timedelta(hours=hour)).timetuple())
41+
* 1000,
42+
"y_cord": data[hour * -1],
4243
}
4344
)
4445
return results
4546

4647

47-
class AdministrationMetricsSerializer(Serializer):
48+
class CoordinateSerializer(Serializer):
49+
"""Coordinates for diagrams"""
50+
51+
x_cord = IntegerField(read_only=True)
52+
y_cord = IntegerField(read_only=True)
53+
54+
def create(self, validated_data: dict) -> Model:
55+
raise NotImplementedError
56+
57+
def update(self, instance: Model, validated_data: dict) -> Model:
58+
raise NotImplementedError
59+
60+
61+
class LoginMetricsSerializer(Serializer):
4862
"""Login Metrics per 1h"""
4963

5064
logins_per_1h = SerializerMethodField()
5165
logins_failed_per_1h = SerializerMethodField()
5266

67+
@swagger_serializer_method(serializer_or_field=CoordinateSerializer(many=True))
5368
def get_logins_per_1h(self, _):
5469
"""Get successful logins per hour for the last 24 hours"""
5570
return get_events_per_1h(action=EventAction.LOGIN)
5671

72+
@swagger_serializer_method(serializer_or_field=CoordinateSerializer(many=True))
5773
def get_logins_failed_per_1h(self, _):
5874
"""Get failed logins per hour for the last 24 hours"""
5975
return get_events_per_1h(action=EventAction.LOGIN_FAILED)
@@ -70,8 +86,8 @@ class AdministrationMetricsViewSet(ViewSet):
7086

7187
permission_classes = [IsAdminUser]
7288

73-
@swagger_auto_schema(responses={200: AdministrationMetricsSerializer(many=True)})
89+
@swagger_auto_schema(responses={200: LoginMetricsSerializer(many=False)})
7490
def list(self, request: Request) -> Response:
7591
"""Login Metrics per 1h"""
76-
serializer = AdministrationMetricsSerializer(True)
92+
serializer = LoginMetricsSerializer(True)
7793
return Response(serializer.data)

authentik/admin/api/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class TaskSerializer(Serializer):
2525
task_finish_timestamp = DateTimeField(source="finish_timestamp")
2626

2727
status = ChoiceField(
28-
source="result.status.value",
29-
choices=[(x.value, x.name) for x in TaskResultStatus],
28+
source="result.status.name",
29+
choices=[(x.name, x.name) for x in TaskResultStatus],
3030
)
3131
messages = ListField(source="result.messages")
3232

authentik/api/v2/urls.py

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""api v2 urls"""
2+
from django.conf import settings
23
from django.urls import path, re_path
34
from drf_yasg2 import openapi
45
from drf_yasg2.views import get_schema_view
@@ -54,12 +55,24 @@
5455
from authentik.sources.ldap.api import LDAPPropertyMappingViewSet, LDAPSourceViewSet
5556
from authentik.sources.oauth.api import OAuthSourceViewSet
5657
from authentik.sources.saml.api import SAMLSourceViewSet
57-
from authentik.stages.authenticator_static.api import AuthenticatorStaticStageViewSet
58-
from authentik.stages.authenticator_totp.api import AuthenticatorTOTPStageViewSet
58+
from authentik.stages.authenticator_static.api import (
59+
AuthenticatorStaticStageViewSet,
60+
StaticAdminDeviceViewSet,
61+
StaticDeviceViewSet,
62+
)
63+
from authentik.stages.authenticator_totp.api import (
64+
AuthenticatorTOTPStageViewSet,
65+
TOTPAdminDeviceViewSet,
66+
TOTPDeviceViewSet,
67+
)
5968
from authentik.stages.authenticator_validate.api import (
6069
AuthenticatorValidateStageViewSet,
6170
)
62-
from authentik.stages.authenticator_webauthn.api import AuthenticateWebAuthnStageViewSet
71+
from authentik.stages.authenticator_webauthn.api import (
72+
AuthenticateWebAuthnStageViewSet,
73+
WebAuthnAdminDeviceViewSet,
74+
WebAuthnDeviceViewSet,
75+
)
6376
from authentik.stages.captcha.api import CaptchaStageViewSet
6477
from authentik.stages.consent.api import ConsentStageViewSet
6578
from authentik.stages.deny.api import DenyStageViewSet
@@ -133,6 +146,13 @@
133146
router.register("propertymappings/saml", SAMLPropertyMappingViewSet)
134147
router.register("propertymappings/scope", ScopeMappingViewSet)
135148

149+
router.register("authenticators/static", StaticDeviceViewSet)
150+
router.register("authenticators/totp", TOTPDeviceViewSet)
151+
router.register("authenticators/webauthn", WebAuthnDeviceViewSet)
152+
router.register("authenticators/admin/static", StaticAdminDeviceViewSet)
153+
router.register("authenticators/admin/totp", TOTPAdminDeviceViewSet)
154+
router.register("authenticators/admin/webauthn", WebAuthnAdminDeviceViewSet)
155+
136156
router.register("stages/all", StageViewSet)
137157
router.register("stages/authenticator/static", AuthenticatorStaticStageViewSet)
138158
router.register("stages/authenticator/totp", AuthenticatorTOTPStageViewSet)
@@ -164,27 +184,26 @@
164184
name="GNU GPLv3", url="https://github.com/BeryJu/authentik/blob/master/LICENSE"
165185
),
166186
)
167-
SchemaView = get_schema_view(
168-
info,
169-
public=True,
170-
permission_classes=(AllowAny,),
171-
)
187+
SchemaView = get_schema_view(info, public=True, permission_classes=(AllowAny,))
172188

173-
urlpatterns = [
174-
re_path(
175-
r"^swagger(?P<format>\.json|\.yaml)$",
176-
SchemaView.without_ui(cache_timeout=0),
177-
name="schema-json",
178-
),
179-
path(
180-
"swagger/",
181-
SchemaView.with_ui("swagger", cache_timeout=0),
182-
name="schema-swagger-ui",
183-
),
184-
path("redoc/", SchemaView.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
189+
urlpatterns = router.urls + [
185190
path(
186191
"flows/executor/<slug:flow_slug>/",
187192
FlowExecutorView.as_view(),
188193
name="flow-executor",
189194
),
190-
] + router.urls
195+
re_path(
196+
r"^swagger(?P<format>\.json|\.yaml)$",
197+
SchemaView.without_ui(cache_timeout=0),
198+
name="schema-json",
199+
),
200+
]
201+
202+
if settings.DEBUG:
203+
urlpatterns = urlpatterns + [
204+
path(
205+
"swagger/",
206+
SchemaView.with_ui("swagger", cache_timeout=0),
207+
name="schema-swagger-ui",
208+
),
209+
]

authentik/core/api/applications.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from django.core.cache import cache
33
from django.db.models import QuerySet
44
from django.http.response import Http404
5+
from drf_yasg2.utils import swagger_auto_schema
56
from guardian.shortcuts import get_objects_for_user
67
from rest_framework.decorators import action
78
from rest_framework.fields import SerializerMethodField
@@ -13,7 +14,7 @@
1314
from rest_framework_guardian.filters import ObjectPermissionsFilter
1415
from structlog.stdlib import get_logger
1516

16-
from authentik.admin.api.metrics import get_events_per_1h
17+
from authentik.admin.api.metrics import CoordinateSerializer, get_events_per_1h
1718
from authentik.core.api.providers import ProviderSerializer
1819
from authentik.core.models import Application
1920
from authentik.events.models import EventAction
@@ -109,6 +110,7 @@ def list(self, request: Request) -> Response:
109110
serializer = self.get_serializer(allowed_applications, many=True)
110111
return self.get_paginated_response(serializer.data)
111112

113+
@swagger_auto_schema(responses={200: CoordinateSerializer(many=True)})
112114
@action(detail=True)
113115
def metrics(self, request: Request, slug: str):
114116
"""Metrics for application logins"""

authentik/core/api/groups.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ class GroupViewSet(ModelViewSet):
2121
serializer_class = GroupSerializer
2222
search_fields = ["name", "is_superuser"]
2323
filterset_fields = ["name", "is_superuser"]
24+
ordering = ["name"]

authentik/core/api/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def get_verbose_name_plural(self, obj: Model) -> str:
2828
class TypeCreateSerializer(Serializer):
2929
"""Types of an object that can be created"""
3030

31-
name = CharField(read_only=True)
32-
description = CharField(read_only=True)
33-
link = CharField(read_only=True)
31+
name = CharField(required=True)
32+
description = CharField(required=True)
33+
link = CharField(required=True)
3434

3535
def create(self, validated_data: dict) -> Model:
3636
raise NotImplementedError

0 commit comments

Comments
 (0)