Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions openstack_sdk/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -96,7 +96,7 @@ impl From<WebSsoError> for AuthError {

#[cfg(feature = "keystone_ng")]
impl From<FederationError> for AuthError {
fn from(source: v3federation::FederationError) -> Self {
fn from(source: v4federation::FederationError) -> Self {
Self::AuthToken {
source: source.into(),
}
Expand Down
18 changes: 9 additions & 9 deletions openstack_sdk/src/auth/authtoken.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -164,7 +164,7 @@ pub enum AuthTokenError {
Federation {
/// The error source
#[from]
source: v3federation::FederationError,
source: v4federation::FederationError,
},
}

Expand Down Expand Up @@ -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
Expand All @@ -264,6 +261,9 @@ pub enum AuthType {
V3Multifactor,
/// WebSSO
V3WebSso,
/// Federation
#[cfg(feature = "keystone_ng")]
V4Federation,
}

impl FromStr for AuthType {
Expand All @@ -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(),
}),
Expand All @@ -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",
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion openstack_sdk/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions openstack_sdk/src/openstack_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,34 +460,34 @@ 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.
// TODO: If we know the scope we can request it from the very beginning
// 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 {
Expand Down