def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs): request.scopes = list( set(request.scopes).union(set(get_default_scopes(client)))) return super(CustomOAuth2Validator, self).validate_scopes(client_id, scopes, client, request, *args, **kwargs)
def form_valid(self, form): client_id = form.cleaned_data.get('client_id', '') application = get_oauth2_application_model().objects.get(client_id=client_id) scopes = form.cleaned_data.get('scope', '') scopes = set(scopes.split(' ')) scopes.update(set(get_default_scopes(application))) private_scopes = application.private_scopes if private_scopes: private_scopes = set(private_scopes.split(' ')) scopes.update(private_scopes) scopes = ' '.join(list(scopes)) form.cleaned_data['scope'] = scopes return super(CustomAuthorizationView, self).form_valid(form)
def form_valid(self, form): client_id = form.cleaned_data.get('client_id', '') application = get_oauth2_application_model().objects.get( client_id=client_id) scopes = form.cleaned_data.get('scope', '') scopes = set(scopes.split(' ')) scopes.update(set(get_default_scopes(application))) private_scopes = application.private_scopes if private_scopes: private_scopes = set(private_scopes.split(' ')) scopes.update(private_scopes) scopes = ' '.join(list(scopes)) form.cleaned_data['scope'] = scopes return super(CustomAuthorizationView, self).form_valid(form)
def get_default_scopes(self, client_id, request, *args, **kwargs): application = get_object_or_404(get_oauth2_application_model(), client_id=client_id) return get_default_scopes(application)
def remove_basic_scope(zipped_scope_description, application): default_scopes = get_default_scopes(application) return [(scope, description) for scope, description in zipped_scope_description if scope not in default_scopes]
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs): request.scopes = list(set(request.scopes).union(set(get_default_scopes(client)))) return super(CustomOAuth2Validator, self).validate_scopes(client_id, scopes, client, request, *args, **kwargs)