api: fix import error

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-06-13 12:59:28 +02:00
parent 31d2ea65fd
commit 572b8d87b5
3 changed files with 27 additions and 23 deletions

View file

@ -10,3 +10,26 @@ class AuthentikAPIConfig(AppConfig):
label = "authentik_api"
mountpoint = "api/"
verbose_name = "authentik API"
def ready(self) -> None:
from drf_spectacular.extensions import OpenApiAuthenticationExtension
from authentik.api.authentication import TokenAuthentication
# Class is defined here as it needs to be created early enough that drf-spectacular will
# find it, but also won't cause any import issues
# pylint: disable=unused-variable
class TokenSchema(OpenApiAuthenticationExtension):
"""Auth schema"""
target_class = TokenAuthentication
name = "authentik"
def get_security_definition(self, auto_schema):
"""Auth schema"""
return {
"type": "apiKey",
"in": "header",
"name": "Authorization",
}

View file

@ -3,7 +3,6 @@ from base64 import b64decode
from binascii import Error
from typing import Any, Optional, Union
from drf_spectacular.authentication import OpenApiAuthenticationExtension
from rest_framework.authentication import BaseAuthentication, get_authorization_header
from rest_framework.exceptions import AuthenticationFailed
from rest_framework.request import Request
@ -56,18 +55,3 @@ class TokenAuthentication(BaseAuthentication):
return None
return (token.user, None) # pragma: no cover
class TokenSchema(OpenApiAuthenticationExtension):
"""Auth schema"""
target_class = TokenAuthentication
name = "authentik"
def get_security_definition(self, auto_schema):
"""Auth schema"""
return {
"type": "apiKey",
"in": "header",
"name": "Authorization",
}

View file

@ -1,7 +1,7 @@
openapi: 3.0.3
info:
title: authentik
version: 2021.6.1-rc4
version: 2021.6.1-rc5
description: Making authentication simple.
contact:
email: hello@beryju.org
@ -2717,14 +2717,10 @@ paths:
name: is_active
schema:
type: boolean
title: Active
description: Designates whether this user should be treated as active. Unselect
this instead of deleting accounts.
- in: query
name: is_superuser
schema:
type: string
format: uuid
type: boolean
- in: query
name: name
schema:
@ -3041,7 +3037,7 @@ paths:
- in: query
name: has_key
schema:
type: string
type: boolean
description: Only return certificate-key pairs with keys
- in: query
name: name
@ -26137,6 +26133,7 @@ components:
forward_auth_mode:
type: boolean
readOnly: true
deprecated: true
required:
- external_host
- forward_auth_mode