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

Allow multiple algorithms to be used #52

Open
akifd opened this issue Nov 6, 2018 · 0 comments
Open

Allow multiple algorithms to be used #52

akifd opened this issue Nov 6, 2018 · 0 comments

Comments

@akifd
Copy link

akifd commented Nov 6, 2018

We need to allow both RS256 and HS256 authentication. Basically we want to allow users of our API to either login with email/password to get the the token (normal users), or, they provide us their public key to verify their secret key signed JWT signature (external systems using our API). At the moment, drf simplejwt does not seem to allow this without some hacking.

Currently the Token class' __init__ does the following:

# An encoded token was provided
from .state import token_backend

# Decode token
try:
    self.payload = token_backend.decode(token, verify=verify)
 except TokenBackendError:
    raise TokenError(_('Token is invalid or expired'))

Could it instead do something like token_backend = self.get_token_backend() to fetch the backend? This way we could create tokens for different backends (with different algorithms) without having to copy paste the whole init function. This may not be the most elegant way to solve this, as it will still be bit weird to have the single ALGORITHM setting, if multiple could be used.

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