Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The scope parameter has been mistakenly required on device access token request #1411

Open
Tracked by #1750
hafezdivandari opened this issue May 22, 2024 · 2 comments · May be fixed by #1412
Open
Tracked by #1750

The scope parameter has been mistakenly required on device access token request #1411

hafezdivandari opened this issue May 22, 2024 · 2 comments · May be fixed by #1412

Comments

@hafezdivandari
Copy link

hafezdivandari commented May 22, 2024

On device authorization flow, according to RFC8628, the "Device Access Token Request" should send these parameters:

  • grant_type
  • device_code
  • client_id

As you can see there is no scope parameter, because the scope parameter had been sent on the first step "Device Authorization Request":

  • client_id
  • scope

The scopes are requested by the client on the first request and should be persisted on the DB. When user enters the user code we display the client info and list of scopes to be approved by user. So the client shouldn't specify scopes on the last request, but the current implementation requires scopes on DeviceCodeGrant::respondToAccessTokenRequest() mistakenly:

$scopes = $this->validateScopes($this->getRequestParameter('scope', $request, $this->defaultScope));
$deviceCodeEntity = $this->validateDeviceCode($request, $client);

I think you should get the scopes from $deviceCodeEntity instead, which was persisted on the DB.

-$scopes = $this->validateScopes($this->getRequestParameter('scope', $request, $this->defaultScope));
$deviceCodeEntity = $this->validateDeviceCode($request, $client);
+$scopes = $deviceCodeEntity->getScopes(); // no need to call `validateScope` because already done on `respondToDeviceAuthorizationRequest` before persisting to DB

Am I missing something?

@hafezdivandari hafezdivandari linked a pull request May 23, 2024 that will close this issue
@hafezdivandari
Copy link
Author

@Sephster would you please take a look? it seems to be a bug.

@Sephster
Copy link
Member

Does indeed look to be a bug. Thanks for spotting this. I'm tied up the next few days but will get to this early next week. Cheers @hafezdivandari

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants