Skip to content

Commit bc50e0a

Browse files
committed
check whether skip_application flag is True and bypass authorization step
1 parent 0656670 commit bc50e0a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

oauth2_provider/views/base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ def get(self, request, *args, **kwargs):
115115
kwargs['scopes_descriptions'] = [oauth2_settings.SCOPES[scope] for scope in scopes]
116116
kwargs['scopes'] = scopes
117117
# at this point we know an Application instance with such client_id exists in the database
118-
kwargs['application'] = Application.objects.get(client_id=credentials['client_id']) # TODO: cache it!
118+
application = Application.objects.get(client_id=credentials['client_id']) # TODO: cache it!
119+
kwargs['application'] = application
119120
kwargs.update(credentials)
120121
self.oauth2_data = kwargs
121122
# following two loc are here only because of https://code.djangoproject.com/ticket/17795
@@ -126,10 +127,11 @@ def get(self, request, *args, **kwargs):
126127
# a successful response depending on 'approval_prompt' url parameter
127128
require_approval = request.GET.get('approval_prompt', oauth2_settings.REQUEST_APPROVAL_PROMPT)
128129

129-
# if skip_authorization_completely is True, skip the authorization screen even
130-
# if this is the first use of the application and there was no previous authorization
131-
# useful for in-house applications-> assume an in-house applications are already approved.
132-
if self.skip_authorization_completely:
130+
# If skip_authorization field is True, skip the authorization screen even
131+
# if this is the first use of the application and there was no previous authorization.
132+
# This is useful for in-house applications-> assume an in-house applications
133+
# are already approved.
134+
if application.skip_authorization:
133135
uri, headers, body, status = self.create_authorization_response(
134136
request=self.request, scopes=" ".join(scopes),
135137
credentials=credentials, allow=True)

0 commit comments

Comments
 (0)