spring-projects / spring-projects/spring-security

@RegisteredOAuth2AuthorizedClient should support upgrading scopes

Open
#5,381 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: oauth2 type: enhancement
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Summary

A @RegisteredOAuth2AuthorizedClient should be able to have the scopes necessary to make a particular request. If the scopes are not present on the access token, it should support automatically requesting the additional scopes. This will allow a client to request the fewest possible scopes necessary without needing to provide additional code when needing to request more scopes.

For example, if a ClientRegistration has the scopes user, message, and admin associated to it a user should be able to state something like @RegisteredOAuth2AuthorizedClient(scopes = { "message" }). If the current access token associated to the registration had the user scope and not the message scope, then Spring Security would trigger the flow that would ensure the access token had user and message scopes.

We should also ensure that we can get tokens where the scopes are not additive. For example, for the scenario above we might have something like @RegisteredOAuth2AuthorizedClient(onlyScopes = { "message" }). Then an access token that is passed along would only contain the message scope and not the user scope despite the previous associated token having a user scope.

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 by tracing the @RegisteredOAuth2AuthorizedClient entry point and the existing authorized-client scope handling. Define how additive and non-additive scope requests should behave, then verify that tokens are refreshed or requested with the required scopes and that both annotation forms are covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
authorization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.