Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
move fusionauth into it's own create (#1444)
Will Hutchinson5e0e69c3878e
diff --git a/.env-localdev.enc b/.env-localdev.encindex 0c12d6bc0e..4460a68283 100644--- a/.env-localdev.enc+++ b/.env-localdev.enc@@ -51,7 +51,6 @@ ENVIRONMENT=ENC[AES256_GCM,data:LDi57GYMEg==,iv:H8UJxB8k9cztvoUF6U10D0er2tM+ES45FRECENCY_TABLE_NAME=ENC[AES256_GCM,data:TyHA84CiO9OswLgL0Xw=,iv:fmKBjYzmJL9mnSrJ2yUUhD2OzqGBqpKe2XnQePLcIR4=,tag:Zisf5gAaRASjQJKx+SEJIA==,type:str]FUSIONAUTH_API_KEY_SECRET_KEY=ENC[AES256_GCM,data:QQ1aCX/xPClyjxmdB/ERt3AZuG9vPTk66xnU+/kDicyj7IdAG3WPtniQJMGGvbGIVasyDY2sRZdFFA==,iv:fuAaRLjSK7zWAjJE6SqWIdEppNlvCYdwcY30ubiaVCI=,tag:22IupxCezZbEiUw7begl5A==,type:str]FUSIONAUTH_TENANT_ID=ENC[AES256_GCM,data:JWPDfkNykNail7aB4MrgmwWa1WdW6tV9MnoyQX/+wwSvW2edkdY=,iv:qP+khm20jWNvw95ODuZU3ohYWhwJRzYp9m7Vi3k9CUw=,tag:LeBcxN9NE5C0+bfM6VNfMA==,type:str]-FUSIONAUTH_APPLICATION_ID=ENC[AES256_GCM,data:MCF+KSzGzWkb4vf5iKDOZrFD+iYdTUwjwfOAztax7IHVFBOKD+Q=,iv:MFMCiUjbiXasuJ5ZePuThEkX6Nqs5j2E1ByUdQdGzps=,tag:UDlxEH4xT9nkF9mLmh1VNQ==,type:str]FUSIONAUTH_BASE_URL=ENC[AES256_GCM,data:aM33jXYaTQUx7+S82Y8/jGjCZbz9G24QTIk/WKnZLCe1QQ==,iv:8V0K80Ib6HzAC83nUpdCvphMdQesF3PoZT2v3VJdawQ=,tag:/zxEQp5Rh38JpclzKfsmuw==,type:str]FUSIONAUTH_CLIENT_ID=ENC[AES256_GCM,data:XHc34Yg560RyJe7DO9kqsDXeK3X+4f4zQIypk6vj5DBIElSXovk=,iv:pqbtycYdlMqHAWsW0IT43xcGINStabeAqi1niLYfzrE=,tag:vvXe59xt7cM1BRK8ho47PQ==,type:str]FUSIONAUTH_CLIENT_SECRET_KEY=ENC[AES256_GCM,data:opHdp5+kQBITtzjvv0BHJvUGi201YlCqX01ftaiK,iv:lTKNW6rHZFADAebhliqOOXiiaqgsumf8z+y3sn7833k=,tag:oNVMZABwkoj1m82JTZYuUQ==,type:str]@@ -127,7 +126,7 @@ sops_kms__list_1__map_arn=arn:aws:kms:us-west-1:569036502058:key/mrk-cab29bf9480sops_kms__list_1__map_aws_profile=sops_kms__list_1__map_created_at=2026-02-03T14:46:45Zsops_kms__list_1__map_enc=AQICAHjuYcSMsjB0lKJtZ3DIAvxF8N3RNRn5KZaAN74Et6122wEgw9B5bWVjFVnU2kvvYrAsAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMjqkFO5E+NmhMEFLfAgEQgDtgSVqvR4m1awQFs/oq8iNeI/6jS3IXs7bQiUUTyQySXE6/kjPJLdYITJlXCzu7t/eXd4nMFCLcDMwYqg==-sops_lastmodified=2026-02-06T18:37:31Z-sops_mac=ENC[AES256_GCM,data:oUf6cUQNnFqhPfzwwR+5sBIPl873VnKLa1fi78h6eBTkQm7JFjqjl1ZpeXd6AvHkYfCfuOPWqzUS39Xnijv1op0cibX4qFQoJ3HVh4Qgixx7vrC+eVK+8gUyoBjdKyGxjACoi96ma0lDlyAbRlZVssFJbwlNXtB4Kg09mLhhCLo=,iv:ddrbMWELwJHiP13Rt/qjv53mx8q8oXXka+XKnB5KJfk=,tag:Y8iZCRZBdNt4cS6Wmq7QSg==,type:str]+sops_lastmodified=2026-02-10T19:00:13Z+sops_mac=ENC[AES256_GCM,data:4MU2Zh5SM3vx6YrO2mS0Orc8arHfBQrWcNtp+28N3KJguIeJrust6ZDm0TwBHnv+ZDy6/s4C8rjn/S2KZW9qj1BLerkngL7NFwAm/SvgEgdf27E91eVRnyjlXA9Sht1O3n74uNcDMtMYksqWp5TBxddnkeHR6bFi6TN2RKBk1RY=,iv:JsoNlDMFXgYNLq5u/BQo4UY02WJr6guVGEH5ijlNFpQ=,tag:ChOdsWYlQn2ZQO2Aglngjg==,type:str]sops_unencrypted_suffix=_unencryptedsops_version=3.11.0diff --git a/infra/stacks/authentication-service/index.ts b/infra/stacks/authentication-service/index.tsindex c8c33ec365..c749ed658a 100644--- a/infra/stacks/authentication-service/index.ts+++ b/infra/stacks/authentication-service/index.ts@@ -192,10 +192,6 @@ const service = new AuthenticationService('authentication-service', {name: 'FUSIONAUTH_CLIENT_SECRET_KEY',value: pulumi.interpolate`${FUSIONAUTH_CLIENT_SECRET_KEY}`,},- {- name: 'FUSIONAUTH_APPLICATION_ID',- value: pulumi.interpolate`${FUSIONAUTH_CLIENT_ID}`,- },{name: 'FUSIONAUTH_TENANT_ID',value: FUSIONAUTH_TENANT_ID,diff --git a/infra/stacks/fusionauth-instance/justfile b/infra/stacks/fusionauth-instance/justfileindex 0abd949aa9..554a30a2b5 100644--- a/infra/stacks/fusionauth-instance/justfile+++ b/infra/stacks/fusionauth-instance/justfile@@ -76,7 +76,6 @@ insert_local_fusionauth_variables:echo "#AUTO-ADDED DO NOT MODIFY" >> "$ENV_FILE"echo "FUSIONAUTH_TENANT_ID=\"${TENANT_ID}\"" >> "$ENV_FILE"echo "AUDIENCE=\"${APPLICATION_ID}\"" >> "$ENV_FILE"- echo "FUSIONAUTH_APPLICATION_ID=\"${APPLICATION_ID}\"" >> "$ENV_FILE"echo "FUSIONAUTH_CLIENT_ID=\"${APPLICATION_ID}\"" >> "$ENV_FILE"echo "FUSIONAUTH_CLIENT_SECRET_KEY=\"${CLIENT_SECRET}\"" >> "$ENV_FILE"diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lockindex 5b25f6c7ef..42461c04e7 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -510,6 +510,7 @@ dependencies = ["document_storage_service_client","doppleganger","email_validator",+ "fusionauth","futures","http-body-util","jsonwebtoken",@@ -544,7 +545,6 @@ dependencies = ["secretsmanager_client","serde","serde_json",- "serde_urlencoded","serde_utils","ses_client","sha1",@@ -3580,6 +3580,23 @@ version = "1.3.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"+[[package]]+name = "fusionauth"+version = "0.1.0"+dependencies = [+ "anyhow",+ "base64 0.22.1",+ "macro_env",+ "reqwest",+ "serde",+ "serde_json",+ "serde_urlencoded",+ "thiserror 2.0.17",+ "tokio",+ "tracing",+ "urlencoding",+]+[[package]]name = "futf"version = "0.1.5"diff --git a/rust/cloud-storage/Cargo.toml b/rust/cloud-storage/Cargo.tomlindex 1153385bf5..e0e574599c 100644--- a/rust/cloud-storage/Cargo.toml+++ b/rust/cloud-storage/Cargo.toml@@ -40,6 +40,7 @@ members = ["email_validator","entity_access","frecency",+ "fusionauth","gmail_client","integration_tests/*","lambda_client",diff --git a/rust/cloud-storage/authentication_service/Cargo.toml b/rust/cloud-storage/authentication_service/Cargo.tomlindex 2654107cb1..2acd8d372a 100644--- a/rust/cloud-storage/authentication_service/Cargo.toml+++ b/rust/cloud-storage/authentication_service/Cargo.toml@@ -13,10 +13,6 @@ path = "src/main.rs"name = "generate_keys"path = "src/bin/generate_keys.rs"-[[bin]]-name = "backfill_null_macro_user_id"-path = "src/bin/backfill_null_macro_user_id.rs"-[[bin]]name = "authentication_service_openapi"path = "src/openapi.rs"@@ -45,6 +41,7 @@ cookie = { workspace = true }document_storage_service_client = { path = "../document_storage_service_client" }doppleganger = { workspace = true }email_validator = { path = "../email_validator" }+fusionauth = { path = "../fusionauth" }futures = { workspace = true }http-body-util = { workspace = true }jsonwebtoken = { workspace = true }@@ -91,7 +88,6 @@ rsa = "0.9.10"secretsmanager_client = { path = "../secretsmanager_client" }serde = { workspace = true }serde_json = { workspace = true }-serde_urlencoded = "0.7.1"serde_utils = { path = "../serde_utils", features = ["urlencode"] }ses_client = { path = "../ses_client" }sha1 = "0.10.6"diff --git a/rust/cloud-storage/authentication_service/examples/fetch_and_checksum.rs b/rust/cloud-storage/authentication_service/examples/fetch_and_checksum.rsdeleted file mode 100644index ee9b4016e7..0000000000--- a/rust/cloud-storage/authentication_service/examples/fetch_and_checksum.rs+++ /dev/null@@ -1,21 +0,0 @@-use authentication_service::fetch_and_checksum::fetch_and_checksum;-use std::env;-#[tokio::main]-async fn main() -> anyhow::Result<()> {- let args: Vec<String> = env::args().collect();-- if args.len() < 2 {- println!("Supply a URL");- return Ok(());- }-- let url: &str = &args[1];-- dbg!(url);-- let checksum = fetch_and_checksum(url).await?;-- println!("{}", checksum);-- Ok(())-}diff --git a/rust/cloud-storage/authentication_service/src/api/context.rs b/rust/cloud-storage/authentication_service/src/api/context.rsindex cc094f77b3..3914214889 100644--- a/rust/cloud-storage/authentication_service/src/api/context.rs+++ b/rust/cloud-storage/authentication_service/src/api/context.rs@@ -22,7 +22,7 @@ use teams::{#[derive(Clone, FromRef)]pub(crate) struct ApiContext {pub db: PgPool,- pub auth_client: Arc<authentication_service::service::fusionauth_client::FusionAuthClient>,+ pub auth_client: Arc<fusionauth::FusionAuthClient>,pub macro_cache_client: Arc<MacroCache>,pub stripe_client: Arc<stripe::Client>,pub document_storage_service_client:diff --git a/rust/cloud-storage/authentication_service/src/api/internal/google_access_token.rs b/rust/cloud-storage/authentication_service/src/api/internal/google_access_token.rsindex bd9a41efde..d4f248d1fc 100644--- a/rust/cloud-storage/authentication_service/src/api/internal/google_access_token.rs+++ b/rust/cloud-storage/authentication_service/src/api/internal/google_access_token.rs@@ -1,11 +1,11 @@-use authentication_service::service::fusionauth_client::FusionAuthClient;-use authentication_service::service::fusionauth_client::error::FusionAuthClientError;use axum::{Json,extract::{self, State},http::StatusCode,response::{IntoResponse, Response},};+use fusionauth::FusionAuthClient;+use fusionauth::error::FusionAuthClientError;use macro_middleware::auth::internal_access::ValidInternalKey;use model::authentication::google_token::GoogleAccessToken;use model::response::ErrorResponse;diff --git a/rust/cloud-storage/authentication_service/src/api/internal/remove_link.rs b/rust/cloud-storage/authentication_service/src/api/internal/remove_link.rsindex 90f2ebfe2d..e40df04585 100644--- a/rust/cloud-storage/authentication_service/src/api/internal/remove_link.rs+++ b/rust/cloud-storage/authentication_service/src/api/internal/remove_link.rs@@ -1,5 +1,5 @@use crate::api::context::ApiContext;-use authentication_service::service::fusionauth_client::error::FusionAuthClientError;+use fusionauth::error::FusionAuthClientError;use axum::{Json,diff --git a/rust/cloud-storage/authentication_service/src/api/jwt/refresh.rs b/rust/cloud-storage/authentication_service/src/api/jwt/refresh.rsindex acb20f0a2e..c4429f642d 100644--- a/rust/cloud-storage/authentication_service/src/api/jwt/refresh.rs+++ b/rust/cloud-storage/authentication_service/src/api/jwt/refresh.rs@@ -2,15 +2,13 @@ use crate::api::{context::TokenContext,utils::{create_access_token_cookie, create_refresh_token_cookie},};-use authentication_service::service::fusionauth_client::{- FusionAuthClient, error::FusionAuthClientError,-};use axum::{Extension, Json,extract::State,http::StatusCode,response::{IntoResponse, Response},};+use fusionauth::{FusionAuthClient, error::FusionAuthClientError};use macro_auth::{error::MacroAuthError, middleware::decode_jwt::JwtValidationArgs};use model::response::UserTokensResponse;use std::sync::Arc;diff --git a/rust/cloud-storage/authentication_service/src/api/login/password.rs b/rust/cloud-storage/authentication_service/src/api/login/password.rsindex e4781bf6aa..315173a776 100644--- a/rust/cloud-storage/authentication_service/src/api/login/password.rs+++ b/rust/cloud-storage/authentication_service/src/api/login/password.rs@@ -2,13 +2,13 @@ use crate::api::{context::ApiContext,utils::{create_access_token_cookie, create_refresh_token_cookie},};-use authentication_service::service::fusionauth_client::error::FusionAuthClientError;use axum::{Extension, Json,extract::{self, State},http::StatusCode,response::{IntoResponse, Response},};+use fusionauth::error::FusionAuthClientError;use model::{authentication::login::request::PasswordRequest,response::{ErrorResponse, UserTokensResponse},diff --git a/rust/cloud-storage/authentication_service/src/api/login/passwordless.rs b/rust/cloud-storage/authentication_service/src/api/login/passwordless.rsindex d46f2856aa..ba4254a581 100644--- a/rust/cloud-storage/authentication_service/src/api/login/passwordless.rs+++ b/rust/cloud-storage/authentication_service/src/api/login/passwordless.rs@@ -8,7 +8,7 @@ use axum::{use std::borrow::Cow;use crate::{api::context::ApiContext, generate_password::generate_random_password};-use authentication_service::service::fusionauth_client::error::FusionAuthClientError;+use fusionauth::error::FusionAuthClientError;use model::{authentication::login::{request::PasswordlessRequest, response::SsoRequiredResponse},response::EmptyResponse,@@ -96,7 +96,7 @@ pub async fn handler(tracing::trace!(email=%lowercase_email, "user does not exist, we need to create user");let fusionauth_user_id = ctx.auth_client- .create_user(authentication_service::service::fusionauth_client::user::create::User {+ .create_user(fusionauth::user::create::User {email: (&lowercase_email).into(),password: generate_random_password().into(),username: None,diff --git a/rust/cloud-storage/authentication_service/src/api/merge/verify_merge_request.rs b/rust/cloud-storage/authentication_service/src/api/merge/verify_merge_request.rsindex 3bb9da6f39..5bed1200c8 100644--- a/rust/cloud-storage/authentication_service/src/api/merge/verify_merge_request.rs+++ b/rust/cloud-storage/authentication_service/src/api/merge/verify_merge_request.rs@@ -8,9 +8,7 @@ use axum::{};use crate::api::context::ApiContext;-use authentication_service::service::fusionauth_client::identity_provider::{- IdentityProviderLink, LinkUserRequest,-};+use fusionauth::identity_provider::{IdentityProviderLink, LinkUserRequest};use model::{response::{EmptyResponse, ErrorResponse},diff --git a/rust/cloud-storage/authentication_service/src/api/oauth/passwordless_callback.rs b/rust/cloud-storage/authentication_service/src/api/oauth/passwordless_callback.rsindex 5a47711940..397d57cbe5 100644--- a/rust/cloud-storage/authentication_service/src/api/oauth/passwordless_callback.rs+++ b/rust/cloud-storage/authentication_service/src/api/oauth/passwordless_callback.rs@@ -11,7 +11,7 @@ use crate::api::{context::ApiContext,utils::{create_access_token_cookie, create_refresh_token_cookie},};-use authentication_service::service::fusionauth_client::error::FusionAuthClientError;+use fusionauth::error::FusionAuthClientError;use model::response::{ErrorResponse, UserTokensResponse};diff --git a/rust/cloud-storage/authentication_service/src/api/oauth2/google.rs b/rust/cloud-storage/authentication_service/src/api/oauth2/google.rsindex 77aa6e0a0a..a606f6edf6 100644--- a/rust/cloud-storage/authentication_service/src/api/oauth2/google.rs+++ b/rust/cloud-storage/authentication_service/src/api/oauth2/google.rs@@ -17,10 +17,8 @@ use crate::api::{login::{self},},};-use authentication_service::service::{- fusionauth_client::identity_provider::{IdentityProviderLink, LinkUserRequest},- user::create_user::create_user_profile,-};+use authentication_service::service::user::create_user::create_user_profile;+use fusionauth::identity_provider::{IdentityProviderLink, LinkUserRequest};async fn link_user(ctx: &ApiContext,diff --git a/rust/cloud-storage/authentication_service/src/api/user/create_user.rs b/rust/cloud-storage/authentication_service/src/api/user/create_user.rsindex d622d93c28..02f5e6c322 100644--- a/rust/cloud-storage/authentication_service/src/api/user/create_user.rs+++ b/rust/cloud-storage/authentication_service/src/api/user/create_user.rs@@ -83,7 +83,7 @@ pub async fn handler(ctx.auth_client.create_user(- authentication_service::service::fusionauth_client::user::create::User {+ fusionauth::user::create::User {email: email.into(),password: req.password.into(),username: Some(req.username.into()),diff --git a/rust/cloud-storage/authentication_service/src/api/webhooks/user/create_user_webhook.rs b/rust/cloud-storage/authentication_service/src/api/webhooks/user/create_user_webhook.rsindex 05f74436e7..08456ef20f 100644--- a/rust/cloud-storage/authentication_service/src/api/webhooks/user/create_user_webhook.rs+++ b/rust/cloud-storage/authentication_service/src/api/webhooks/user/create_user_webhook.rs@@ -14,9 +14,8 @@ use rand::Rng;use sqlx::{Pool, Postgres};use crate::api::context::ApiContext;-use authentication_service::service::{- fusionauth_client::error::FusionAuthClientError, user::create_user::create_user,-};+use authentication_service::service::user::create_user::create_user;+use fusionauth::error::FusionAuthClientError;use model::authentication::webhooks::FusionAuthUserWebhook;/// FusionAuth create user webhookdiff --git a/rust/cloud-storage/authentication_service/src/bin/backfill_null_macro_user_id.rs b/rust/cloud-storage/authentication_service/src/bin/backfill_null_macro_user_id.rsdeleted file mode 100644index be7414671e..0000000000--- a/rust/cloud-storage/authentication_service/src/bin/backfill_null_macro_user_id.rs+++ /dev/null@@ -1,141 +0,0 @@-use anyhow::Context;-use authentication_service::generate_random_password;-use futures::StreamExt;-use macro_entrypoint::MacroEntrypoint;-use sqlx::postgres::PgPoolOptions;-use std::borrow::Cow;--/// Backfills the macro_user table with all users in the database-/// LIMIT defaults to 1000-/// STARTING_CURSOR optional cursor to start from (User table id)-#[tokio::main]-pub async fn main() -> anyhow::Result<()> {- MacroEntrypoint::default().init();-- let database_url = std::env::var("DATABASE_URL").context("expected to find DATABASE_URL")?;- let db = PgPoolOptions::new()- .min_connections(5)- .max_connections(25)- .connect(&database_url)- .await- .context("could not connect to db")?;-- tracing::trace!("initialized db connection");-- let limit = std::env::var("LIMIT")- .map(|s| s.parse::<i64>().unwrap())- .unwrap_or(1000);- let mut cursor: Option<String> = std::env::var("CURSOR").ok();-- let mut total = 0;-- let auth_client = authentication_service::FusionAuthClient::new(- std::env::var("FUSIONAUTH_TENANT_ID").context("FUSIONAUTH_TENANT_ID env var not set")?,- std::env::var("FUSIONAUTH_API_KEY").context("FUSIONAUTH_API_KEY env var not set")?,- std::env::var("FUSIONAUTH_CLIENT_ID").context("FUSIONAUTH_CLIENT_ID env var not set")?,- std::env::var("FUSIONAUTH_CLIENT_SECRET")- .context("FUSIONAUTH_CLIENT_SECRET env var not set")?,- std::env::var("FUSIONAUTH_APPLICATION_ID")- .context("FUSIONAUTH_APPLICATION_ID env var not set")?,- std::env::var("FUSIONAUTH_BASE_URL").context("FUSIONAUTH_BASE_URL env var not set")?,- "FUSIONAUTH_OAUTH_REDIRECT_URI".to_string(), // not used in script so can be ignored- "GOOGLE_CLIENT_ID".to_string(), // not used in script so can be ignored- "GOOGLE_CLIENT_SECRET".to_string(), // not used in script so can be ignored- );-- loop {- // get batch of users email + stripe customer id with macro_user_id NULL- let users =- macro_db_client::user::get_all::get_all_user_ids_stripe_customer_id_with_null_macro_user_id(&db, limit, cursor.clone())- .await- .context("unable to get users")?;-- if users.is_empty() {- tracing::trace!("no more users to process");- break;- }-- let last_user_id = users.last().map(|(id, _)| id.clone());-- let result = futures::stream::iter(users.iter())- .then(|(user_id, stripe_customer_id)| {- let db = db.clone();- let auth_client = auth_client.clone();- async move {- tracing::trace!(user_id=%user_id, stripe_customer_id=?stripe_customer_id, "processing user");- let stripe_customer_id = if let Some(stripe_customer_id) = stripe_customer_id {- stripe_customer_id.to_string()- } else {- return Err((user_id.to_string(), anyhow::anyhow!("no stripe customer id found")));- };-- // strip the macro| from user id to get their email- let email = user_id.replace("macro|", "");-- // get fusionauth user id by email- let fusionauth_user_id = if let Ok(fusionauth_user_id) = auth_client- .get_user_id_by_email(&email)- .await {- fusionauth_user_id- } else {- tracing::warn!("unable to get fusionauth user id by email {email}. creating user");- auth_client.create_user(authentication_service::User{- email: Cow::Borrowed(&email),- password: generate_random_password().into(),- username: None, // the username will automatically be set to the email- },- true,- )- .await- .map_err(|e| (user_id.to_string(), anyhow::Error::new(e)))?;-- return Ok(());- };-- tracing::trace!(fusionauth_user_id=?fusionauth_user_id, user_id=?user_id, stripe_customer_id=?stripe_customer_id, "user id found");-- let mut transaction = db.begin().await.map_err(|e| {- (- user_id.to_string(),- anyhow::Error::new(e).context("unable to start transaction"),- )- })?;-- // create macro user- macro_db_client::macro_user::create_macro_user(&mut transaction, &fusionauth_user_id, &email, &stripe_customer_id, &email).await.map_err(|e| (user_id.to_string(), e))?;-- // update User table with macro_user_id- macro_db_client::user::update::upsert_macro_user_id(&mut transaction, user_id, &fusionauth_user_id).await.map_err(|e| (user_id.to_string(), e))?;-- // move user profile to macro_user_info table- macro_db_client::user::update::migrate_macro_user_info(&mut transaction, &fusionauth_user_id, user_id).await.map_err(|e| (user_id.to_string(), e))?;-- transaction.commit().await.map_err(|e| (user_id.to_string(), anyhow::Error::new(e)))?;-- Ok(())- }- })- .collect::<Vec<Result<(), (String, anyhow::Error)>>>()- .await;-- let failed_results = result- .into_iter()- .filter_map(|r| r.err())- .collect::<Vec<_>>();-- for (user_id, e) in failed_results {- eprintln!("unable to process user {user_id}: reason: {e}");- }-- if let Some(cursor) = cursor.as_deref() {- println!("processed cursor {cursor} users");- }-- cursor = last_user_id;- total += users.len();- }-- println!("done processed {total} users");-- Ok(())-}diff --git a/rust/cloud-storage/authentication_service/src/config.rs b/rust/cloud-storage/authentication_service/src/config.rsindex 0b3769ecf0..9586ad7043 100644--- a/rust/cloud-storage/authentication_service/src/config.rs+++ b/rust/cloud-storage/authentication_service/src/config.rs@@ -29,8 +29,6 @@ pub struct Config {pub fusionauth_client_id: String,/// FusionAuth client secret keypub fusionauth_client_secret_key: String,- /// FusionAuth application id- pub fusionauth_application_id: String,/// FusionAuth base urlpub fusionauth_base_url: String,/// FusionAuth oauth redirect uri@@ -84,8 +82,6 @@ impl Config {.context("FUSIONAUTH_CLIENT_ID must be provided")?;let fusionauth_client_secret_key = std::env::var("FUSIONAUTH_CLIENT_SECRET_KEY").context("FUSIONAUTH_CLIENT_SECRET_KEY must be provided")?;- let fusionauth_application_id = std::env::var("FUSIONAUTH_APPLICATION_ID")- .context("FUSIONAUTH_APPLICATION_ID must be provided")?;let fusionauth_base_url =std::env::var("FUSIONAUTH_BASE_URL").context("FUSIONAUTH_BASE_URL must be provided")?;let fusionauth_oauth_redirect_uri = std::env::var("FUSIONAUTH_OAUTH_REDIRECT_URI")@@ -131,7 +127,6 @@ impl Config {fusionauth_api_key_secret_key,fusionauth_client_id,fusionauth_client_secret_key,- fusionauth_application_id,fusionauth_base_url,fusionauth_oauth_redirect_uri,google_client_id,diff --git a/rust/cloud-storage/authentication_service/src/lib.rs b/rust/cloud-storage/authentication_service/src/lib.rsindex b11418955e..1f278a4d51 100644--- a/rust/cloud-storage/authentication_service/src/lib.rs+++ b/rust/cloud-storage/authentication_service/src/lib.rs@@ -1,9 +1 @@-pub mod fetch_and_checksum;-mod generate_password;pub mod service;--/// expose auth client to be used in bin-pub use service::fusionauth_client::FusionAuthClient;-pub use service::fusionauth_client::user::create::User;--pub use generate_password::generate_random_password;diff --git a/rust/cloud-storage/authentication_service/src/main.rs b/rust/cloud-storage/authentication_service/src/main.rsindex 21dda53390..8b8f8ce261 100644--- a/rust/cloud-storage/authentication_service/src/main.rs+++ b/rust/cloud-storage/authentication_service/src/main.rs@@ -33,8 +33,6 @@ mod config;mod generate_password;mod rate_limit_config;-use authentication_service::service;-#[tokio::main]async fn main() -> anyhow::Result<()> {MacroEntrypoint::default().init();@@ -126,12 +124,11 @@ async fn main() -> anyhow::Result<()> {.to_string(),};- let auth_client = service::fusionauth_client::FusionAuthClient::new(+ let auth_client = fusionauth::FusionAuthClient::new(config.fusionauth_tenant_id,fusionauth_api_key,config.fusionauth_client_id.clone(),fusionauth_client_secret,- config.fusionauth_application_id.clone(),config.fusionauth_base_url.clone(),config.fusionauth_oauth_redirect_uri.clone(),config.google_client_id.clone(),diff --git a/rust/cloud-storage/authentication_service/src/service/mod.rs b/rust/cloud-storage/authentication_service/src/service/mod.rsindex 0a7927ac44..22d12a3827 100644--- a/rust/cloud-storage/authentication_service/src/service/mod.rs+++ b/rust/cloud-storage/authentication_service/src/service/mod.rs@@ -1,2 +1 @@-pub mod fusionauth_client;pub mod user;diff --git a/rust/cloud-storage/fusionauth/Cargo.toml b/rust/cloud-storage/fusionauth/Cargo.tomlnew file mode 100644index 0000000000..c5f08f2af3--- /dev/null+++ b/rust/cloud-storage/fusionauth/Cargo.toml@@ -0,0 +1,20 @@+[package]+edition = "2024"+name = "fusionauth"+publish = false+version = "0.1.0"++[dependencies]+anyhow = { workspace = true }+base64 = { workspace = true }+macro_env = { path = "../macro_env" }+reqwest = { workspace = true }+serde = { workspace = true }+serde_json = { workspace = true }+serde_urlencoded = "0.7.1"+thiserror = { workspace = true }+tracing = { workspace = true }+urlencoding = { workspace = true }++[dev-dependencies]+tokio = { workspace = true }diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/apple.rs b/rust/cloud-storage/fusionauth/src/apple.rssimilarity index 93%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/apple.rsrename to rust/cloud-storage/fusionauth/src/apple.rsindex 097ccc168e..38ffd99acf 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/apple.rs+++ b/rust/cloud-storage/fusionauth/src/apple.rs@@ -1,6 +1,6 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{FusionAuthClient, Result, UnauthedClient,error::{FusionAuthClientError, GenericErrorResponse},};@@ -82,7 +82,8 @@ async fn login(}impl FusionAuthClient {- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Performs an Apple login using the provided identity provider ID, id token, and code.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn apple_login(&self,apple_identity_provider_id: &str,@@ -93,7 +94,7 @@ impl FusionAuthClient {&self.unauth_client,&self.fusion_auth_base_url,AppleLoginRequest {- application_id: Cow::Borrowed(&self.application_id),+ application_id: Cow::Borrowed(&self.client_id),data: AppleLoginRequestData {id_token: Cow::Borrowed(id_token),code: Cow::Borrowed(code),diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/error.rs b/rust/cloud-storage/fusionauth/src/error.rssimilarity index 65%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/error.rsrename to rust/cloud-storage/fusionauth/src/error.rsindex 2a4b53b402..d47085fbe4 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/error.rs+++ b/rust/cloud-storage/fusionauth/src/error.rs@@ -1,30 +1,43 @@#[derive(thiserror::Error, Debug, serde::Serialize)]#[serde(tag = "type")]+/// Errors that can occur when interacting with the FusionAuth API.pub enum FusionAuthClientError {+ /// The user does not exist in FusionAuth.#[error("user does not exist")]UserDoesNotExist,+ /// The user's email has not been verified.#[error("user not verified")]UserNotVerified,+ /// The user is not registered to the application.#[error("user not registered to application")]UserNotRegistered,+ /// The user is already registered to the application.#[error("user already registered")]UserAlreadyRegistered,+ /// A user with this email already exists.#[error("user already exists")]UserAlreadyExists,+ /// No identity provider was found.#[error("no identity provider found")]NoIdentityProviderFound,+ /// The provided code was incorrect.#[error("incorrect code")]IncorrectCode,+ /// The refresh token was not found or has expired.#[error("refresh token was not found or has expired")]InvalidRefreshToken,+ /// A generic error occurred.#[error("an unknown error occurred")]Generic(GenericErrorResponse),+ /// The grant is invalid - user may have revoked access.#[error("Invalid grant - user may have revoked access")]InvalidGrant,}+/// A generic error response containing a message.#[derive(serde::Serialize, Debug)]pub struct GenericErrorResponse {+ /// The error message.pub message: String,}diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/google/mod.rs b/rust/cloud-storage/fusionauth/src/google/mod.rssimilarity index 85%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/google/mod.rsrename to rust/cloud-storage/fusionauth/src/google/mod.rsindex 6813410da1..a93df2cd7a 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/google/mod.rs+++ b/rust/cloud-storage/fusionauth/src/google/mod.rs@@ -1,11 +1,13 @@-use crate::service::fusionauth_client::{+use crate::{FusionAuthClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};+/// Google OAuth token operations.pub mod oauth;impl FusionAuthClient {+ /// Refreshes a Google OAuth2 access token using a refresh token.#[tracing::instrument(skip(self, refresh_token), fields(client_id=%self.client_id))]pub async fn refresh_google_token(&self,@@ -20,6 +22,7 @@ impl FusionAuthClient {.await}+ /// Exchanges a Google authorization code for tokens.#[tracing::instrument(skip(self, code, redirect_uri))]pub async fn exchange_google_code_for_tokens(&self,@@ -36,6 +39,7 @@ impl FusionAuthClient {.await}+ /// Parses and decodes a Google ID token to extract user info.#[tracing::instrument(skip(self, id_token))]pub fn parse_google_id_token(&self, id_token: &str) -> Result<oauth::GoogleUserInfo> {let result = oauth::decode_google_id_token(id_token).map_err(|e| {diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/google/oauth.rs b/rust/cloud-storage/fusionauth/src/google/oauth.rssimilarity index 87%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/google/oauth.rsrename to rust/cloud-storage/fusionauth/src/google/oauth.rsindex a485c256bd..d695ae25b5 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/google/oauth.rs+++ b/rust/cloud-storage/fusionauth/src/google/oauth.rs@@ -1,6 +1,6 @@use std::{collections::HashMap, time::Duration};-use crate::service::fusionauth_client::{+use crate::{Result, UnauthedClient,error::{FusionAuthClientError, GenericErrorResponse},};@@ -10,6 +10,7 @@ use base64::{};#[derive(serde::Serialize, serde::Deserialize, Debug)]+/// Request to refresh a Google OAuth2 access token.pub struct GoogleTokenRequest {client_id: String,client_secret: String,@@ -18,17 +19,23 @@ pub struct GoogleTokenRequest {}#[derive(serde::Serialize, serde::Deserialize, Debug)]+/// Response from refreshing a Google OAuth2 access token.pub struct GoogleTokenResponse {+ /// The access token.pub access_token: String,+ /// The number of seconds until the token expires.pub expires_in: u64,+ /// The scope of the token.pub scope: String,+ /// The type of token.pub token_type: String,+ /// The ID token.pub id_token: String,}/// Refreshes a Google OAuth2 access token using a refresh token./// See https://developers.google.com/identity/protocols/oauth2/web-server#offline-pub(in crate::service::fusionauth_client) async fn refresh_google_token(+pub(crate) async fn refresh_google_token(client: &UnauthedClient,client_id: &str,client_secret: &str,@@ -99,8 +106,11 @@ pub(in crate::service::fusionauth_client) async fn refresh_google_token(}#[derive(Debug, serde::Deserialize)]+/// Response from exchanging a Google authorization code for tokens.pub struct GoogleExchangeTokenResponse {+ /// The refresh token.pub refresh_token: String,+ /// The ID token.pub id_token: String,}@@ -113,7 +123,8 @@ struct TokenExchangeRequest {redirect_uri: String,}-pub(in crate::service::fusionauth_client) async fn exchange_code_for_tokens(+/// Exchanges a Google authorization code for tokens.+pub(crate) async fn exchange_code_for_tokens(client: &UnauthedClient,client_id: &str,client_secret: &str,@@ -172,16 +183,19 @@ pub(in crate::service::fusionauth_client) async fn exchange_code_for_tokens(}#[derive(Debug, serde::Serialize, serde::Deserialize)]+/// User info extracted from a Google ID token.pub struct GoogleUserInfo {- pub sub: String, // Google user ID+ /// The Google user ID.+ pub sub: String,+ /// The user's email address.pub email: String,+ /// Additional claims from the ID token.#[serde(flatten)]pub other: HashMap<String, serde_json::Value>,}-pub(in crate::service::fusionauth_client) fn decode_google_id_token(- id_token: &str,-) -> anyhow::Result<GoogleUserInfo> {+/// Decodes a Google ID token without signature verification.+pub(crate) fn decode_google_id_token(id_token: &str) -> anyhow::Result<GoogleUserInfo> {// Split the JWT into its three partslet parts: Vec<&str> = id_token.split('.').collect();if parts.len() != 3 {diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/link.rs b/rust/cloud-storage/fusionauth/src/identity_provider/link.rssimilarity index 86%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/link.rsrename to rust/cloud-storage/fusionauth/src/identity_provider/link.rsindex 951d934276..358bc9f366 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/link.rs+++ b/rust/cloud-storage/fusionauth/src/identity_provider/link.rs@@ -1,12 +1,13 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{AuthedClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]+/// Response containing identity provider links.pub struct RetrieveLinkResponse {/// The link returned from the lookup - should only be one in the vec#[serde(rename = "identityProviderLinks")]@@ -15,16 +16,27 @@ pub struct RetrieveLinkResponse {#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]+/// An identity provider link.pub struct Link {+ /// The display name for this link.pub display_name: String,+ /// The identity provider ID.pub identity_provider_id: String,+ /// The name of the identity provider.pub identity_provider_name: String,+ /// The type of the identity provider.pub identity_provider_type: String,+ /// The user ID on the identity provider side.pub identity_provider_user_id: String,+ /// The instant when the link was created.pub insert_instant: u64,+ /// The instant of the last login using this link.pub last_login_instant: u64,+ /// The tenant ID.pub tenant_id: String,+ /// The token associated with this link.pub token: String,+ /// The FusionAuth user ID.pub user_id: String,}@@ -32,7 +44,7 @@ pub struct Link {/// If idp_id is provided, only links for that identity provider are returned/// https://fusionauth.io/docs/apis/identity-providers/links#retrieve-a-link/// Valid respones: 200, 400, 401, 404, 500-pub(in crate::service::fusionauth_client) async fn get_links(+pub(crate) async fn get_links(client: &AuthedClient,base_url: &str,user_id: &str,@@ -80,6 +92,7 @@ pub(in crate::service::fusionauth_client) async fn get_links(#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]+/// An identity provider link for creating a link.pub struct IdentityProviderLink<'a> {/// The display namepub display_name: Cow<'a, str>,@@ -95,6 +108,7 @@ pub struct IdentityProviderLink<'a> {#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]+/// Request to link a user to an identity provider.pub struct LinkUserRequest<'a> {/// The identity provider linkpub identity_provider_link: IdentityProviderLink<'a>,@@ -103,7 +117,7 @@ pub struct LinkUserRequest<'a> {/// This API is used to create a link between a FusionAuth User and a user in a 3rd party identity provider. This API may be useful when you already know the unique Id of a user in a 3rd party identity provider and the corresponding FusionAuth User./// https://fusionauth.io/docs/apis/identity-providers/links#link-a-user/// Valid respones: 200, 400, 401, 500, 504-pub(in crate::service::fusionauth_client) async fn link_user(+pub(crate) async fn link_user(client: &AuthedClient,base_url: &str,request: LinkUserRequest<'_>,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/login.rs b/rust/cloud-storage/fusionauth/src/identity_provider/login.rssimilarity index 96%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/login.rsrename to rust/cloud-storage/fusionauth/src/identity_provider/login.rsindex 0eb92a6494..83e75119ef 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/login.rs+++ b/rust/cloud-storage/fusionauth/src/identity_provider/login.rs@@ -1,6 +1,6 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{Result, UnauthedClient,error::{FusionAuthClientError, GenericErrorResponse},};@@ -41,7 +41,7 @@ pub struct IdentityProviderLoginResponse {/// This API allows you to complete a OpenID Connect login after authenticating a user using the OpenID Connect API. If you are using the FusionAuth login UI with the OpenID Connect button you will not utilize this API directly./// https://fusionauth.io/docs/apis/identity-providers/openid-connect#complete-an-openid-connect-login/// Valid respones: 200, 202, 203, 204, 212, 213, 242, 400, 401, 409, 410, 500, 503, 504-pub(in crate::service::fusionauth_client) async fn complete_identity_provider_login(+pub(crate) async fn complete_identity_provider_login(client: &UnauthedClient,base_url: &str,request: IdentityProviderLoginRequest<'_>,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/lookup.rs b/rust/cloud-storage/fusionauth/src/identity_provider/lookup.rssimilarity index 96%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/lookup.rsrename to rust/cloud-storage/fusionauth/src/identity_provider/lookup.rsindex 0755b16d0e..46cd9486a3 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/lookup.rs+++ b/rust/cloud-storage/fusionauth/src/identity_provider/lookup.rs@@ -1,6 +1,6 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{AuthedClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};@@ -36,7 +36,7 @@ struct IdentityProviderLookupResponse<'a> {/// If a match is found, it will return the identify provider's id to be used in the sso idp_hint/// https://fusionauth.io/docs/apis/identity-providers/#lookup-an-identity-provider/// Valid respones: 200, 400, 404, 500-pub(in crate::service::fusionauth_client) async fn get_idp_id_by_domain(+pub(crate) async fn get_idp_id_by_domain(client: &AuthedClient,base_url: &str,email: &str,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/mod.rs b/rust/cloud-storage/fusionauth/src/identity_provider/mod.rssimilarity index 78%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/mod.rsrename to rust/cloud-storage/fusionauth/src/identity_provider/mod.rsindex 39f9acb824..69f36e6380 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/mod.rs+++ b/rust/cloud-storage/fusionauth/src/identity_provider/mod.rs@@ -1,6 +1,6 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{FusionAuthClient, Result};+use crate::{FusionAuthClient, Result};mod link;mod login;@@ -11,13 +11,14 @@ mod unlink;pub use link::*;impl FusionAuthClient {- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Searches for an identity provider by name and returns its ID.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn get_identity_provider_id_by_name(&self, name: &str) -> Result<String> {search::get_idp_id_by_name(&self.auth_client, &self.fusion_auth_base_url, name).await}/// This API is used to retrieve all Links for a specific user.- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn get_links(&self,user_id: &str,@@ -33,12 +34,13 @@ impl FusionAuthClient {}/// This API is used to create a link between a FusionAuth User and a user in a 3rd party identity provider. This API may be useful when you already know the unique Id of a user in a 3rd party identity provider and the corresponding FusionAuth User.- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url, user_id=%request.identity_provider_link.user_id, idp_id=%request.identity_provider_link.identity_provider_id))]+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url, user_id=%request.identity_provider_link.user_id, idp_id=%request.identity_provider_link.identity_provider_id))]pub async fn link_user(&self, request: LinkUserRequest<'_>) -> Result<()> {link::link_user(&self.auth_client, &self.fusion_auth_base_url, request).await}- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Unlinks a user from an identity provider.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn unlink_user(&self, user_id: &str, idp_id: &str, idp_user_id: &str) -> Result<()> {unlink::unlink(&self.auth_client,@@ -50,13 +52,14 @@ impl FusionAuthClient {.await}- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Looks up an identity provider by domain.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn lookup_identity_provider(&self, domain: &str) -> Result<Option<String>> {lookup::get_idp_id_by_domain(&self.auth_client, &self.fusion_auth_base_url, domain).await}/// Completes the identity provider login- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn complete_identity_provider_login(&self,idp_id: &str,@@ -68,7 +71,7 @@ impl FusionAuthClient {&self.unauth_client,&self.fusion_auth_base_url,login::IdentityProviderLoginRequest {- application_id: Cow::Borrowed(&self.application_id),+ application_id: Cow::Borrowed(&self.client_id),identity_provider_id: Cow::Borrowed(idp_id),no_link,data: login::IdentityProviderLoginRequestData {diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/search.rs b/rust/cloud-storage/fusionauth/src/identity_provider/search.rssimilarity index 96%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/search.rsrename to rust/cloud-storage/fusionauth/src/identity_provider/search.rsindex 3911da976f..616f10f42c 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/search.rs+++ b/rust/cloud-storage/fusionauth/src/identity_provider/search.rs@@ -1,6 +1,6 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{AuthedClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};@@ -24,7 +24,7 @@ struct IdentityProviderSearchResponse<'a> {/// name of the provider/// https://fusionauth.io/docs/apis/identity-providers/#request-1/// Valid respones: 200, 400, 401, 500-pub(in crate::service::fusionauth_client) async fn get_idp_id_by_name(+pub(crate) async fn get_idp_id_by_name(client: &AuthedClient,base_url: &str,name: &str,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/unlink.rs b/rust/cloud-storage/fusionauth/src/identity_provider/unlink.rssimilarity index 93%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/unlink.rsrename to rust/cloud-storage/fusionauth/src/identity_provider/unlink.rsindex b2301db5e7..bb6febc0f7 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/identity_provider/unlink.rs+++ b/rust/cloud-storage/fusionauth/src/identity_provider/unlink.rs@@ -1,4 +1,4 @@-use crate::service::fusionauth_client::{+use crate::{AuthedClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};@@ -6,7 +6,7 @@ use crate::service::fusionauth_client::{/// Unlinks a user from an identity provider/// https://fusionauth.io/docs/apis/identity-providers/links#unlink-a-user/// Valid respones: 200, 400, 401, 404, 500-pub(in crate::service::fusionauth_client) async fn unlink(+pub(crate) async fn unlink(client: &AuthedClient,base_url: &str,user_id: &str,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/jwt/mod.rs b/rust/cloud-storage/fusionauth/src/jwt/mod.rssimilarity index 70%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/jwt/mod.rsrename to rust/cloud-storage/fusionauth/src/jwt/mod.rsindex 6262a83099..1699916755 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/jwt/mod.rs+++ b/rust/cloud-storage/fusionauth/src/jwt/mod.rs@@ -1,9 +1,10 @@-use crate::service::fusionauth_client::{FusionAuthClient, Result};+use crate::{FusionAuthClient, Result};mod refresh;impl FusionAuthClient {- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Refreshes a JWT token using the provided access and refresh tokens.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn refresh_token(&self,access_token: &str,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/jwt/refresh.rs b/rust/cloud-storage/fusionauth/src/jwt/refresh.rssimilarity index 98%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/jwt/refresh.rsrename to rust/cloud-storage/fusionauth/src/jwt/refresh.rsindex 7c497e353a..a7d0673d5b 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/jwt/refresh.rs+++ b/rust/cloud-storage/fusionauth/src/jwt/refresh.rs@@ -1,6 +1,6 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{Result, UnauthedClient,error::{FusionAuthClientError, GenericErrorResponse},};diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/mod.rs b/rust/cloud-storage/fusionauth/src/lib.rssimilarity index 84%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/mod.rsrename to rust/cloud-storage/fusionauth/src/lib.rsindex dfd8a5fea8..d433558be4 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/mod.rs+++ b/rust/cloud-storage/fusionauth/src/lib.rs@@ -1,20 +1,35 @@+#![deny(missing_docs)]+//! FusionAuth API client library.++/// Apple identity provider login.pub mod apple;+/// FusionAuth error types.pub mod error;+/// Google identity provider and OAuth.pub mod google;+/// Identity provider management (links, login, lookup, search, unlink).pub mod identity_provider;+/// JWT refresh operations.pub mod jwt;+/// Logout operations.pub mod logout;+/// OAuth authorization code grant.pub mod oauth;+/// Password-based login.pub mod password;+/// Passwordless login flow.pub mod passwordless;+/// User management (create, delete, get, register, verify).pub mod user;+/// Result type alias using [`error::FusionAuthClientError`] as the default error.pub type Result<T, E = error::FusionAuthClientError> = std::result::Result<T, E>;use anyhow::Context;use reqwest::Url;+/// An HTTP client with default Authorization and optional tenant headers.#[derive(Clone, Debug)]pub struct AuthedClient {inner: reqwest::Client,@@ -24,6 +39,7 @@ pub struct AuthedClient {const FUSIONAUTH_TENANT_ID_HEADER: &str = "X-FusionAuth-TenantId";impl AuthedClient {+ /// Creates a new authenticated client with the given API key and tenant ID.pub fn new(url: &str, api_key: String, tenant_id: String) -> Self {// Create authenticated client with default Authorization headerlet mut auth_headers = reqwest::header::HeaderMap::new();@@ -49,34 +65,37 @@ impl AuthedClient {Self { inner: client }}+ /// Returns a reference to the inner reqwest client.pub fn client(&self) -> &reqwest::Client {&self.inner}}+/// An HTTP client without authentication headers.#[derive(Clone, Debug, Default)]pub struct UnauthedClient {inner: reqwest::Client,}impl UnauthedClient {+ /// Creates a new unauthenticated client.pub fn new() -> Self {Self::default()}+ /// Returns a reference to the inner reqwest client.pub fn client(&self) -> &reqwest::Client {&self.inner}}+/// The main FusionAuth API client.#[derive(Clone, Debug)]pub struct FusionAuthClient {/// The fusionauth client idclient_id: String,/// The fusionauth client secretclient_secret: String,- /// The fusionauth application id- application_id: String,/// The base url for the fusion auth apifusion_auth_base_url: String,/// The oauth redirect uri@@ -92,13 +111,13 @@ pub struct FusionAuthClient {}impl FusionAuthClient {+ /// Creates a new FusionAuth client with the given configuration.#[expect(clippy::too_many_arguments, reason = "too annoying to fix")]pub fn new(tenant_id: String,api_key: String,client_id: String,client_secret: String,- application_id: String,fusion_auth_base_url: String,oauth_redirect_uri: String,google_client_id: String,@@ -110,7 +129,6 @@ impl FusionAuthClient {Self {client_id,client_secret,- application_id,fusion_auth_base_url,oauth_redirect_uri,auth_client,@@ -123,7 +141,7 @@ impl FusionAuthClient {/// Constructs the oauth2 authorize url for the given idp/// If login_hint is provided, it will be used as the login_hint parameter. This is used to/// ensure users are correctly redirected for domain specific SSO- #[tracing::instrument(skip(self, state), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url), level = tracing::Level::TRACE)]+ #[tracing::instrument(skip(self, state), level = tracing::Level::TRACE)]pub fn construct_oauth2_authorize_url<T>(&self,idp_id: &str,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/logout.rs b/rust/cloud-storage/fusionauth/src/logout.rssimilarity index 94%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/logout.rsrename to rust/cloud-storage/fusionauth/src/logout.rsindex 2920917c9f..a092da191f 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/logout.rs+++ b/rust/cloud-storage/fusionauth/src/logout.rs@@ -1,4 +1,4 @@-use crate::service::fusionauth_client::{+use crate::{FusionAuthClient, Result, UnauthedClient,error::{FusionAuthClientError, GenericErrorResponse},};@@ -53,7 +53,8 @@ async fn logout(client: &UnauthedClient, base_url: &str, request: LogoutRequest<}impl FusionAuthClient {- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Logs out the user for the given tenant.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn logout(&self, tenant_id: &str) -> Result<()> {logout(&self.unauth_client,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/oauth/mod.rs b/rust/cloud-storage/fusionauth/src/oauth/mod.rssimilarity index 96%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/oauth/mod.rsrename to rust/cloud-storage/fusionauth/src/oauth/mod.rsindex cd7c6c21b0..a1f0699429 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/oauth/mod.rs+++ b/rust/cloud-storage/fusionauth/src/oauth/mod.rs@@ -1,6 +1,6 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{FusionAuthClient, Result, UnauthedClient,error::{FusionAuthClientError, GenericErrorResponse},};@@ -96,7 +96,8 @@ async fn complete(}impl FusionAuthClient {- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Completes the OAuth2 authorization code grant flow.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn complete_authorization_code_grant(&self, code: &str) -> Result<(String, String)> {complete(&self.unauth_client,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/password.rs b/rust/cloud-storage/fusionauth/src/password.rssimilarity index 93%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/password.rsrename to rust/cloud-storage/fusionauth/src/password.rsindex 229af32d4d..3244ede7e3 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/password.rs+++ b/rust/cloud-storage/fusionauth/src/password.rs@@ -1,6 +1,6 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{AuthedClient, FusionAuthClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};@@ -91,13 +91,14 @@ async fn login(}impl FusionAuthClient {- #[tracing::instrument(skip(self, password), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Performs a password-based login with the given email and password.+ #[tracing::instrument(skip(self, password), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn password_login(&self, email: &str, password: &str) -> Result<(String, String)> {login(&self.auth_client,&self.fusion_auth_base_url,PasswordLoginRequest {- application_id: Cow::Borrowed(&self.application_id),+ application_id: Cow::Borrowed(&self.client_id),login_id: Cow::Borrowed(email),password: Cow::Borrowed(password),},diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/passwordless/mod.rs b/rust/cloud-storage/fusionauth/src/passwordless/mod.rssimilarity index 92%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/passwordless/mod.rsrename to rust/cloud-storage/fusionauth/src/passwordless/mod.rsindex 22a87cd70a..99eee55c4e 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/passwordless/mod.rs+++ b/rust/cloud-storage/fusionauth/src/passwordless/mod.rs@@ -1,6 +1,6 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{AuthedClient, FusionAuthClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};@@ -43,17 +43,23 @@ struct PasswordlessLoginCompleteRequest<'a> {pub code: Cow<'a, str>,}+/// The state returned in the passwordless login response.#[derive(serde::Serialize, serde::Deserialize, Debug)]pub struct PasswordlessLoginStateResponse {+ /// The redirect URI.pub redirect_uri: String,}+/// A user returned from the passwordless login response.#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]pub struct User {+ /// The user's FusionAuth ID.pub id: String,+ /// The user's email address.pub email: String,}+/// The complete response from a passwordless login.#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]pub struct PasswordlessLoginCompleteResponse {@@ -220,7 +226,8 @@ async fn complete(}impl FusionAuthClient {- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Starts a passwordless login flow for the given email.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn start_passwordless_login(&self,email: &str,@@ -231,7 +238,7 @@ impl FusionAuthClient {&self.fusion_auth_base_url,PasswordlessLoginStartRequest {login_id: Cow::Borrowed(email),- application_id: Cow::Borrowed(&self.application_id),+ application_id: Cow::Borrowed(&self.client_id),state: PasswordlessLoginStateRequest {client_id: Cow::Borrowed(&self.client_id),response_type: Cow::Borrowed("code"),@@ -243,7 +250,8 @@ impl FusionAuthClient {.await}- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Sends the passwordless login code to the user.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn send_passwordless_login(&self, code: &str) -> Result<()> {send(&self.auth_client,@@ -255,6 +263,7 @@ impl FusionAuthClient {.await}+ /// Completes the passwordless login flow with the given code.#[tracing::instrument(skip_all, level = tracing::Level::TRACE)]pub async fn complete_passwordless_login(&self,@@ -264,7 +273,7 @@ impl FusionAuthClient {&self.auth_client,&self.fusion_auth_base_url,PasswordlessLoginCompleteRequest {- application_id: Cow::Borrowed(&self.application_id),+ application_id: Cow::Borrowed(&self.client_id),code: Cow::Borrowed(code),},)diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/test.rs b/rust/cloud-storage/fusionauth/src/test.rssimilarity index 100%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/test.rsrename to rust/cloud-storage/fusionauth/src/test.rsdiff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/create.rs b/rust/cloud-storage/fusionauth/src/user/create.rssimilarity index 91%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/create.rsrename to rust/cloud-storage/fusionauth/src/user/create.rsindex 50617bd0e4..8cba781e0d 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/create.rs+++ b/rust/cloud-storage/fusionauth/src/user/create.rs@@ -1,10 +1,11 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{AuthedClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};+/// A user to create in FusionAuth.#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]pub struct User<'a> {@@ -20,7 +21,7 @@ pub struct User<'a> {#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]-pub(in crate::service::fusionauth_client) struct CreateUserRequest<'a> {+pub(crate) struct CreateUserRequest<'a> {/// The fusionauth application idpub application_id: Cow<'a, str>,/// Whether to skip verification of a user@@ -32,7 +33,7 @@ pub(in crate::service::fusionauth_client) struct CreateUserRequest<'a> {#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]-pub(in crate::service::fusionauth_client) struct UserResponse<'a> {+pub(crate) struct UserResponse<'a> {/// The id of the userpub id: Cow<'a, str>,/// The email address of the user@@ -43,7 +44,7 @@ pub(in crate::service::fusionauth_client) struct UserResponse<'a> {#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]-pub(in crate::service::fusionauth_client) struct CreateUserResponse<'a> {+pub(crate) struct CreateUserResponse<'a> {/// The userpub user: UserResponse<'a>,}@@ -51,7 +52,7 @@ pub(in crate::service::fusionauth_client) struct CreateUserResponse<'a> {/// Creates a user in fusionauth/// https://fusionauth.io/docs/apis/users#create-a-user/// Valid respones: 200, 400, 401, 500, 503, 504-pub(in crate::service::fusionauth_client) async fn create_user(+pub(crate) async fn create_user(client: &AuthedClient,base_url: &str,request: CreateUserRequest<'_>,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/delete.rs b/rust/cloud-storage/fusionauth/src/user/delete.rssimilarity index 91%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/delete.rsrename to rust/cloud-storage/fusionauth/src/user/delete.rsindex d9344cc22d..8cabaaf976 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/delete.rs+++ b/rust/cloud-storage/fusionauth/src/user/delete.rs@@ -1,4 +1,4 @@-use crate::service::fusionauth_client::{+use crate::{AuthedClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};@@ -6,7 +6,7 @@ use crate::service::fusionauth_client::{/// Deletes a user in fusionauth/// https://fusionauth.io/docs/apis/users#delete-a-user/// Valid respones: 200, 400, 401, 404, 500, 503, 504-pub(in crate::service::fusionauth_client) async fn delete_user(+pub(crate) async fn delete_user(client: &AuthedClient,base_url: &str,user_id: &str,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/get.rs b/rust/cloud-storage/fusionauth/src/user/get.rssimilarity index 89%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/get.rsrename to rust/cloud-storage/fusionauth/src/user/get.rsindex 19f2af27f4..e1a11e2142 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/get.rs+++ b/rust/cloud-storage/fusionauth/src/user/get.rs@@ -1,13 +1,13 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{AuthedClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]-pub(in crate::service::fusionauth_client) struct UserResponse<'a> {+pub(crate) struct UserResponse<'a> {/// The id of the userpub id: Cow<'a, str>,/// The email address of the user@@ -18,7 +18,7 @@ pub(in crate::service::fusionauth_client) struct UserResponse<'a> {#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]-pub(in crate::service::fusionauth_client) struct GetUserResponse<'a> {+pub(crate) struct GetUserResponse<'a> {/// The userpub user: UserResponse<'a>,}@@ -26,7 +26,7 @@ pub(in crate::service::fusionauth_client) struct GetUserResponse<'a> {/// Retreives a user by email in fusionauth/// https://fusionauth.io/docs/apis/users#retrieve-a-user/// Valid respones: 200, 400, 401, 500, 503-pub(in crate::service::fusionauth_client) async fn get_user_id_by_email(+pub(crate) async fn get_user_id_by_email(client: &AuthedClient,base_url: &str,email: &str,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/mod.rs b/rust/cloud-storage/fusionauth/src/user/mod.rssimilarity index 74%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/mod.rsrename to rust/cloud-storage/fusionauth/src/user/mod.rsindex aa7678f3f1..2e80608221 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/mod.rs+++ b/rust/cloud-storage/fusionauth/src/user/mod.rs@@ -1,7 +1,8 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{FusionAuthClient, Result};+use crate::{FusionAuthClient, Result};+/// User creation operations.pub mod create;mod delete;mod get;@@ -9,7 +10,8 @@ mod register;mod verify;impl FusionAuthClient {- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Gets a user's FusionAuth ID by their email address.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn get_user_id_by_email(&self, email: &str) -> Result<String> {get::get_user_id_by_email(&self.auth_client, &self.fusion_auth_base_url, email).await}@@ -17,7 +19,7 @@ impl FusionAuthClient {/// Creates a new user in FusionAuth./// This will automatically trigger the api::webhooks::user::create_user_webhook to be called/// from within FusionAuth as well.- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn create_user(&self,user: create::User<'_>,@@ -27,7 +29,7 @@ impl FusionAuthClient {&self.auth_client,&self.fusion_auth_base_url,create::CreateUserRequest {- application_id: Cow::Borrowed(&self.application_id),+ application_id: Cow::Borrowed(&self.client_id),skip_verification,user,},@@ -36,12 +38,13 @@ impl FusionAuthClient {}/// This API is used to delete a User. Hard deletes the user.- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn delete_user(&self, user_id: &str) -> Result<()> {delete::delete_user(&self.auth_client, &self.fusion_auth_base_url, user_id).await}- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Registers a user to the application by looking up their email first.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn register_user_from_email(&self, email: &str) -> Result<()> {// Get the fusionauth user id for the emaillet fusionauth_user_id =@@ -54,14 +57,15 @@ impl FusionAuthClient {&fusionauth_user_id,register::RegisterUserRequest {registration: register::Registration {- application_id: Cow::Borrowed(&self.application_id),+ application_id: Cow::Borrowed(&self.client_id),},},).await}- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Registers a user to the application by their user ID.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn register_user(&self, user_id: &str) -> Result<()> {register::register_user(&self.auth_client,@@ -69,14 +73,15 @@ impl FusionAuthClient {user_id,register::RegisterUserRequest {registration: register::Registration {- application_id: Cow::Borrowed(&self.application_id),+ application_id: Cow::Borrowed(&self.client_id),},},).await}- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Verifies a user's email with the given verification ID.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn verify_email(&self, verification_id: &str) -> Result<()> {verify::verify_email(&self.auth_client,@@ -88,12 +93,13 @@ impl FusionAuthClient {.await}- #[tracing::instrument(skip(self), fields(application_id=%self.application_id, fusion_auth_base_url=%self.fusion_auth_base_url))]+ /// Resends the email verification for the given email.+ #[tracing::instrument(skip(self), fields(application_id=%self.client_id, fusion_auth_base_url=%self.fusion_auth_base_url))]pub async fn resend_verify_email(&self, email: &str) -> Result<()> {verify::resend_verify_email(&self.auth_client,&self.fusion_auth_base_url,- &self.application_id,+ &self.client_id,email,).awaitdiff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/register.rs b/rust/cloud-storage/fusionauth/src/user/register.rssimilarity index 89%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/register.rsrename to rust/cloud-storage/fusionauth/src/user/register.rsindex 8ac4d230fa..4cbf5b35af 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/register.rs+++ b/rust/cloud-storage/fusionauth/src/user/register.rs@@ -1,20 +1,20 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{AuthedClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]-pub(in crate::service::fusionauth_client) struct Registration<'a> {+pub(crate) struct Registration<'a> {/// The application idpub application_id: Cow<'a, str>,}#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]-pub(in crate::service::fusionauth_client) struct RegisterUserRequest<'a> {+pub(crate) struct RegisterUserRequest<'a> {/// The registration objectpub registration: Registration<'a>,}@@ -22,7 +22,7 @@ pub(in crate::service::fusionauth_client) struct RegisterUserRequest<'a> {/// Registers a user to a given application in fusionauth/// https://fusionauth.io/docs/apis/registrations#create-a-user-registration-for-an-existing-user/// Valid respones: 200, 400, 401, 404, 500, 503-pub(in crate::service::fusionauth_client) async fn register_user<'a>(+pub(crate) async fn register_user<'a>(client: &AuthedClient,base_url: &str,user_id: &str,diff --git a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/verify.rs b/rust/cloud-storage/fusionauth/src/user/verify.rssimilarity index 94%rename from rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/verify.rsrename to rust/cloud-storage/fusionauth/src/user/verify.rsindex f8ebcdecff..0b543caef7 100644--- a/rust/cloud-storage/authentication_service/src/service/fusionauth_client/user/verify.rs+++ b/rust/cloud-storage/fusionauth/src/user/verify.rs@@ -1,13 +1,13 @@use std::borrow::Cow;-use crate::service::fusionauth_client::{+use crate::{AuthedClient, Result,error::{FusionAuthClientError, GenericErrorResponse},};#[derive(serde::Serialize, serde::Deserialize, Debug)]#[serde(rename_all = "camelCase")]-pub(in crate::service::fusionauth_client) struct VerifyEmailRequest<'a> {+pub(crate) struct VerifyEmailRequest<'a> {/// The verification id to validate the user's emailpub verification_id: Cow<'a, str>,}@@ -15,7 +15,7 @@ pub(in crate::service::fusionauth_client) struct VerifyEmailRequest<'a> {/// Verifies a user's email in fusionauth/// https://fusionauth.io/docs/apis/users#verify-a-users-email/// Valid respones: 200, 400, 401, 404, 500, 503-pub(in crate::service::fusionauth_client) async fn verify_email<'a>(+pub(crate) async fn verify_email<'a>(client: &AuthedClient,base_url: &str,verify_email_request: VerifyEmailRequest<'a>,