question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom claims not in scope

See original GitHub issue

Question 💬

I am using a custom provider like so:

{
      id: "svipe",
      name: "Svipe",
      type: "oauth",
      version: "2.0",
      scope: "openid profile",
      idToken: true,
      params: { grant_type: "authorization_code" },
      accessTokenUrl: "https://api.svipe.com/oidc/v1/token",
      requestTokenUrl: "https://api.svipe.com/oidc/v1/authorize",
      authorizationUrl: "https://api.svipe.com/oidc/v1/authorize?response_type=code",
      profileUrl: "https://api.svipe.com/oidc/v1/userinfo",
      async profile(profile, tokens) {
        return {
          id: profile.svipeid,
          name: profile.name,
          email: profile.email
        }
      },
      clientId: process.env.SVIPE_ID,
      clientSecret: process.env.SVIPE_SECRET
    },

This is an OIDC provider and the configuration is here

Now, this provider has support for the common OIDC claims but also many custom such as passport document_number and such. How do I request this? Using passport and the openid-client strategy I would do this:

   var params = {
    claims: {
      device_token: {essential: true},
      issuing_country: {essential: true},
      document_number: {essential: true},
      birthdate: {essential: true},
      person_number: {essential: true},
      email: false,
      phone: false,
      given_name: {essential: true},
      family_name: {essential: true},
      portrait: {essential: true},
      pkpass: req.session.pkpass
     }
    };

    passport.use(
      'oidc',
      new Strategy({ client, params }, (tokenSet, userinfo, done) => {
        var claims = tokenSet.claims();
        claims.id_token = tokenSet.id_token;
        return done(null, claims);
      })
    );

How can I do the same with NextAuth?

How to reproduce ☕️

Nothing to reproduce, this is a “how to” question.

Contributing 🙌🏽

Yes, I am willing to help answer this question in a PR

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
advatarcommented, Aug 15, 2021

Cool. I actually solved it temporarily like this:

authorizationUrl: "https://api.svipe.com/oidc/v1/authorize?response_type=code&claims="+encodeURIComponent(JSON.stringify({
        device_token: {essential: true},
        issuing_country: {essential: true},
        document_number: {essential: true},
        birthdate: {essential: true},
        person_number: {essential: true},
        email: false,
        phone: false,
        given_name: {essential: true},
        family_name: {essential: true},
        portrait: {essential: true}
       })),
0reactions
balazsorban44commented, Aug 16, 2021

Awesome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom claims are not added in the token
I have written a rule to add a custom claim when retrieving the access token. The rule gets the claims from an external...
Read more >
Custom Claims not present in access_token - Questions
Hi I am following this article in terms of creating a custom claim and getting that value back in the access_token.
Read more >
c# - Custom claim not accessible in ...
by default custom claims will not be included in the User, instead you need to manually map the incoming claims that you care...
Read more >
Control Access with Custom Claims and Security Rules
Best practices for custom claims​​ Custom claims are only used to provide access control. They are not designed to store additional data (such...
Read more >
What Are Scopes and Claims? A Short Overview
In the Curity Identity Server every claim the Server can issue will belong to a scope, but you can have scopes which do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found