Skip to content

Commit 1dc277e

Browse files
committed
handle app specific scopes if enabled
1 parent ab58a18 commit 1dc277e

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
@@ -77,8 +77,12 @@ class AuthorizationView(BaseAuthorizationView, FormView):
7777
skip_authorization_completely = False
7878

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

0 commit comments

Comments
 (0)