openidconnect-rs icon indicating copy to clipboard operation
openidconnect-rs copied to clipboard

How to request non-standard claims for id_token

Open jgiacomoni opened this issue 1 year ago • 2 comments

We are using pure implicit flow (id_token only) to request non-standard claims with standard and non-standard scope values.

EDIT scopes won't work for us as we need to be able to specify various attributes/value for each requested claim.

per https://openid.net/specs/openid-connect-core-1_0.html#Claims

we should be able to specify something like this in the authorization query params

{ "id_token": { "field_x": { "essential": true, "value" : "y", "condition" : "z", // non-standard }, }

If this isn't supported, are there plans to do so? or should I assume I need to manually append these claims to the authorization_url?

thanks!

jgiacomoni avatar Apr 19 '24 17:04 jgiacomoni

Hey @jgiacomoni,

This can currently be done using AuthorizationRequest::add_extra_param, where claims is the name and the serialized JSON is the value. The value will be URL-encoded automatically, so just pass in the plain JSON.

I'd be open to a PR (after some discussion about the API) for adding a higher-level interface for setting this parameter but don't plan to implement that myself in the near future.

ramosbugs avatar Apr 19 '24 20:04 ramosbugs

@ramosbugs thanks! I'll take a look. I'm currently in prototyping mode so I'll probably just follow your suggestion until I need something more robust.

jgiacomoni avatar Apr 22 '24 14:04 jgiacomoni