Rather than this...
class GroupViewSet(viewsets.ModelViewSet):
permission_classes = [TokenHasGroupScope]
model = Group
or this...
class GroupViewSet(viewsets.ModelViewSet):
permission_classes = [TokenHasScope('groups', 'admin')]
model = Group
I was thinking simply this...
class GroupViewSet(viewsets.ModelViewSet):
permission_classes = [TokenHasScope]
model = Group
required_scopes = ('groups', 'admin')
The permission is passed the view, so it can encapsulate all the required logic without needing a mixin, and simply use `getattr` to determine which scopes are required, if any. DjangoModelPermissions does something similar, and it's a pattern that's also used in places like the filtering classes.
Anyways, I'll be looking forward to seeing progress on Django OAuth Toolkit during the EuroPython sprints - have a great time!