Run cargo fmt across all crates
All checks were successful
CI / Clippy (push) Successful in 2m55s
CI / Security Audit (push) Has been skipped
CI / Tests (push) Has been skipped
CI / Format (pull_request) Successful in 2s
CI / Format (push) Successful in 2s
CI / Clippy (pull_request) Successful in 2m54s
CI / Security Audit (pull_request) Has been skipped
CI / Tests (pull_request) Has been skipped

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sharang Parnerkar
2026-03-08 00:35:48 +01:00
parent daaa588fc3
commit f52f9fd65f
2 changed files with 7 additions and 11 deletions

View File

@@ -62,8 +62,7 @@ pub async fn require_jwt_auth(request: Request, next: Next) -> Response {
}
async fn validate_token(token: &str, state: &JwksState) -> Result<(), String> {
let header =
decode_header(token).map_err(|e| format!("failed to decode JWT header: {e}"))?;
let header = decode_header(token).map_err(|e| format!("failed to decode JWT header: {e}"))?;
let kid = header
.kid
@@ -77,8 +76,8 @@ async fn validate_token(token: &str, state: &JwksState) -> Result<(), String> {
.find(|k| k.common.key_id.as_deref() == Some(&kid))
.ok_or_else(|| "no matching key found in JWKS".to_string())?;
let decoding_key = DecodingKey::from_jwk(jwk)
.map_err(|e| format!("failed to create decoding key: {e}"))?;
let decoding_key =
DecodingKey::from_jwk(jwk).map_err(|e| format!("failed to create decoding key: {e}"))?;
let mut validation = Validation::new(header.alg);
validation.validate_exp = true;

View File

@@ -16,13 +16,10 @@ pub async fn start_api_server(agent: ComplianceAgent, port: u16) -> Result<(), A
.layer(CorsLayer::permissive())
.layer(TraceLayer::new_for_http());
if let (Some(kc_url), Some(kc_realm)) = (
&agent.config.keycloak_url,
&agent.config.keycloak_realm,
) {
let jwks_url = format!(
"{kc_url}/realms/{kc_realm}/protocol/openid-connect/certs"
);
if let (Some(kc_url), Some(kc_realm)) =
(&agent.config.keycloak_url, &agent.config.keycloak_realm)
{
let jwks_url = format!("{kc_url}/realms/{kc_realm}/protocol/openid-connect/certs");
let jwks_state = JwksState {
jwks: Arc::new(RwLock::new(None)),
jwks_url,