change mobile device pk to uuid
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
e99a660a5f
commit
28e1c08800
|
@ -1,6 +1,7 @@
|
||||||
"""api v3 urls"""
|
"""api v3 urls"""
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from django.urls.resolvers import URLPattern
|
from django.urls.resolvers import URLPattern
|
||||||
from django.views.decorators.cache import cache_page
|
from django.views.decorators.cache import cache_page
|
||||||
|
@ -11,7 +12,6 @@ from structlog.stdlib import get_logger
|
||||||
from authentik.api.v3.config import ConfigView
|
from authentik.api.v3.config import ConfigView
|
||||||
from authentik.api.views import APIBrowserView
|
from authentik.api.views import APIBrowserView
|
||||||
from authentik.lib.utils.reflection import get_apps
|
from authentik.lib.utils.reflection import get_apps
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
LOGGER = get_logger()
|
LOGGER = get_logger()
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
"""AuthenticatorMobileStage API Views"""
|
"""AuthenticatorMobileStage API Views"""
|
||||||
from django_filters.rest_framework.backends import DjangoFilterBackend
|
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 drf_spectacular.utils import extend_schema, inline_serializer
|
from drf_spectacular.utils import extend_schema, inline_serializer
|
||||||
|
from rest_framework import mixins
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.fields import CharField, UUIDField
|
from rest_framework.fields import CharField, UUIDField
|
||||||
|
from rest_framework.filters import OrderingFilter, SearchFilter
|
||||||
|
from rest_framework.permissions import IsAdminUser
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
from rest_framework.serializers import ModelSerializer
|
||||||
|
from rest_framework.viewsets import GenericViewSet, ModelViewSet
|
||||||
|
|
||||||
from authentik.api.authorization import OwnerFilter, OwnerPermissions
|
from authentik.api.authorization import OwnerFilter, OwnerPermissions
|
||||||
from authentik.core.api.used_by import UsedByMixin
|
from authentik.core.api.used_by import UsedByMixin
|
||||||
from authentik.stages.authenticator_mobile.api.auth import MobileDeviceTokenAuthentication
|
from authentik.stages.authenticator_mobile.api.auth import MobileDeviceTokenAuthentication
|
||||||
|
@ -80,10 +80,7 @@ class MobileDeviceViewSet(
|
||||||
responses={
|
responses={
|
||||||
200: inline_serializer(
|
200: inline_serializer(
|
||||||
"MobileDeviceEnrollmentCallbackSerializer",
|
"MobileDeviceEnrollmentCallbackSerializer",
|
||||||
{
|
{"device_token": CharField(required=True), "device_uuid": UUIDField(required=True)},
|
||||||
"device_token": CharField(required=True),
|
|
||||||
"device_uuid": UUIDField(required=True)
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
request=inline_serializer(
|
request=inline_serializer(
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
# Generated by Django 4.1.10 on 2023-07-24 21:33
|
# Generated by Django 4.2.4 on 2023-09-04 11:59
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -52,12 +54,6 @@ class Migration(migrations.Migration):
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="MobileDevice",
|
name="MobileDevice",
|
||||||
fields=[
|
fields=[
|
||||||
(
|
|
||||||
"id",
|
|
||||||
models.AutoField(
|
|
||||||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
(
|
||||||
"name",
|
"name",
|
||||||
models.CharField(
|
models.CharField(
|
||||||
|
@ -68,6 +64,7 @@ class Migration(migrations.Migration):
|
||||||
"confirmed",
|
"confirmed",
|
||||||
models.BooleanField(default=True, help_text="Is this device ready for use?"),
|
models.BooleanField(default=True, help_text="Is this device ready for use?"),
|
||||||
),
|
),
|
||||||
|
("uuid", models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
|
||||||
("device_id", models.TextField(unique=True)),
|
("device_id", models.TextField(unique=True)),
|
||||||
(
|
(
|
||||||
"stage",
|
"stage",
|
||||||
|
@ -108,6 +105,7 @@ class Migration(migrations.Migration):
|
||||||
default=authentik.stages.authenticator_mobile.models.default_token_key
|
default=authentik.stages.authenticator_mobile.models.default_token_key
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
("firebase_token", models.TextField(blank=True)),
|
||||||
(
|
(
|
||||||
"device",
|
"device",
|
||||||
models.ForeignKey(
|
models.ForeignKey(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Mobile authenticator stage"""
|
"""Mobile authenticator stage"""
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -60,6 +61,8 @@ class AuthenticatorMobileStage(ConfigurableStage, FriendlyNamedStage, Stage):
|
||||||
class MobileDevice(SerializerModel, Device):
|
class MobileDevice(SerializerModel, Device):
|
||||||
"""Mobile authenticator for a single user"""
|
"""Mobile authenticator for a single user"""
|
||||||
|
|
||||||
|
uuid = models.UUIDField(primary_key=True, default=uuid4)
|
||||||
|
|
||||||
user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
|
user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
|
||||||
|
|
||||||
# Connect to the stage to when validating access we know the API Credentials
|
# Connect to the stage to when validating access we know the API Credentials
|
||||||
|
|
|
@ -10,7 +10,10 @@ from authentik.flows.challenge import (
|
||||||
WithUserInfoChallenge,
|
WithUserInfoChallenge,
|
||||||
)
|
)
|
||||||
from authentik.flows.stage import ChallengeStageView
|
from authentik.flows.stage import ChallengeStageView
|
||||||
from authentik.stages.authenticator_mobile.models import AuthenticatorMobileStage, MobileDevice, MobileDeviceToken
|
from authentik.stages.authenticator_mobile.models import (
|
||||||
|
MobileDevice,
|
||||||
|
MobileDeviceToken,
|
||||||
|
)
|
||||||
|
|
||||||
FLOW_PLAN_MOBILE_ENROLL = "authentik/stages/authenticator_mobile/enroll"
|
FLOW_PLAN_MOBILE_ENROLL = "authentik/stages/authenticator_mobile/enroll"
|
||||||
|
|
||||||
|
|
|
@ -6148,6 +6148,11 @@
|
||||||
"model_authentik_stages_authenticator_mobile.mobiledevice": {
|
"model_authentik_stages_authenticator_mobile.mobiledevice": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"pk": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uuid",
|
||||||
|
"title": "Uuid"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 64,
|
"maxLength": 64,
|
||||||
|
|
111
schema.yml
111
schema.yml
|
@ -648,16 +648,17 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/GenericError'
|
$ref: '#/components/schemas/GenericError'
|
||||||
description: ''
|
description: ''
|
||||||
/authenticators/admin/mobile/{id}/:
|
/authenticators/admin/mobile/{uuid}/:
|
||||||
get:
|
get:
|
||||||
operationId: authenticators_admin_mobile_retrieve
|
operationId: authenticators_admin_mobile_retrieve
|
||||||
description: Viewset for Mobile authenticator devices (for admins)
|
description: Viewset for Mobile authenticator devices (for admins)
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -687,10 +688,11 @@ paths:
|
||||||
description: Viewset for Mobile authenticator devices (for admins)
|
description: Viewset for Mobile authenticator devices (for admins)
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -726,10 +728,11 @@ paths:
|
||||||
description: Viewset for Mobile authenticator devices (for admins)
|
description: Viewset for Mobile authenticator devices (for admins)
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -764,10 +767,11 @@ paths:
|
||||||
description: Viewset for Mobile authenticator devices (for admins)
|
description: Viewset for Mobile authenticator devices (for admins)
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -2017,16 +2021,17 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/GenericError'
|
$ref: '#/components/schemas/GenericError'
|
||||||
description: ''
|
description: ''
|
||||||
/authenticators/mobile/{id}/:
|
/authenticators/mobile/{uuid}/:
|
||||||
get:
|
get:
|
||||||
operationId: authenticators_mobile_retrieve
|
operationId: authenticators_mobile_retrieve
|
||||||
description: Viewset for Mobile authenticator devices
|
description: Viewset for Mobile authenticator devices
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -2056,10 +2061,11 @@ paths:
|
||||||
description: Viewset for Mobile authenticator devices
|
description: Viewset for Mobile authenticator devices
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -2095,10 +2101,11 @@ paths:
|
||||||
description: Viewset for Mobile authenticator devices
|
description: Viewset for Mobile authenticator devices
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -2133,10 +2140,11 @@ paths:
|
||||||
description: Viewset for Mobile authenticator devices
|
description: Viewset for Mobile authenticator devices
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -2157,16 +2165,17 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/GenericError'
|
$ref: '#/components/schemas/GenericError'
|
||||||
description: ''
|
description: ''
|
||||||
/authenticators/mobile/{id}/enrollment_callback/:
|
/authenticators/mobile/{uuid}/enrollment_callback/:
|
||||||
post:
|
post:
|
||||||
operationId: authenticators_mobile_enrollment_callback_create
|
operationId: authenticators_mobile_enrollment_callback_create
|
||||||
description: Enrollment callback
|
description: Enrollment callback
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -2197,16 +2206,17 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/GenericError'
|
$ref: '#/components/schemas/GenericError'
|
||||||
description: ''
|
description: ''
|
||||||
/authenticators/mobile/{id}/receive_response/:
|
/authenticators/mobile/{uuid}/receive_response/:
|
||||||
post:
|
post:
|
||||||
operationId: authenticators_mobile_receive_response_create
|
operationId: authenticators_mobile_receive_response_create
|
||||||
description: Get response from notification on phone
|
description: Get response from notification on phone
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -2237,17 +2247,18 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/GenericError'
|
$ref: '#/components/schemas/GenericError'
|
||||||
description: ''
|
description: ''
|
||||||
/authenticators/mobile/{id}/set_notification_key/:
|
/authenticators/mobile/{uuid}/set_notification_key/:
|
||||||
post:
|
post:
|
||||||
operationId: authenticators_mobile_set_notification_key_create
|
operationId: authenticators_mobile_set_notification_key_create
|
||||||
description: Called by the phone whenever the firebase key changes and we need
|
description: Called by the phone whenever the firebase key changes and we need
|
||||||
to update it
|
to update it
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -2274,16 +2285,17 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/GenericError'
|
$ref: '#/components/schemas/GenericError'
|
||||||
description: ''
|
description: ''
|
||||||
/authenticators/mobile/{id}/used_by/:
|
/authenticators/mobile/{uuid}/used_by/:
|
||||||
get:
|
get:
|
||||||
operationId: authenticators_mobile_used_by_list
|
operationId: authenticators_mobile_used_by_list
|
||||||
description: Get a list of all objects that use this object
|
description: Get a list of all objects that use this object
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: uuid
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
description: A unique integer value identifying this Mobile Device.
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mobile Device.
|
||||||
required: true
|
required: true
|
||||||
tags:
|
tags:
|
||||||
- authenticators
|
- authenticators
|
||||||
|
@ -35194,16 +35206,15 @@ components:
|
||||||
description: Serializer for Mobile authenticator devices
|
description: Serializer for Mobile authenticator devices
|
||||||
properties:
|
properties:
|
||||||
pk:
|
pk:
|
||||||
type: integer
|
type: string
|
||||||
readOnly: true
|
format: uuid
|
||||||
title: ID
|
title: Uuid
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
description: The human-readable name of this device.
|
description: The human-readable name of this device.
|
||||||
maxLength: 64
|
maxLength: 64
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
- pk
|
|
||||||
MobileDeviceEnrollmentCallback:
|
MobileDeviceEnrollmentCallback:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -35227,6 +35238,10 @@ components:
|
||||||
type: object
|
type: object
|
||||||
description: Serializer for Mobile authenticator devices
|
description: Serializer for Mobile authenticator devices
|
||||||
properties:
|
properties:
|
||||||
|
pk:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
title: Uuid
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
minLength: 1
|
minLength: 1
|
||||||
|
@ -39072,6 +39087,10 @@ components:
|
||||||
type: object
|
type: object
|
||||||
description: Serializer for Mobile authenticator devices
|
description: Serializer for Mobile authenticator devices
|
||||||
properties:
|
properties:
|
||||||
|
pk:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
title: Uuid
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
minLength: 1
|
minLength: 1
|
||||||
|
|
Reference in a new issue