integrate axum_oidc api changes

This commit is contained in:
Paul Zinselmeyer 2023-04-21 23:32:11 +02:00
parent e08fa51637
commit 3024f344b0
Signed by: pfzetto
GPG key ID: 4EEF46A5B276E648
2 changed files with 18 additions and 23 deletions

7
Cargo.lock generated
View file

@ -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"

View file

@ -65,24 +65,13 @@ impl IntoResponse for Error {
pub struct AppState {
path: String,
application_base: String,
issuer: String,
client_id: String,
client_secret: Option<String>,
scopes: Vec<String>,
oidc_application: OidcApplication<EmptyAdditionalClaims>,
expire: Arc<Mutex<BTreeMap<NaiveDateTime, String>>>,
key: Key,
}
impl FromRef<AppState> for OidcApplication {
impl FromRef<AppState> for OidcApplication<EmptyAdditionalClaims> {
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::<EmptyAdditionalClaims>::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 });