Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
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]
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
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]