Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SERVE_AUTHENTICATION seems not working #471

Closed
masb3 opened this issue Jul 29, 2021 · 2 comments
Closed

SERVE_AUTHENTICATION seems not working #471

masb3 opened this issue Jul 29, 2021 · 2 comments
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending

Comments

@masb3
Copy link

masb3 commented Jul 29, 2021

I have DRF settings with Auth classes as following:
REST_FRAMEWORK = { "DEFAULT_AUTHENTICATION_CLASSES": ( "rest_framework.authentication.TokenAuthentication", "rest_framework.authentication.BasicAuthentication", ), "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema" }

However in schema I would like to expose only TokenAuthentication. For that I add settings
SPECTACULAR_SETTINGS = { "SERVE_AUTHENTICATION": ["rest_framework.authentication.TokenAuthentication"], }
But output schema still has basicAuth and tokenAuth under securitySchemes and in all endpoints under security.
Any idea how to serve only TokenAuthentication?

@tfranzel
Copy link
Owner

tfranzel commented Jul 29, 2021

Hi,

SERVE_AUTHENTICATION only applies to the auth mechanism under which the schema is served (e.g. SpectacularApiView). it has not effect on the schema itself.

i believe your request is a duplicate of #326

given that this was now requested by several people, i think a new setting is the most appropriate solution.

@tfranzel tfranzel added enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending labels Jul 29, 2021
@masb3
Copy link
Author

masb3 commented Jul 30, 2021

Thank you @tfranzel that exactly I was looking for!

@masb3 masb3 closed this as completed Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending
Projects
None yet
Development

No branches or pull requests

2 participants