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 have different read/write scope for a View? #595

Closed
prafulbagai opened this issue May 11, 2018 · 1 comment
Closed

How to have different read/write scope for a View? #595

prafulbagai opened this issue May 11, 2018 · 1 comment
Labels

Comments

@prafulbagai
Copy link

I'm using DRF and OAuthToolkit. Here is my view:-

class UserDetailView(RetrieveUpdateDestroyAPIView):
    serializer_class = UserUpdateSerializer
    permission_classes = [TokenHasResourceScope]
    required_scopes = ['user_detail']

Now, the above view will support GET, PUT, PATCH, and DELETE methods. Now, if I create a token with a scope as user_detail, it will give access to all the methods. However, I want different read/write scopes for SAFE and UNSAFE methods.

Upon reading OAuthToolkit code for TokenHasResourceScope, it create scopes for SAFE and UNSAFE methods, ie user_detail:read and user_detail:write.

Now, if the client request for user_detail:read scope, the library returns invalid scope.

How do I support scopes for read and write of a particular view differently?

@AraujoBravo
Copy link

I'm using DRF and OAuthToolkit. Here is my view:-

class UserDetailView(RetrieveUpdateDestroyAPIView):
    serializer_class = UserUpdateSerializer
    permission_classes = [TokenHasResourceScope]
    required_scopes = ['user_detail']

Now, the above view will support GET, PUT, PATCH, and DELETE methods. Now, if I create a token with a scope as user_detail, it will give access to all the methods. However, I want different read/write scopes for SAFE and UNSAFE methods.

Upon reading OAuthToolkit code for TokenHasResourceScope, it create scopes for SAFE and UNSAFE methods, ie user_detail:read and user_detail:write.

Now, if the client request for user_detail:read scope, the library returns invalid scope.

How do I support scopes for read and write of a particular view differently?

Here it specifies the solution:
#410

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

No branches or pull requests

4 participants