Fix formatting
This commit is contained in:
parent
1fa648ecea
commit
0ee20f400c
|
@ -1,6 +1,7 @@
|
||||||
from drf_spectacular.contrib.django_oauth_toolkit import OpenApiAuthenticationExtension
|
from drf_spectacular.contrib.django_oauth_toolkit import OpenApiAuthenticationExtension
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
class CustomOAuthExt(OpenApiAuthenticationExtension):
|
class CustomOAuthExt(OpenApiAuthenticationExtension):
|
||||||
target_class = "funkwhale_api.common.authentication.OAuth2Authentication"
|
target_class = "funkwhale_api.common.authentication.OAuth2Authentication"
|
||||||
name = "oauth2"
|
name = "oauth2"
|
||||||
|
@ -26,11 +27,12 @@ class CustomOAuthExt(OpenApiAuthenticationExtension):
|
||||||
|
|
||||||
return {"type": "oauth2", "flows": flows}
|
return {"type": "oauth2", "flows": flows}
|
||||||
|
|
||||||
|
|
||||||
def custom_preprocessing_hook(endpoints):
|
def custom_preprocessing_hook(endpoints):
|
||||||
filtered = []
|
filtered = []
|
||||||
# your modifications to the list of operations that are exposed in the schema
|
# your modifications to the list of operations that are exposed in the schema
|
||||||
api_type = os.environ['API_TYPE']
|
api_type = os.environ["API_TYPE"]
|
||||||
for (path, path_regex, method, callback) in endpoints:
|
for (path, path_regex, method, callback) in endpoints:
|
||||||
if path.startswith(f"/api/{api_type}"):
|
if path.startswith(f"/api/{api_type}"):
|
||||||
filtered.append((path, path_regex, method, callback))
|
filtered.append((path, path_regex, method, callback))
|
||||||
return filtered
|
return filtered
|
||||||
|
|
|
@ -131,7 +131,7 @@ SPECTACULAR_SETTINGS = {
|
||||||
"OAUTH2_FLOWS": ["authorizationCode"],
|
"OAUTH2_FLOWS": ["authorizationCode"],
|
||||||
"OAUTH2_AUTHORIZATION_URL": "/authorize",
|
"OAUTH2_AUTHORIZATION_URL": "/authorize",
|
||||||
"OAUTH2_TOKEN_URL": "/api/v1/oauth/token/",
|
"OAUTH2_TOKEN_URL": "/api/v1/oauth/token/",
|
||||||
'PREPROCESSING_HOOKS': ["config.schema.custom_preprocessing_hook"],
|
"PREPROCESSING_HOOKS": ["config.schema.custom_preprocessing_hook"],
|
||||||
}
|
}
|
||||||
|
|
||||||
if env.bool("WEAK_PASSWORDS", default=False):
|
if env.bool("WEAK_PASSWORDS", default=False):
|
||||||
|
|
Loading…
Reference in New Issue