forked from ansible/django-ansible-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More fixes from warnings in /docs/ page
- Loading branch information
1 parent
b660136
commit f853acd
Showing
4 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
from django.apps import AppConfig | ||
|
||
from ansible_base.api_documentation.customizations import apply_authentication_customizations | ||
|
||
|
||
class ApiDocumentationConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'ansible_base.api_documentation' | ||
label = 'dab_api_documentation' | ||
|
||
def ready(self): | ||
from django.conf import settings | ||
|
||
if 'ansible_base.authentication' in settings.INSTALLED_APPS: | ||
apply_authentication_customizations() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def apply_authentication_customizations() -> None: | ||
"""Make the schema generator of the type of DAB authentication classes""" | ||
from drf_spectacular.authentication import SessionScheme | ||
|
||
from ansible_base.authentication.session import SessionAuthentication | ||
|
||
class MyAuthenticationScheme(SessionScheme): | ||
target_class = SessionAuthentication # full import path OR class ref | ||
name = 'SessionAuthentication' | ||
|
||
def get_security_definition(self, auto_schema): | ||
return { | ||
'type': 'apiKey', | ||
'in': 'header', | ||
'name': 'api_key', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters