-
Notifications
You must be signed in to change notification settings - Fork 273
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
How do we disable an authentication scheme? #326
Comments
this is currently not supported |
For anyone coming through here, I had a need for this (an API with auth classes used only by internal clients and not relevant to external consumers) and hacked together a basic solution by subclassing This library has been much better than the other drf openapi tools I've used in the past...if this is functionality you'd ever consider making part of the core library I'd be happy to work up a PR with tests/docs/etc. from drf_spectacular.openapi import * # noqa
class EnumeratedAuthOnlyAutoSchema(AutoSchema):
def get_auth(self):
"""
Copy-pasted from parent class with a small change to allow enumerating the specific authentication classes we want to
expose to users rather than everything we actually have enabled in the django rest framework config.
"""
allowed_auths = set(settings.SPECTACULAR_SETTINGS.get('ALLOWED_AUTH_CLASSES', []))
auths = []
for authenticator in self.view.get_authenticators():
if f'{authenticator.__module__}.{authenticator.__class__.__name__}' not in allowed_auths:
continue
... |
this is now supported 😄 |
🎉 Thank you! |
I want to disable Session authentication scheme from schema and shown only Token Authentication
The text was updated successfully, but these errors were encountered: