Try to validate a Bearer token as a JWT via the JWKS registry. Returns `Some(identity)` if the token is a valid JWT with 2 dots and the registry verifies the signature. Returns `None` otherwise.
(state: &AppState, token: &str)
| 31 | /// Returns `Some(identity)` if the token is a valid JWT with 2 dots and |
| 32 | /// the registry verifies the signature. Returns `None` otherwise. |
| 33 | fn try_validate_jwt(state: &AppState, token: &str) -> Option<AuthenticatedIdentity> { |
| 34 | if token.matches('.').count() == 2 |
| 35 | && let Some(ref registry) = state.shared.jwks_registry |
| 36 | && let Ok(identity) = tokio::runtime::Handle::current().block_on(registry.validate(token)) |
| 37 | { |
| 38 | Some(identity) |
| 39 | } else { |
| 40 | None |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /// Resolve an authenticated identity from HTTP headers. |
| 45 | /// |
no test coverage detected