jazzband / django-oauth-toolkit

OAuth2 goodies for the Djangonauts!
https://django-oauth-toolkit.readthedocs.io
Other
3.13k stars 792 forks source link

How to prevent user to request and grant introspection scope? #1297

Closed zhuang42 closed 1 year ago

zhuang42 commented 1 year ago

As my understanding scopes are optionally passed to authorize endpoint, how to prevent an user granting some specificity scopes and the access token. It seems there is no out of box solution from DOT?

Chappie74 commented 1 year ago

For that you're going to have to create a custom view that does the token creation and prevent the user from using the /token endpoint that comes with this package. From your view you then make an internal request to the token view with the scope you would like.

Here is an example of how I did it.

image

zhuang42 commented 1 year ago

Thank you @Chappie74, it's a good idea. I am thinking to extend the application model and set a list of scopes, which the user can only grant these scopes defined by applications