Add authentication serializer for Bearer token auth
This commit is contained in:
parent
2746d8750d
commit
fc3fa79e9f
|
@ -1,4 +1,5 @@
|
|||
from drf_spectacular.contrib.django_oauth_toolkit import OpenApiAuthenticationExtension
|
||||
from drf_spectacular.plumbing import build_bearer_security_scheme_object
|
||||
import os
|
||||
|
||||
|
||||
|
@ -28,6 +29,17 @@ class CustomOAuthExt(OpenApiAuthenticationExtension):
|
|||
return {"type": "oauth2", "flows": flows}
|
||||
|
||||
|
||||
class CustomApplicationTokenExt(OpenApiAuthenticationExtension):
|
||||
target_class = "funkwhale_api.common.authentication.ApplicationTokenAuthentication"
|
||||
name = "ApplicationToken"
|
||||
|
||||
def get_security_definition(self, auto_schema):
|
||||
return build_bearer_security_scheme_object(
|
||||
header_name='Authorization',
|
||||
token_prefix='Bearer',
|
||||
)
|
||||
|
||||
|
||||
def custom_preprocessing_hook(endpoints):
|
||||
filtered = []
|
||||
# your modifications to the list of operations that are exposed in the schema
|
||||
|
|
Loading…
Reference in New Issue