diff --git a/Cargo.lock b/Cargo.lock index c448b70..43dc774 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,12 +161,11 @@ dependencies = [ [[package]] name = "axum_oidc" version = "0.1.0" -source = "git+https://git.zettoit.eu/pfz4/axum_oidc#75ed3b861a85cd18d8473a65cc6a90bc38528527" +source = "git+https://git.zettoit.eu/pfz4/axum_oidc#428399951cc2d70a2bf5f0f4e8a84cf7cc142feb" dependencies = [ "async-trait", "axum", "axum-extra", - "cookie", "openidconnect", "reqwest", "serde", @@ -235,9 +234,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" [[package]] name = "byteorder" diff --git a/src/main.rs b/src/main.rs index 09eb25e..42671c4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,24 +65,13 @@ impl IntoResponse for Error { pub struct AppState { path: String, application_base: String, - issuer: String, - client_id: String, - client_secret: Option, - scopes: Vec, + oidc_application: OidcApplication, expire: Arc>>, - key: Key, } -impl FromRef for OidcApplication { +impl FromRef for OidcApplication { fn from_ref(input: &AppState) -> Self { - OidcApplication::new( - input.application_base.to_string(), - input.issuer.to_string(), - input.client_id.to_string(), - input.client_secret.to_owned(), - input.scopes.clone(), - input.key.clone(), - ) + input.oidc_application.clone() } } @@ -107,15 +96,22 @@ async fn main() { load_expire("data", &mut expire).await; } + let oidc_application = OidcApplication::::create( + application_base.parse().unwrap(), + issuer.to_string(), + client_id.to_string(), + client_secret.to_owned(), + scopes.clone(), + Key::generate(), + ) + .await + .unwrap(); + let state: AppState = AppState { path: "data".to_string(), application_base, - issuer, - client_id, - client_secret, - scopes, + oidc_application, expire: expire.clone(), - key: Key::generate(), }; tokio::spawn(async move { expire_thread("data".to_string(), expire).await });