spring-projects / spring-projects/spring-security

OAuth2 Device Code Flow requires to be used with a requested scope

Open
#19,238 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

I use the OAuth2 Authorization Server (V. 4.0.6) with an OAuth Client which supports the AuthorizationGrantType "urn:ietf:params:oauth:grant-type:device_code". When I request a device authorization via a POST request to "/oauth2/device_authorization" without any scope and later giving the consent on the "DefaultConsentPage" to the device an error is thrown.

I think the problem is located in 'OAuth2DeviceAuthorizationConsentAuthenticationProvider' line 182 following. In case the list of authorities is empty an error will be thrown. The message of that error is also some kind of misleading because the property "client_id" is mentioned missing. Should be "scope" instead.

To Reproduce

  • Start the Application from the example
  • Execute a device authorization request without any scope
  • Open Browser and browse to URL given in the property "verification_uri_complete" of the previous authorization request.
  • Login (test/test)
  • Click "Submit Consent"

Expected behavior
Because the scope parameter in the initial device authorization request is optional I expect that i can give the consent if there was no requested scope.

Sample
Example Project: https://github.com/cwiejack/spring-authorizationserver-device-code-bug
see exampleRequests.http

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with OAuth2DeviceAuthorizationConsentAuthenticationProvider around line 182 and reproduce the flow using the linked example project's exampleRequests.http. Check the no-scope device authorization path and the consent submission from DefaultConsentPage. Done means consent succeeds when the initial request has no scope, and any related validation message identifies scope rather than client_id.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
authentication, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.