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

how to differentiate 'invalid credentials' and 'disabled users'? #494

Open
flc opened this issue Jun 29, 2017 · 2 comments
Open

how to differentiate 'invalid credentials' and 'disabled users'? #494

flc opened this issue Jun 29, 2017 · 2 comments

Comments

@flc
Copy link

flc commented Jun 29, 2017

Hi, do you have any idea how could I differeniate the case when the user provides invalid credentials and the case when the user provides valid credentials but the user is disabled (is_active is False)? They both return 'Invalid credentials given.' message (which comes from oauthlib) but it would be important to differentiate the two cases. Currently it seems that a lot of functionality need to be overriden with a lot of duplicate codes to achieve it.

I'm open to any idea in general about how to handle this properly.

@apiraino
Copy link

Hi,

same thought that I had when we moved from django-oauth2-provider (deprecated) to django-oauth-toolkit.
We use using DRF and we had to remove djangorestframework-oauth too.

The pkg djangorestframework-oauth has an authenticate_credentials mehod, that does exactly what you mention, i.e. distinguish from a "invalid/missing credentials" error from an "invalid token" error:
https://github.com/jpadilla/django-rest-framework-oauth/blob/master/rest_framework_oauth/authentication.py#L163

Our workaround is to stuff a custom class with the missing logic copying from the removed package djangoframework-oauth package and then use this class as our oauth2 auth check and token retrieval.

But this solutions smells, so I'm open to other suggestions.

IMHO django-oauth-toolkit should implement the missing logic.

Just my .2 cents

@auvipy
Copy link
Contributor

auvipy commented Oct 26, 2021

Our workaround is to stuff a custom class with the missing logic copying from the removed package djangoframework-oauth package and then use this class as our oauth2 auth check and token retrieval.

you are welcome to come with the implementation

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

3 participants