start checkin

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-09-04 19:52:33 +02:00
parent cb6d4f9b27
commit 47cb4603da
No known key found for this signature in database
4 changed files with 111 additions and 9 deletions

View file

@ -1,4 +1,5 @@
"""AuthenticatorMobileStage API Views""" """AuthenticatorMobileStage API Views"""
from django.utils.translation import gettext_lazy as _
from django_filters.rest_framework.backends import DjangoFilterBackend from django_filters.rest_framework.backends import DjangoFilterBackend
from drf_spectacular.utils import OpenApiResponse, extend_schema, inline_serializer from drf_spectacular.utils import OpenApiResponse, extend_schema, inline_serializer
from rest_framework import mixins from rest_framework import mixins
@ -27,10 +28,30 @@ class MobileDeviceSerializer(ModelSerializer):
depth = 2 depth = 2
class MobileDeviceInfoSerializer(PassiveSerializer):
"""Info about a mobile device"""
platform = ChoiceField(
(
("ios", "iOS"),
("android", "Android"),
)
)
version = CharField()
app_version = CharField()
class MobileDeviceCheckInSerializer(PassiveSerializer):
"""Check info into authentik"""
info = MobileDeviceInfoSerializer()
class MobileDeviceEnrollmentSerializer(PassiveSerializer): class MobileDeviceEnrollmentSerializer(PassiveSerializer):
"""Enrollment request, send the device's unique identifier""" """Enrollment request, send the device's unique identifier"""
device_uid = CharField(required=True) device_uid = CharField(required=True)
info = MobileDeviceInfoSerializer()
class MobileDeviceSetPushKeySerializer(PassiveSerializer): class MobileDeviceSetPushKeySerializer(PassiveSerializer):
@ -39,6 +60,25 @@ class MobileDeviceSetPushKeySerializer(PassiveSerializer):
firebase_key = CharField(required=True) firebase_key = CharField(required=True)
class MobileDeviceResponseSerializer(PassiveSerializer):
"""Response from push sent to phone"""
tx_id = CharField(required=True)
status = ChoiceField(
(
(
"accept",
_("Accept"),
),
(
"deny",
_("Deny"),
),
),
required=True,
)
class MobileDeviceViewSet( class MobileDeviceViewSet(
mixins.RetrieveModelMixin, mixins.RetrieveModelMixin,
mixins.UpdateModelMixin, mixins.UpdateModelMixin,
@ -137,6 +177,7 @@ class MobileDeviceViewSet(
methods=["POST"], methods=["POST"],
detail=True, detail=True,
permission_classes=[], permission_classes=[],
filter_backends=[],
authentication_classes=[MobileDeviceTokenAuthentication], authentication_classes=[MobileDeviceTokenAuthentication],
) )
def set_notification_key(self, request: Request, pk: str) -> Response: def set_notification_key(self, request: Request, pk: str) -> Response:
@ -148,10 +189,17 @@ class MobileDeviceViewSet(
device.save() device.save()
return Response(status=204) return Response(status=204)
@extend_schema(
responses={
204: OpenApiResponse(description="Key successfully set"),
},
request=MobileDeviceResponseSerializer,
)
@action( @action(
methods=["POST"], methods=["POST"],
detail=True, detail=True,
permission_classes=[], permission_classes=[],
filter_backends=[],
authentication_classes=[MobileDeviceTokenAuthentication], authentication_classes=[MobileDeviceTokenAuthentication],
) )
def receive_response(self, request: Request, pk: str) -> Response: def receive_response(self, request: Request, pk: str) -> Response:

View file

@ -127,6 +127,7 @@ class MobileDevice(SerializerModel, Device):
badge=0, badge=0,
sound="default", sound="default",
content_available=True, content_available=True,
category="authentik_push_authentication",
), ),
interruption_level="time-sensitive", interruption_level="time-sensitive",
), ),

View file

@ -1613,7 +1613,8 @@
"enum": [ "enum": [
"absent", "absent",
"present", "present",
"created" "created",
"must_created"
], ],
"default": "present" "default": "present"
}, },
@ -1649,7 +1650,8 @@
"enum": [ "enum": [
"absent", "absent",
"present", "present",
"created" "created",
"must_created"
], ],
"default": "present" "default": "present"
}, },

View file

@ -2259,17 +2259,13 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/MobileDeviceRequest' $ref: '#/components/schemas/MobileDeviceResponseRequest'
required: true required: true
security: security:
- mobile_device_token: [] - mobile_device_token: []
responses: responses:
'200': '204':
content: description: Key successfully set
application/json:
schema:
$ref: '#/components/schemas/MobileDevice'
description: ''
'400': '400':
content: content:
application/json: application/json:
@ -18734,6 +18730,8 @@ paths:
- authentik_sources_saml.usersamlsourceconnection - authentik_sources_saml.usersamlsourceconnection
- authentik_stages_authenticator_duo.authenticatorduostage - authentik_stages_authenticator_duo.authenticatorduostage
- authentik_stages_authenticator_duo.duodevice - authentik_stages_authenticator_duo.duodevice
- authentik_stages_authenticator_mobile.authenticatormobilestage
- authentik_stages_authenticator_mobile.mobiledevice
- authentik_stages_authenticator_sms.authenticatorsmsstage - authentik_stages_authenticator_sms.authenticatorsmsstage
- authentik_stages_authenticator_sms.smsdevice - authentik_stages_authenticator_sms.smsdevice
- authentik_stages_authenticator_static.authenticatorstaticstage - authentik_stages_authenticator_static.authenticatorstaticstage
@ -18803,6 +18801,8 @@ paths:
* `authentik_sources_saml.usersamlsourceconnection` - User SAML Source Connection * `authentik_sources_saml.usersamlsourceconnection` - User SAML Source Connection
* `authentik_stages_authenticator_duo.authenticatorduostage` - Duo Authenticator Setup Stage * `authentik_stages_authenticator_duo.authenticatorduostage` - Duo Authenticator Setup Stage
* `authentik_stages_authenticator_duo.duodevice` - Duo Device * `authentik_stages_authenticator_duo.duodevice` - Duo Device
* `authentik_stages_authenticator_mobile.authenticatormobilestage` - Mobile Authenticator Setup Stage
* `authentik_stages_authenticator_mobile.mobiledevice` - Mobile Device
* `authentik_stages_authenticator_sms.authenticatorsmsstage` - SMS Authenticator Setup Stage * `authentik_stages_authenticator_sms.authenticatorsmsstage` - SMS Authenticator Setup Stage
* `authentik_stages_authenticator_sms.smsdevice` - SMS Device * `authentik_stages_authenticator_sms.smsdevice` - SMS Device
* `authentik_stages_authenticator_static.authenticatorstaticstage` - Static Authenticator Stage * `authentik_stages_authenticator_static.authenticatorstaticstage` - Static Authenticator Stage
@ -19028,6 +19028,8 @@ paths:
- authentik_sources_saml.usersamlsourceconnection - authentik_sources_saml.usersamlsourceconnection
- authentik_stages_authenticator_duo.authenticatorduostage - authentik_stages_authenticator_duo.authenticatorduostage
- authentik_stages_authenticator_duo.duodevice - authentik_stages_authenticator_duo.duodevice
- authentik_stages_authenticator_mobile.authenticatormobilestage
- authentik_stages_authenticator_mobile.mobiledevice
- authentik_stages_authenticator_sms.authenticatorsmsstage - authentik_stages_authenticator_sms.authenticatorsmsstage
- authentik_stages_authenticator_sms.smsdevice - authentik_stages_authenticator_sms.smsdevice
- authentik_stages_authenticator_static.authenticatorstaticstage - authentik_stages_authenticator_static.authenticatorstaticstage
@ -19097,6 +19099,8 @@ paths:
* `authentik_sources_saml.usersamlsourceconnection` - User SAML Source Connection * `authentik_sources_saml.usersamlsourceconnection` - User SAML Source Connection
* `authentik_stages_authenticator_duo.authenticatorduostage` - Duo Authenticator Setup Stage * `authentik_stages_authenticator_duo.authenticatorduostage` - Duo Authenticator Setup Stage
* `authentik_stages_authenticator_duo.duodevice` - Duo Device * `authentik_stages_authenticator_duo.duodevice` - Duo Device
* `authentik_stages_authenticator_mobile.authenticatormobilestage` - Mobile Authenticator Setup Stage
* `authentik_stages_authenticator_mobile.mobiledevice` - Mobile Device
* `authentik_stages_authenticator_sms.authenticatorsmsstage` - SMS Authenticator Setup Stage * `authentik_stages_authenticator_sms.authenticatorsmsstage` - SMS Authenticator Setup Stage
* `authentik_stages_authenticator_sms.smsdevice` - SMS Device * `authentik_stages_authenticator_sms.smsdevice` - SMS Device
* `authentik_stages_authenticator_static.authenticatorstaticstage` - Static Authenticator Stage * `authentik_stages_authenticator_static.authenticatorstaticstage` - Static Authenticator Stage
@ -35269,8 +35273,11 @@ components:
device_uid: device_uid:
type: string type: string
minLength: 1 minLength: 1
info:
$ref: '#/components/schemas/MobileDeviceInfoRequest'
required: required:
- device_uid - device_uid
- info
MobileDeviceEnrollmentStatus: MobileDeviceEnrollmentStatus:
type: object type: object
properties: properties:
@ -35286,6 +35293,22 @@ components:
description: |- description: |-
* `success` - Success * `success` - Success
* `waiting` - Waiting * `waiting` - Waiting
MobileDeviceInfoRequest:
type: object
description: Info about a mobile device
properties:
platform:
$ref: '#/components/schemas/PlatformEnum'
version:
type: string
minLength: 1
app_version:
type: string
minLength: 1
required:
- app_version
- platform
- version
MobileDeviceRequest: MobileDeviceRequest:
type: object type: object
description: Serializer for Mobile authenticator devices description: Serializer for Mobile authenticator devices
@ -35301,6 +35324,26 @@ components:
maxLength: 64 maxLength: 64
required: required:
- name - name
MobileDeviceResponseRequest:
type: object
description: Response from push sent to phone
properties:
tx_id:
type: string
minLength: 1
status:
$ref: '#/components/schemas/MobileDeviceResponseStatusEnum'
required:
- status
- tx_id
MobileDeviceResponseStatusEnum:
enum:
- accept
- deny
type: string
description: |-
* `accept` - Accept
* `deny` - Deny
MobileDeviceSetPushKeyRequest: MobileDeviceSetPushKeyRequest:
type: object type: object
description: Set notification key description: Set notification key
@ -40528,6 +40571,14 @@ components:
minLength: 1 minLength: 1
required: required:
- permissions - permissions
PlatformEnum:
enum:
- ios
- android
type: string
description: |-
* `ios` - iOS
* `android` - Android
PlexAuthenticationChallenge: PlexAuthenticationChallenge:
type: object type: object
description: Challenge shown to the user in identification stage description: Challenge shown to the user in identification stage