diff --git a/crates/bitwarden/src/auth/api/request/access_token_request.rs b/crates/bitwarden/src/auth/api/request/access_token_request.rs index b5035269b..9f41d6b40 100644 --- a/crates/bitwarden/src/auth/api/request/access_token_request.rs +++ b/crates/bitwarden/src/auth/api/request/access_token_request.rs @@ -13,10 +13,10 @@ pub struct AccessTokenRequest { } impl AccessTokenRequest { - pub fn new(service_account_id: Uuid, client_secret: &String) -> Self { + pub fn new(access_token_id: Uuid, client_secret: &String) -> Self { let obj = Self { scope: "api.secrets".to_string(), - client_id: service_account_id.to_string(), + client_id: access_token_id.to_string(), client_secret: client_secret.to_string(), grant_type: "client_credentials".to_string(), }; diff --git a/crates/bitwarden/src/auth/login/access_token.rs b/crates/bitwarden/src/auth/login/access_token.rs index 1ec8c8b34..8d5996119 100644 --- a/crates/bitwarden/src/auth/login/access_token.rs +++ b/crates/bitwarden/src/auth/login/access_token.rs @@ -59,7 +59,7 @@ pub(crate) async fn login_access_token( r.refresh_token.clone(), r.expires_in, LoginMethod::ServiceAccount(ServiceAccountLoginMethod::AccessToken { - service_account_id: access_token.service_account_id, + access_token_id: access_token.access_token_id, client_secret: access_token.client_secret, organization_id, }), @@ -76,7 +76,7 @@ async fn request_access_token( input: &AccessToken, ) -> Result { let config = client.get_api_configurations().await; - AccessTokenRequest::new(input.service_account_id, &input.client_secret) + AccessTokenRequest::new(input.access_token_id, &input.client_secret) .send(config) .await } diff --git a/crates/bitwarden/src/auth/renew.rs b/crates/bitwarden/src/auth/renew.rs index a8bfac51f..7973947ab 100644 --- a/crates/bitwarden/src/auth/renew.rs +++ b/crates/bitwarden/src/auth/renew.rs @@ -44,11 +44,11 @@ pub(crate) async fn renew_token(client: &mut Client) -> Result<()> { }, LoginMethod::ServiceAccount(s) => match s { ServiceAccountLoginMethod::AccessToken { - service_account_id, + access_token_id, client_secret, .. } => { - AccessTokenRequest::new(*service_account_id, client_secret) + AccessTokenRequest::new(*access_token_id, client_secret) .send(&client.__api_configurations) .await? } diff --git a/crates/bitwarden/src/client/access_token.rs b/crates/bitwarden/src/client/access_token.rs index b68d78572..db6b78f20 100644 --- a/crates/bitwarden/src/client/access_token.rs +++ b/crates/bitwarden/src/client/access_token.rs @@ -10,7 +10,7 @@ use crate::{ }; pub struct AccessToken { - pub service_account_id: Uuid, + pub access_token_id: Uuid, pub client_secret: String, pub encryption_key: SymmetricCryptoKey, } @@ -22,7 +22,7 @@ impl FromStr for AccessToken { let (first_part, encryption_key) = key.split_once(':').ok_or(AccessTokenInvalidError::NoKey)?; - let [version, service_account_id, client_secret]: [&str; 3] = first_part + let [version, access_token_id, client_secret]: [&str; 3] = first_part .split('.') .collect::>() .try_into() @@ -32,7 +32,7 @@ impl FromStr for AccessToken { return Err(AccessTokenInvalidError::WrongVersion.into()); } - let Ok(service_account_id) = service_account_id.parse() else { + let Ok(access_token_id) = access_token_id.parse() else { return Err(AccessTokenInvalidError::InvalidUuid.into()); }; @@ -49,7 +49,7 @@ impl FromStr for AccessToken { derive_shareable_key(encryption_key, "accesstoken", Some("sm-access-token")); Ok(AccessToken { - service_account_id, + access_token_id, client_secret: client_secret.to_owned(), encryption_key, }) @@ -69,7 +69,7 @@ mod tests { let token = AccessToken::from_str(access_token).unwrap(); assert_eq!( - &token.service_account_id.to_string(), + &token.access_token_id.to_string(), "ec2c1d46-6a4b-4751-a310-af9601317f2d" ); assert_eq!(token.client_secret, "C2IgxjjLF7qSshsbwe8JGcbM075YXw"); diff --git a/crates/bitwarden/src/client/client.rs b/crates/bitwarden/src/client/client.rs index 6d1503312..2b6b76a2f 100644 --- a/crates/bitwarden/src/client/client.rs +++ b/crates/bitwarden/src/client/client.rs @@ -58,7 +58,7 @@ pub(crate) enum UserLoginMethod { #[derive(Debug, Clone)] pub(crate) enum ServiceAccountLoginMethod { AccessToken { - service_account_id: Uuid, + access_token_id: Uuid, client_secret: String, organization_id: Uuid, }, diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index 6f27a0e4d..22e3b5dcd 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -272,7 +272,7 @@ async fn process_commands() -> Result<()> { profile } else if let Some(access_token) = cli.access_token { AccessToken::from_str(&access_token)? - .service_account_id + .access_token_id .to_string() } else { String::from("default") @@ -619,7 +619,7 @@ fn get_config_profile( profile.to_owned() } else { AccessToken::from_str(access_token)? - .service_account_id + .access_token_id .to_string() };