Skip to content

Commit 9447e2d

Browse files
committed
handle app specific scopes if enabled
1 parent 62e091f commit 9447e2d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

oauth2_provider/views/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,12 @@ class AuthorizationView(BaseAuthorizationView, FormView):
7878
skip_authorization_completely = False
7979

8080
def get_initial(self):
81-
# TODO: move this scopes conversion from and to string into a utils function
82-
scopes = self.oauth2_data.get('scope', self.oauth2_data.get('scopes', []))
81+
if oauth2_settings.APP_SPECIFIC_SCOPES:
82+
application = Application.objects.get(client_id=self.request.GET['client_id'])
83+
scopes = application.allowed_scopes.split(' ')
84+
else:
85+
# TODO: move this scopes conversion from and to string into a utils function
86+
scopes = self.oauth2_data.get('scope', self.oauth2_data.get('scopes', []))
8387
initial_data = {
8488
'redirect_uri': self.oauth2_data.get('redirect_uri', None),
8589
'scope': ' '.join(scopes),

0 commit comments

Comments
 (0)