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

Use authenticate_header method to get header prefix #276

Open
Rasmnev opened this issue Aug 16, 2022 · 1 comment
Open

Use authenticate_header method to get header prefix #276

Rasmnev opened this issue Aug 16, 2022 · 1 comment

Comments

@Rasmnev
Copy link

Rasmnev commented Aug 16, 2022

If authenticate_header method is used in line 38 it would be easier to use multiple prefixes by just subclassing TokenAuthentication and overriding that method

for example:

class BearerAuth(TokenAuthentication):
    def authenticate_header(self, request):
        return "Bearer"

REST_FRAMEWORK = {
  ...
  "DEFAULT_AUTHENTICATION_CLASSES": (
      "knox.auth.TokenAuthentication",
      "BearerAuth",
  ),
  ...
}

REST_KNOX = {
...
"AUTH_HEADER_PREFIX": "Token",
...
}
@Rasmnev
Copy link
Author

Rasmnev commented Aug 16, 2022

Another possibility would be to add the keyword attribute to match DRF's TokenAuthentication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant