Skip to content

Commit d71e227

Browse files
committed
Update request body validator
A public device code grant doesn't have a client_secret to check
1 parent 9a5bf82 commit d71e227

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

oauth2_provider/oauth2_validators.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
AbstractApplication.GRANT_CLIENT_CREDENTIALS,
5757
AbstractApplication.GRANT_OPENID_HYBRID,
5858
),
59-
"urn:ietf:params:oauth:grant-type:device_code": (AbstractApplication.GRANT_DEVICE_CODE,)
59+
"urn:ietf:params:oauth:grant-type:device_code": (AbstractApplication.GRANT_DEVICE_CODE,),
6060
}
6161

6262
Application = get_application_model()
@@ -167,8 +167,9 @@ def _authenticate_basic_auth(self, request):
167167
elif request.client.client_id != client_id:
168168
log.debug("Failed basic auth: wrong client id %s" % client_id)
169169
return False
170-
elif (request.client.client_type == "public"
171-
and request.grant_type == "urn:ietf:params:oauth:grant-type:device_code"
170+
elif (
171+
request.client.client_type == "public"
172+
and request.grant_type == "urn:ietf:params:oauth:grant-type:device_code"
172173
):
173174
return True
174175
elif not self._check_secret(client_secret, request.client.client_secret):
@@ -196,6 +197,11 @@ def _authenticate_request_body(self, request):
196197
if self._load_application(client_id, request) is None:
197198
log.debug("Failed body auth: Application %s does not exists" % client_id)
198199
return False
200+
elif (
201+
request.client.client_type == "public"
202+
and request.grant_type == "urn:ietf:params:oauth:grant-type:device_code"
203+
):
204+
return True
199205
elif not self._check_secret(client_secret, request.client.client_secret):
200206
log.debug("Failed body auth: wrong client secret %s" % client_secret)
201207
return False

0 commit comments

Comments
 (0)