ramosbugs / openidconnect-rs

OpenID Connect Library for Rust
MIT License
404 stars 100 forks source link

How to request non-standard claims for id_token #162

Open jgiacomoni opened 5 months ago

jgiacomoni commented 5 months ago

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!

ramosbugs commented 5 months ago

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.

jgiacomoni commented 5 months ago

@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.