allow setting firebase api key while sending enrollment callback

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2024-01-02 22:59:43 +01:00
parent c90d35b113
commit 76498a2d7b
No known key found for this signature in database
3 changed files with 16 additions and 7 deletions

View file

@ -53,19 +53,19 @@ class MobileDeviceCheckInSerializer(PassiveSerializer):
info = MobileDeviceInfoSerializer() info = MobileDeviceInfoSerializer()
class MobileDeviceEnrollmentSerializer(PassiveSerializer):
"""Enrollment request, send the device's unique identifier"""
device_uid = CharField(required=True)
info = MobileDeviceInfoSerializer()
class MobileDeviceSetPushKeySerializer(PassiveSerializer): class MobileDeviceSetPushKeySerializer(PassiveSerializer):
"""Set notification key""" """Set notification key"""
firebase_key = CharField(required=True) firebase_key = CharField(required=True)
class MobileDeviceEnrollmentSerializer(MobileDeviceSetPushKeySerializer):
"""Enrollment request, send the device's unique identifier"""
device_uid = CharField(required=True)
info = MobileDeviceInfoSerializer()
class MobileDeviceResponseSerializer(PassiveSerializer): class MobileDeviceResponseSerializer(PassiveSerializer):
"""Response from push sent to phone""" """Response from push sent to phone"""
@ -120,6 +120,7 @@ class MobileDeviceViewSet(
device.name = data.validated_data["info"]["hostname"] device.name = data.validated_data["info"]["hostname"]
device.confirmed = True device.confirmed = True
device.device_id = data.validated_data["device_uid"] device.device_id = data.validated_data["device_uid"]
device.firebase_token = data.validated_data["firebase_key"]
device.save() device.save()
MobileDeviceToken.objects.filter( MobileDeviceToken.objects.filter(
device=device, device=device,

View file

@ -35380,6 +35380,9 @@ components:
type: object type: object
description: Enrollment request, send the device's unique identifier description: Enrollment request, send the device's unique identifier
properties: properties:
firebase_key:
type: string
minLength: 1
device_uid: device_uid:
type: string type: string
minLength: 1 minLength: 1
@ -35387,6 +35390,7 @@ components:
$ref: '#/components/schemas/MobileDeviceInfoRequest' $ref: '#/components/schemas/MobileDeviceInfoRequest'
required: required:
- device_uid - device_uid
- firebase_key
- info - info
MobileDeviceEnrollmentStatus: MobileDeviceEnrollmentStatus:
type: object type: object

View file

@ -511,6 +511,9 @@ components:
type: object type: object
description: Enrollment request, send the device's unique identifier description: Enrollment request, send the device's unique identifier
properties: properties:
firebase_key:
type: string
minLength: 1
device_uid: device_uid:
type: string type: string
minLength: 1 minLength: 1
@ -518,6 +521,7 @@ components:
$ref: '#/components/schemas/MobileDeviceInfoRequest' $ref: '#/components/schemas/MobileDeviceInfoRequest'
required: required:
- device_uid - device_uid
- firebase_key
- info - info
MobileDeviceEnrollmentStatus: MobileDeviceEnrollmentStatus:
type: object type: object