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
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:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user