From c3a42345bcfa97d053e4bf13ef69c1d854911686 Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Mon, 1 Sep 2025 19:07:02 +0200 Subject: [PATCH] chore: Rename the v3federation to v4federation Keystone-ng moved the new auth method to the v4 (with passkeys and the jwt login). Start working on support for those new features by first moving the corresponding federation login. --- openstack_sdk/src/auth.rs | 10 +++++----- openstack_sdk/src/auth/authtoken.rs | 18 +++++++++--------- .../auth/{v3federation.rs => v4federation.rs} | 0 openstack_sdk/src/error.rs | 2 +- openstack_sdk/src/openstack_async.rs | 12 ++++++------ 5 files changed, 21 insertions(+), 21 deletions(-) rename openstack_sdk/src/auth/{v3federation.rs => v4federation.rs} (100%) diff --git a/openstack_sdk/src/auth.rs b/openstack_sdk/src/auth.rs index 59c0fb854..53b1fc2bc 100644 --- a/openstack_sdk/src/auth.rs +++ b/openstack_sdk/src/auth.rs @@ -31,20 +31,20 @@ mod auth_token_endpoint; pub mod authtoken; pub mod authtoken_scope; pub mod v3applicationcredential; -#[cfg(feature = "keystone_ng")] -pub mod v3federation; pub mod v3oidcaccesstoken; pub mod v3password; pub mod v3token; pub mod v3totp; pub mod v3websso; +#[cfg(feature = "keystone_ng")] +pub mod v4federation; use authtoken::{AuthToken, AuthTokenError}; use authtoken_scope::AuthTokenScopeError; -#[cfg(feature = "keystone_ng")] -use v3federation::FederationError; use v3oidcaccesstoken::OidcAccessTokenError; use v3websso::WebSsoError; +#[cfg(feature = "keystone_ng")] +use v4federation::FederationError; /// Authentication error #[derive(Debug, Error)] @@ -96,7 +96,7 @@ impl From for AuthError { #[cfg(feature = "keystone_ng")] impl From for AuthError { - fn from(source: v3federation::FederationError) -> Self { + fn from(source: v4federation::FederationError) -> Self { Self::AuthToken { source: source.into(), } diff --git a/openstack_sdk/src/auth/authtoken.rs b/openstack_sdk/src/auth/authtoken.rs index 18081d67b..6fa24a38f 100644 --- a/openstack_sdk/src/auth/authtoken.rs +++ b/openstack_sdk/src/auth/authtoken.rs @@ -27,7 +27,7 @@ use crate::api::identity::v3::auth::token::get as token_v3_info; use crate::api::RestEndpoint; use crate::auth::auth_token_endpoint as token_v3; #[cfg(feature = "keystone_ng")] -use crate::auth::v3federation; +use crate::auth::v4federation; use crate::auth::{ auth_helper::AuthHelper, authtoken_scope, v3applicationcredential, v3oidcaccesstoken, v3password, v3token, v3totp, v3websso, AuthState, @@ -164,7 +164,7 @@ pub enum AuthTokenError { Federation { /// The error source #[from] - source: v3federation::FederationError, + source: v4federation::FederationError, }, } @@ -249,9 +249,6 @@ impl AuthToken { pub enum AuthType { /// v3 Application Credentials V3ApplicationCredential, - #[cfg(feature = "keystone_ng")] - /// Federation - V3Federation, /// OIDC Access token V3OidcAccessToken, /// v3 Password @@ -264,6 +261,9 @@ pub enum AuthType { V3Multifactor, /// WebSSO V3WebSso, + /// Federation + #[cfg(feature = "keystone_ng")] + V4Federation, } impl FromStr for AuthType { @@ -275,13 +275,13 @@ impl FromStr for AuthType { Ok(Self::V3ApplicationCredential) } "v3password" | "password" => Ok(Self::V3Password), - #[cfg(feature = "keystone_ng")] - "v3federation" | "federation" => Ok(Self::V3Federation), "v3oidcaccesstoken" | "accesstoken" => Ok(Self::V3OidcAccessToken), "v3token" | "token" => Ok(Self::V3Token), "v3totp" => Ok(Self::V3Totp), "v3multifactor" => Ok(Self::V3Multifactor), "v3websso" => Ok(Self::V3WebSso), + #[cfg(feature = "keystone_ng")] + "v4federation" | "federation" => Ok(Self::V4Federation), other => Err(Self::Err::IdentityMethod { auth_type: other.into(), }), @@ -304,13 +304,13 @@ impl AuthType { match self { Self::V3ApplicationCredential => "v3applicationcredential", Self::V3Password => "v3password", - #[cfg(feature = "keystone_ng")] - Self::V3Federation => "v3federation", Self::V3OidcAccessToken => "v3oidcaccesstoken", Self::V3Token => "v3token", Self::V3Multifactor => "v3multifactor", Self::V3Totp => "v3totp", Self::V3WebSso => "v3websso", + #[cfg(feature = "keystone_ng")] + Self::V4Federation => "v4federation", } } } diff --git a/openstack_sdk/src/auth/v3federation.rs b/openstack_sdk/src/auth/v4federation.rs similarity index 100% rename from openstack_sdk/src/auth/v3federation.rs rename to openstack_sdk/src/auth/v4federation.rs diff --git a/openstack_sdk/src/error.rs b/openstack_sdk/src/error.rs index 673657787..4dee8aa85 100644 --- a/openstack_sdk/src/error.rs +++ b/openstack_sdk/src/error.rs @@ -19,7 +19,7 @@ use thiserror::Error; use crate::api; #[cfg(feature = "keystone_ng")] -use crate::auth::v3federation::FederationError; +use crate::auth::v4federation::FederationError; use crate::auth::{ authtoken::AuthTokenError, authtoken_scope::AuthTokenScopeError, v3oidcaccesstoken::OidcAccessTokenError, v3websso::WebSsoError, AuthError, diff --git a/openstack_sdk/src/openstack_async.rs b/openstack_sdk/src/openstack_async.rs index 80ba62ceb..7594dc092 100644 --- a/openstack_sdk/src/openstack_async.rs +++ b/openstack_sdk/src/openstack_async.rs @@ -460,7 +460,7 @@ impl AsyncOpenStack { } #[cfg(feature = "keystone_ng")] - AuthType::V3Federation => { + AuthType::V4Federation => { // Construct request for initializing authentication (POST call to keystone // `/federation/identity_providers/{idp_id}/auth`) to get the IDP url // client would need to contact. @@ -468,26 +468,26 @@ impl AsyncOpenStack { // saving 1 call. let callback_addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8050)); let init_auth_ep = - auth::v3federation::get_auth_ep(&self.config, callback_addr.port())?; - let auth_info: auth::v3federation::FederationAuthRequestResponse = + auth::v4federation::get_auth_ep(&self.config, callback_addr.port())?; + let auth_info: auth::v4federation::FederationAuthRequestResponse = init_auth_ep.query_async(self).await?; // Perform the magic directing user's browser at the IDP url and waiting // for the callback to be invoked with the authorization code let oauth2_code = - auth::v3federation::get_auth_code(&auth_info.auth_url, callback_addr) + auth::v4federation::get_auth_code(&auth_info.auth_url, callback_addr) .await?; // Construct the request to Keystone to finish the authorization exchanging // received authorization code for the (unscoped) token let mut oidc_callback_builder = - auth::v3federation::OauthCallbackRequestBuilder::default(); + auth::v4federation::OauthCallbackRequestBuilder::default(); if let (Some(code), Some(state)) = (oauth2_code.code, oauth2_code.state) { oidc_callback_builder.code(code.clone()); oidc_callback_builder.state(state.clone()); let oidc_callback_ep = oidc_callback_builder .build() - .map_err(auth::v3federation::FederationError::from)?; + .map_err(auth::v4federation::FederationError::from)?; rsp = oidc_callback_ep.raw_query_async(self).await?; } else {