-
-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stages: authenticator_endpoint_gdtc (#10477)
* rework Signed-off-by: Jens Langhammer <[email protected]> * add loading overlay for chrome Signed-off-by: Jens Langhammer <[email protected]> * start docs Signed-off-by: Jens Langhammer <[email protected]> * Apply suggestions from code review Co-authored-by: Tana M Berry <[email protected]> Signed-off-by: Jens L. <[email protected]> * save data Signed-off-by: Jens Langhammer <[email protected]> * fix web ui, prevent deletion Signed-off-by: Jens Langhammer <[email protected]> * fix Signed-off-by: Jens Langhammer <[email protected]> * text fixes Signed-off-by: Jens Langhammer <[email protected]> --------- Signed-off-by: Jens Langhammer <[email protected]> Signed-off-by: Jens L. <[email protected]> Co-authored-by: Tana M Berry <[email protected]>
- Loading branch information
Showing
30 changed files
with
1,959 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
authentik/enterprise/stages/authenticator_endpoint_gdtc/api.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
"""AuthenticatorEndpointGDTCStage API Views""" | ||
|
||
from django_filters.rest_framework.backends import DjangoFilterBackend | ||
from rest_framework import mixins | ||
from rest_framework.filters import OrderingFilter, SearchFilter | ||
from rest_framework.permissions import IsAdminUser | ||
from rest_framework.serializers import ModelSerializer | ||
from rest_framework.viewsets import GenericViewSet, ModelViewSet | ||
from structlog.stdlib import get_logger | ||
|
||
from authentik.api.authorization import OwnerFilter, OwnerPermissions | ||
from authentik.core.api.used_by import UsedByMixin | ||
from authentik.enterprise.api import EnterpriseRequiredMixin | ||
from authentik.enterprise.stages.authenticator_endpoint_gdtc.models import ( | ||
AuthenticatorEndpointGDTCStage, | ||
EndpointDevice, | ||
) | ||
from authentik.flows.api.stages import StageSerializer | ||
|
||
LOGGER = get_logger() | ||
|
||
|
||
class AuthenticatorEndpointGDTCStageSerializer(EnterpriseRequiredMixin, StageSerializer): | ||
"""AuthenticatorEndpointGDTCStage Serializer""" | ||
|
||
class Meta: | ||
model = AuthenticatorEndpointGDTCStage | ||
fields = StageSerializer.Meta.fields + [ | ||
"configure_flow", | ||
"friendly_name", | ||
"credentials", | ||
] | ||
|
||
|
||
class AuthenticatorEndpointGDTCStageViewSet(UsedByMixin, ModelViewSet): | ||
"""AuthenticatorEndpointGDTCStage Viewset""" | ||
|
||
queryset = AuthenticatorEndpointGDTCStage.objects.all() | ||
serializer_class = AuthenticatorEndpointGDTCStageSerializer | ||
filterset_fields = [ | ||
"name", | ||
"configure_flow", | ||
] | ||
search_fields = ["name"] | ||
ordering = ["name"] | ||
|
||
|
||
class EndpointDeviceSerializer(ModelSerializer): | ||
"""Serializer for Endpoint authenticator devices""" | ||
|
||
class Meta: | ||
model = EndpointDevice | ||
fields = ["pk", "name"] | ||
depth = 2 | ||
|
||
|
||
class EndpointDeviceViewSet( | ||
mixins.RetrieveModelMixin, | ||
mixins.ListModelMixin, | ||
UsedByMixin, | ||
GenericViewSet, | ||
): | ||
"""Viewset for Endpoint authenticator devices""" | ||
|
||
queryset = EndpointDevice.objects.all() | ||
serializer_class = EndpointDeviceSerializer | ||
search_fields = ["name"] | ||
filterset_fields = ["name"] | ||
ordering = ["name"] | ||
permission_classes = [OwnerPermissions] | ||
filter_backends = [OwnerFilter, DjangoFilterBackend, OrderingFilter, SearchFilter] | ||
|
||
|
||
class EndpointAdminDeviceViewSet(ModelViewSet): | ||
"""Viewset for Endpoint authenticator devices (for admins)""" | ||
|
||
permission_classes = [IsAdminUser] | ||
queryset = EndpointDevice.objects.all() | ||
serializer_class = EndpointDeviceSerializer | ||
search_fields = ["name"] | ||
filterset_fields = ["name"] | ||
ordering = ["name"] |
13 changes: 13 additions & 0 deletions
13
authentik/enterprise/stages/authenticator_endpoint_gdtc/apps.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""authentik Endpoint app config""" | ||
|
||
from authentik.enterprise.apps import EnterpriseConfig | ||
|
||
|
||
class AuthentikStageAuthenticatorEndpointConfig(EnterpriseConfig): | ||
"""authentik endpoint config""" | ||
|
||
name = "authentik.enterprise.stages.authenticator_endpoint_gdtc" | ||
label = "authentik_stages_authenticator_endpoint_gdtc" | ||
verbose_name = "authentik Enterprise.Stages.Authenticator.Endpoint GDTC" | ||
default = True | ||
mountpoint = "endpoint/gdtc/" |
115 changes: 115 additions & 0 deletions
115
authentik/enterprise/stages/authenticator_endpoint_gdtc/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Generated by Django 5.0.9 on 2024-10-22 11:40 | ||
|
||
import django.db.models.deletion | ||
import uuid | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
("authentik_flows", "0027_auto_20231028_1424"), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="AuthenticatorEndpointGDTCStage", | ||
fields=[ | ||
( | ||
"stage_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="authentik_flows.stage", | ||
), | ||
), | ||
("friendly_name", models.TextField(null=True)), | ||
("credentials", models.JSONField()), | ||
( | ||
"configure_flow", | ||
models.ForeignKey( | ||
blank=True, | ||
help_text="Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.", | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
to="authentik_flows.flow", | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "Endpoint Authenticator Google Device Trust Connector Stage", | ||
"verbose_name_plural": "Endpoint Authenticator Google Device Trust Connector Stages", | ||
}, | ||
bases=("authentik_flows.stage", models.Model), | ||
), | ||
migrations.CreateModel( | ||
name="EndpointDevice", | ||
fields=[ | ||
("created", models.DateTimeField(auto_now_add=True)), | ||
("last_updated", models.DateTimeField(auto_now=True)), | ||
( | ||
"name", | ||
models.CharField( | ||
help_text="The human-readable name of this device.", max_length=64 | ||
), | ||
), | ||
( | ||
"confirmed", | ||
models.BooleanField(default=True, help_text="Is this device ready for use?"), | ||
), | ||
("last_used", models.DateTimeField(null=True)), | ||
("uuid", models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)), | ||
( | ||
"host_identifier", | ||
models.TextField( | ||
help_text="A unique identifier for the endpoint device, usually the device serial number", | ||
unique=True, | ||
), | ||
), | ||
("data", models.JSONField()), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "Endpoint Device", | ||
"verbose_name_plural": "Endpoint Devices", | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="EndpointDeviceConnection", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
("attributes", models.JSONField()), | ||
( | ||
"device", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="authentik_stages_authenticator_endpoint_gdtc.endpointdevice", | ||
), | ||
), | ||
( | ||
"stage", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="authentik_stages_authenticator_endpoint_gdtc.authenticatorendpointgdtcstage", | ||
), | ||
), | ||
], | ||
), | ||
] |
Empty file.
Oops, something went wrong.