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

Is it possible for a claim to have multiple scopes? #125

Open
davidbasalla opened this issue Sep 11, 2020 · 1 comment
Open

Is it possible for a claim to have multiple scopes? #125

davidbasalla opened this issue Sep 11, 2020 · 1 comment

Comments

@davidbasalla
Copy link
Contributor

davidbasalla commented Sep 11, 2020

I would like to provide an all_data scope that acts as a summary of more focused scopes (eg profile and email), like so:

  claims do
    # Profile scope
    claim :given_name, scope: :profile do |user, scopes, access_token|
      user.first_name
    end

    # Email scope
    claim :email, scope: :email do |user, scopes, access_token|
     user.email
    end
  
    # All data scope
    claim :given_name, scope: :all_data do |user, scopes, access_token|
      user.first_name
    end
    claim :email, scope: :all_data do |user, scopes, access_token|
     user.email
    end
  end

From my testing, this currently breaks scope requests for just profile or email, because the claims OpenStruct (from ClaimsBuilder) uses the claim symbols as keys, thereby overwriting duplicate claim definitions and only storing the claims under the all_data scope.

I also can't find in the OIDC spec whether it should be possible to have claims assigned to multiple scopes - does anyone know?

@toupeira
Copy link
Member

@davidbasalla sorry for the late response!

I don't think this is currently possible, maybe one solution could be to let the scope: argument support arrays, so you'd have scope: [:profile, :all_data] etc.?

At

if access_token.scopes.exists?(claim.scope) && claim.response.include?(response)
we could then check if any of the defined scopes are present in the access token.

PRs welcome, unfortunately I don't have time to look into this myself 🙂

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

No branches or pull requests

2 participants