fn algs_for_key(
allowed: &[Algorithm],
kty: &str,
) -> Result<Vec<Algorithm>, String>Expand description
Narrows the configured algorithms to those a kty key can verify.
This is not an optimization — it is required for correctness. jsonwebtoken
validates the whole algorithm list against the key family before it even
looks at the token:
ⓘ
for alg in &validation.algorithms {
if key.family != alg.family() { return Err(InvalidAlgorithm); }
}So a list spanning two families can never verify anything. The default
token_signing_alg_values_expected spans RSA and EC, which meant every
JWKS-verified token — bearer tokens and interactive id_tokens alike — was
rejected with InvalidAlgorithm unless the operator happened to pin a single
family. Filtering per key keeps the permissive default working with whichever
key the IdP actually published.