api: fix import error
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
31d2ea65fd
commit
572b8d87b5
|
@ -10,3 +10,26 @@ class AuthentikAPIConfig(AppConfig):
|
||||||
label = "authentik_api"
|
label = "authentik_api"
|
||||||
mountpoint = "api/"
|
mountpoint = "api/"
|
||||||
verbose_name = "authentik 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",
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ from base64 import b64decode
|
||||||
from binascii import Error
|
from binascii import Error
|
||||||
from typing import Any, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
from drf_spectacular.authentication import OpenApiAuthenticationExtension
|
|
||||||
from rest_framework.authentication import BaseAuthentication, get_authorization_header
|
from rest_framework.authentication import BaseAuthentication, get_authorization_header
|
||||||
from rest_framework.exceptions import AuthenticationFailed
|
from rest_framework.exceptions import AuthenticationFailed
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
|
@ -56,18 +55,3 @@ class TokenAuthentication(BaseAuthentication):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return (token.user, None) # pragma: no cover
|
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",
|
|
||||||
}
|
|
||||||
|
|
11
schema.yml
11
schema.yml
|
@ -1,7 +1,7 @@
|
||||||
openapi: 3.0.3
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
title: authentik
|
title: authentik
|
||||||
version: 2021.6.1-rc4
|
version: 2021.6.1-rc5
|
||||||
description: Making authentication simple.
|
description: Making authentication simple.
|
||||||
contact:
|
contact:
|
||||||
email: hello@beryju.org
|
email: hello@beryju.org
|
||||||
|
@ -2717,14 +2717,10 @@ paths:
|
||||||
name: is_active
|
name: is_active
|
||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
title: Active
|
|
||||||
description: Designates whether this user should be treated as active. Unselect
|
|
||||||
this instead of deleting accounts.
|
|
||||||
- in: query
|
- in: query
|
||||||
name: is_superuser
|
name: is_superuser
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: boolean
|
||||||
format: uuid
|
|
||||||
- in: query
|
- in: query
|
||||||
name: name
|
name: name
|
||||||
schema:
|
schema:
|
||||||
|
@ -3041,7 +3037,7 @@ paths:
|
||||||
- in: query
|
- in: query
|
||||||
name: has_key
|
name: has_key
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: boolean
|
||||||
description: Only return certificate-key pairs with keys
|
description: Only return certificate-key pairs with keys
|
||||||
- in: query
|
- in: query
|
||||||
name: name
|
name: name
|
||||||
|
@ -26137,6 +26133,7 @@ components:
|
||||||
forward_auth_mode:
|
forward_auth_mode:
|
||||||
type: boolean
|
type: boolean
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
deprecated: true
|
||||||
required:
|
required:
|
||||||
- external_host
|
- external_host
|
||||||
- forward_auth_mode
|
- forward_auth_mode
|
||||||
|
|
Reference in New Issue