From: Thomas Skinner <thomas@atskinner.net>
To: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
Cc: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH openid 1/1] fix #4411: openid: add library code for openid groups support
Date: Tue, 17 Dec 2024 19:36:43 -0600 [thread overview]
Message-ID: <CALn9RMcS=Kko=X9GPCtC_mVzFvvwp8xSKh9Kx-AG3qp0xbjDMg@mail.gmail.com> (raw)
In-Reply-To: <1731501469.ghld71gk9w.astroid@yuna.none>
On Wed, Nov 13, 2024 at 6:46 AM Fabian Grünbichler
<f.gruenbichler@proxmox.com> wrote:
>
> this change actually does a lot more, right? it returns *all* claims,
> and also doesn't do anything groups specific at all, so the patch
> subject is not quite correct..
That's correct. I will update the commit message appropriately. It's
critical to return all of the claims so that the user can specify an
arbitrary claim name in the UI since a claim is not standardized
across IdPs for group names. This also allows Proxmox to be more
flexible in the future when supporting OIDC capabilities.
> I haven't tested this yet, but since all it does is allow arbitrary
> values instead of just empty ones, it should be fine. definitely would
> require some testing with different IdP implementations to ensure no
> regressions..
This change allows the ID token to contain more than just the core
claims prescribed in the openid CoreClaims struct. More importantly,
it allows any claims fields in the ID token to come through. I believe
this is not a breaking change because this is not removing any claims
from the ID token and any values that would have been passed through
OIDC would already be in some serializable format.
> On September 1, 2024 6:55 pm, Thomas Skinner wrote:
> > Signed-off-by: Thomas Skinner <thomas@atskinner.net>
> > ---
> > proxmox-openid/src/lib.rs | 55 +++++++++++++++++++++++++++++++++------
> > 1 file changed, 47 insertions(+), 8 deletions(-)
> >
> > diff --git a/proxmox-openid/src/lib.rs b/proxmox-openid/src/lib.rs
> > index fe65fded..bf8c650b 100644
> > --- a/proxmox-openid/src/lib.rs
> > +++ b/proxmox-openid/src/lib.rs
> > @@ -15,8 +15,11 @@ pub use auth_state::*;
> > use openidconnect::{
> > //curl::http_client,
> > core::{
> > - CoreAuthDisplay, CoreAuthPrompt, CoreAuthenticationFlow, CoreClient, CoreGenderClaim,
> > - CoreIdTokenClaims, CoreIdTokenVerifier, CoreProviderMetadata,
> > + CoreAuthDisplay, CoreAuthPrompt, CoreAuthenticationFlow, CoreErrorResponseType,
> > + CoreGenderClaim, CoreIdTokenVerifier, CoreJsonWebKey, CoreJsonWebKeyType,
> > + CoreJsonWebKeyUse, CoreJweContentEncryptionAlgorithm, CoreJwsSigningAlgorithm,
> > + CoreProviderMetadata, CoreRevocableToken, CoreRevocationErrorResponse,
> > + CoreTokenIntrospectionResponse, CoreTokenType,
> > },
> > AdditionalClaims,
> > AuthenticationContextClass,
> > @@ -24,6 +27,9 @@ use openidconnect::{
> > ClientId,
> > ClientSecret,
> > CsrfToken,
> > + EmptyExtraTokenFields,
> > + IdTokenClaims,
> > + IdTokenFields,
> > IssuerUrl,
> > Nonce,
> > OAuth2TokenResponse,
> > @@ -31,15 +37,47 @@ use openidconnect::{
> > PkceCodeVerifier,
> > RedirectUrl,
> > Scope,
> > + StandardErrorResponse,
> > + StandardTokenResponse,
> > UserInfoClaims,
> > };
> >
> > /// Stores Additional Claims into a serde_json::Value;
> > -#[derive(Debug, Deserialize, Serialize)]
> > +#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
> > pub struct GenericClaims(Value);
> > impl AdditionalClaims for GenericClaims {}
> >
> > pub type GenericUserInfoClaims = UserInfoClaims<GenericClaims, CoreGenderClaim>;
> > +pub type GenericIdTokenClaims = IdTokenClaims<GenericClaims, CoreGenderClaim>;
> > +
> > +pub type GenericIdTokenFields = IdTokenFields<
> > + GenericClaims,
> > + EmptyExtraTokenFields,
> > + CoreGenderClaim,
> > + CoreJweContentEncryptionAlgorithm,
> > + CoreJwsSigningAlgorithm,
> > + CoreJsonWebKeyType,
> > +>;
> > +
> > +pub type GenericTokenResponse = StandardTokenResponse<GenericIdTokenFields, CoreTokenType>;
> > +
> > +pub type GenericClient = openidconnect::Client<
> > + GenericClaims,
> > + CoreAuthDisplay,
> > + CoreGenderClaim,
> > + CoreJweContentEncryptionAlgorithm,
> > + CoreJwsSigningAlgorithm,
> > + CoreJsonWebKeyType,
> > + CoreJsonWebKeyUse,
> > + CoreJsonWebKey,
> > + CoreAuthPrompt,
> > + StandardErrorResponse<CoreErrorResponseType>,
> > + GenericTokenResponse,
> > + CoreTokenType,
> > + CoreTokenIntrospectionResponse,
> > + CoreRevocableToken,
> > + CoreRevocationErrorResponse,
> > +>;
> >
> > #[derive(Debug, Deserialize, Serialize, Clone)]
> > pub struct OpenIdConfig {
> > @@ -56,7 +94,7 @@ pub struct OpenIdConfig {
> > }
> >
> > pub struct OpenIdAuthenticator {
> > - client: CoreClient,
> > + client: GenericClient,
> > config: OpenIdConfig,
> > }
> >
> > @@ -120,8 +158,9 @@ impl OpenIdAuthenticator {
> >
> > let provider_metadata = CoreProviderMetadata::discover(&issuer_url, http_client)?;
> >
> > - let client = CoreClient::from_provider_metadata(provider_metadata, client_id, client_key)
> > - .set_redirect_uri(RedirectUrl::new(String::from(redirect_url))?);
> > + let client =
> > + GenericClient::from_provider_metadata(provider_metadata, client_id, client_key)
> > + .set_redirect_uri(RedirectUrl::new(String::from(redirect_url))?);
> >
> > Ok(Self {
> > client,
> > @@ -195,7 +234,7 @@ impl OpenIdAuthenticator {
> > &self,
> > code: &str,
> > private_auth_state: &PrivateAuthState,
> > - ) -> Result<(CoreIdTokenClaims, GenericUserInfoClaims), Error> {
> > + ) -> Result<(GenericIdTokenClaims, GenericUserInfoClaims), Error> {
> > let code = AuthorizationCode::new(code.to_string());
> > // Exchange the code with a token.
> > let token_response = self
> > @@ -206,7 +245,7 @@ impl OpenIdAuthenticator {
> > .map_err(|err| format_err!("Failed to contact token endpoint: {}", err))?;
> >
> > let id_token_verifier: CoreIdTokenVerifier = self.client.id_token_verifier();
> > - let id_token_claims: &CoreIdTokenClaims = token_response
> > + let id_token_claims: &GenericIdTokenClaims = token_response
> > .extra_fields()
> > .id_token()
> > .expect("Server did not return an ID token")
> > --
> > 2.39.2
> >
> >
> > _______________________________________________
> > pve-devel mailing list
> > pve-devel@lists.proxmox.com
> > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> >
> >
> >
>
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2024-12-18 1:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-01 16:55 [pve-devel] [PATCH SERIES openid/access-control/docs/manager] fix #4411: add support for openid groups Thomas Skinner
2024-09-01 16:55 ` [pve-devel] [PATCH docs 1/1] fix #4411: openid: add docs for openid groups support Thomas Skinner
2024-09-01 16:55 ` [pve-devel] [PATCH openid 1/1] fix #4411: openid: add library code " Thomas Skinner
2024-11-13 12:46 ` Fabian Grünbichler
2024-12-18 1:36 ` Thomas Skinner [this message]
2024-09-01 16:55 ` [pve-devel] [PATCH access-control 1/1] fix #4411: openid: add logic " Thomas Skinner
2024-11-13 12:46 ` Fabian Grünbichler
2024-12-18 2:23 ` Thomas Skinner
2024-11-13 12:47 ` Fabian Grünbichler
2024-09-01 16:55 ` [pve-devel] [PATCH manager 1/1] fix #4411: openid: add ui config " Thomas Skinner
2024-10-03 1:45 ` [pve-devel] [PATCH SERIES openid/access-control/docs/manager] fix #4411: add support for openid groups Thomas Skinner
2024-10-06 17:27 ` DERUMIER, Alexandre via pve-devel
2024-11-13 14:08 ` Mira Limbeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALn9RMcS=Kko=X9GPCtC_mVzFvvwp8xSKh9Kx-AG3qp0xbjDMg@mail.gmail.com' \
--to=thomas@atskinner.net \
--cc=f.gruenbichler@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox