Skip to content

Commit 591bcb6

Browse files
authored
refactor: remove StaticJwksDiscovery for cached approach (#149)
1 parent 3f14cc2 commit 591bcb6

File tree

2 files changed

+4
-8
lines changed
  • crates

2 files changed

+4
-8
lines changed

crates/nebula-authority/src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use base64::{engine::general_purpose::STANDARD, Engine as _};
55
use clap::Parser;
66
use domain::authority::Authority;
77
use nebula_secret_sharing::shamir::Share;
8-
use nebula_token::auth::jwks_discovery::{fetch_jwks, CachedRemoteJwksDiscovery, JwksDiscovery, StaticJwksDiscovery};
8+
use nebula_token::auth::jwks_discovery::{CachedRemoteJwksDiscovery, JwksDiscovery};
99

1010
use crate::logger::LoggerConfig;
1111

@@ -40,9 +40,7 @@ async fn main() -> anyhow::Result<()> {
4040
CachedRemoteJwksDiscovery::new(app_config.jwks_url.clone(), Duration::from_secs(refresh_interval)).await?,
4141
)
4242
} else {
43-
let client = reqwest::Client::new();
44-
let jwks = fetch_jwks(&client, app_config.jwks_url.clone()).await?;
45-
Arc::new(StaticJwksDiscovery::new(jwks))
43+
Arc::new(CachedRemoteJwksDiscovery::new(app_config.jwks_url.clone(), Duration::from_secs(600)).await?)
4644
};
4745
let application = Application::new(authority, jwks_discovery);
4846
if let Some(key_shares) = &app_config.disarm_key_shares {

crates/nebula-backbone/src/application/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{sync::Arc, time::Duration};
22

3-
use nebula_token::auth::jwks_discovery::{fetch_jwks, CachedRemoteJwksDiscovery, JwksDiscovery, StaticJwksDiscovery};
3+
use nebula_token::auth::jwks_discovery::{CachedRemoteJwksDiscovery, JwksDiscovery};
44
use parameter::{ParameterUseCase, ParameterUseCaseImpl};
55
use sea_orm::{DatabaseConnection, TransactionTrait};
66

@@ -123,9 +123,7 @@ pub(super) async fn init(config: &ApplicationConfig) -> anyhow::Result<Applicati
123123
{
124124
Arc::new(CachedRemoteJwksDiscovery::new(config.jwks_url.clone(), Duration::from_secs(refresh_interval)).await?)
125125
} else {
126-
let client = reqwest::Client::new();
127-
let jwks = fetch_jwks(&client, config.jwks_url.clone()).await?;
128-
Arc::new(StaticJwksDiscovery::new(jwks))
126+
Arc::new(CachedRemoteJwksDiscovery::new(config.jwks_url.clone(), Duration::from_secs(600)).await?)
129127
};
130128

131129
database::migrate(database_connection.as_ref()).await?;

0 commit comments

Comments
 (0)