use mas_iana::jose::{
JsonWebKeyEcEllipticCurve, JsonWebKeyOperation, JsonWebKeyType, JsonWebKeyUse,
JsonWebSignatureAlg,
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use url::Url;
use crate::{
base64::{Base64, Base64UrlNoPad},
constraints::{Constrainable, Constraint, ConstraintSet},
};
pub(crate) mod private_parameters;
pub(crate) mod public_parameters;
use self::private_parameters::SymetricKeyError;
pub use self::{
private_parameters::JsonWebKeyPrivateParameters, public_parameters::JsonWebKeyPublicParameters,
};
pub trait ParametersInfo {
fn kty(&self) -> JsonWebKeyType;
fn possible_algs(&self) -> &[JsonWebSignatureAlg];
}
trait JwkEcCurve {
const CRV: JsonWebKeyEcEllipticCurve;
}
impl JwkEcCurve for p256::NistP256 {
const CRV: JsonWebKeyEcEllipticCurve = JsonWebKeyEcEllipticCurve::P256;
}
impl JwkEcCurve for p384::NistP384 {
const CRV: JsonWebKeyEcEllipticCurve = JsonWebKeyEcEllipticCurve::P384;
}
impl JwkEcCurve for k256::Secp256k1 {
const CRV: JsonWebKeyEcEllipticCurve = JsonWebKeyEcEllipticCurve::Secp256K1;
}
#[skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct JsonWebKey<P> {
#[serde(flatten)]
parameters: P,
#[serde(default)]
r#use: Option<JsonWebKeyUse>,
#[serde(default)]
key_ops: Option<Vec<JsonWebKeyOperation>>,
#[serde(default)]
alg: Option<JsonWebSignatureAlg>,
#[serde(default)]
kid: Option<String>,
#[schemars(with = "Option<String>")]
#[serde(default)]
x5u: Option<Url>,
#[schemars(with = "Vec<String>")]
#[serde(default)]
x5c: Option<Vec<Base64>>,
#[schemars(with = "Option<String>")]
#[serde(default)]
x5t: Option<Base64UrlNoPad>,
#[schemars(with = "Option<String>")]
#[serde(default, rename = "x5t#S256")]
x5t_s256: Option<Base64UrlNoPad>,
}
pub type PublicJsonWebKey = JsonWebKey<self::public_parameters::JsonWebKeyPublicParameters>;
pub type PrivateJsonWebKey = JsonWebKey<self::private_parameters::JsonWebKeyPrivateParameters>;
impl TryFrom<PrivateJsonWebKey> for PublicJsonWebKey {
type Error = SymetricKeyError;
fn try_from(value: PrivateJsonWebKey) -> Result<Self, Self::Error> {
value.try_map(JsonWebKeyPublicParameters::try_from)
}
}
impl<P> JsonWebKey<P> {
#[must_use]
pub const fn new(parameters: P) -> Self {
Self {
parameters,
r#use: None,
key_ops: None,
alg: None,
kid: None,
x5u: None,
x5c: None,
x5t: None,
x5t_s256: None,
}
}
pub fn try_map<M, O, E>(self, mapper: M) -> Result<JsonWebKey<O>, E>
where
M: FnOnce(P) -> Result<O, E>,
{
Ok(JsonWebKey {
parameters: mapper(self.parameters)?,
r#use: self.r#use,
key_ops: self.key_ops,
alg: self.alg,
kid: self.kid,
x5u: self.x5u,
x5c: self.x5c,
x5t: self.x5t,
x5t_s256: self.x5t_s256,
})
}
pub fn map<M, O>(self, mapper: M) -> JsonWebKey<O>
where
M: FnOnce(P) -> O,
{
JsonWebKey {
parameters: mapper(self.parameters),
r#use: self.r#use,
key_ops: self.key_ops,
alg: self.alg,
kid: self.kid,
x5u: self.x5u,
x5c: self.x5c,
x5t: self.x5t,
x5t_s256: self.x5t_s256,
}
}
pub fn try_cloned_map<M, O, E>(&self, mapper: M) -> Result<JsonWebKey<O>, E>
where
M: FnOnce(&P) -> Result<O, E>,
{
Ok(JsonWebKey {
parameters: mapper(&self.parameters)?,
r#use: self.r#use.clone(),
key_ops: self.key_ops.clone(),
alg: self.alg.clone(),
kid: self.kid.clone(),
x5u: self.x5u.clone(),
x5c: self.x5c.clone(),
x5t: self.x5t.clone(),
x5t_s256: self.x5t_s256.clone(),
})
}
pub fn cloned_map<M, O>(&self, mapper: M) -> JsonWebKey<O>
where
M: FnOnce(&P) -> O,
{
JsonWebKey {
parameters: mapper(&self.parameters),
r#use: self.r#use.clone(),
key_ops: self.key_ops.clone(),
alg: self.alg.clone(),
kid: self.kid.clone(),
x5u: self.x5u.clone(),
x5c: self.x5c.clone(),
x5t: self.x5t.clone(),
x5t_s256: self.x5t_s256.clone(),
}
}
#[must_use]
pub fn with_use(mut self, value: JsonWebKeyUse) -> Self {
self.r#use = Some(value);
self
}
#[must_use]
pub fn with_key_ops(mut self, key_ops: Vec<JsonWebKeyOperation>) -> Self {
self.key_ops = Some(key_ops);
self
}
#[must_use]
pub fn with_alg(mut self, alg: JsonWebSignatureAlg) -> Self {
self.alg = Some(alg);
self
}
#[must_use]
pub fn with_kid(mut self, kid: impl Into<String>) -> Self {
self.kid = Some(kid.into());
self
}
#[must_use]
pub const fn alg(&self) -> Option<&JsonWebSignatureAlg> {
self.alg.as_ref()
}
#[must_use]
pub const fn params(&self) -> &P {
&self.parameters
}
}
impl<P> Constrainable for JsonWebKey<P>
where
P: ParametersInfo,
{
fn kid(&self) -> Option<&str> {
self.kid.as_deref()
}
fn kty(&self) -> JsonWebKeyType {
self.parameters.kty()
}
fn algs(&self) -> &[JsonWebSignatureAlg] {
self.parameters.possible_algs()
}
fn alg(&self) -> Option<&JsonWebSignatureAlg> {
self.alg.as_ref()
}
fn use_(&self) -> Option<&JsonWebKeyUse> {
self.r#use.as_ref()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct JsonWebKeySet<P> {
keys: Vec<JsonWebKey<P>>,
}
impl<P> Default for JsonWebKeySet<P> {
fn default() -> Self {
Self {
keys: Vec::default(),
}
}
}
pub type PublicJsonWebKeySet = JsonWebKeySet<self::public_parameters::JsonWebKeyPublicParameters>;
pub type PrivateJsonWebKeySet =
JsonWebKeySet<self::private_parameters::JsonWebKeyPrivateParameters>;
impl From<PrivateJsonWebKeySet> for PublicJsonWebKeySet {
fn from(value: PrivateJsonWebKeySet) -> Self {
let keys = value
.keys
.into_iter()
.filter_map(|key: PrivateJsonWebKey| key.try_into().ok())
.collect();
Self { keys }
}
}
impl<P> std::ops::Deref for JsonWebKeySet<P> {
type Target = Vec<JsonWebKey<P>>;
fn deref(&self) -> &Self::Target {
&self.keys
}
}
impl<P> JsonWebKeySet<P> {
#[must_use]
pub fn new(keys: Vec<JsonWebKey<P>>) -> Self {
Self { keys }
}
#[must_use]
pub fn find_key(&self, constraints: &ConstraintSet) -> Option<&JsonWebKey<P>>
where
P: ParametersInfo,
{
constraints.filter(&self.keys).pop()
}
#[must_use]
pub fn find_keys(&self, constraints: &ConstraintSet) -> Vec<&JsonWebKey<P>>
where
P: ParametersInfo,
{
constraints.filter(&self.keys)
}
#[must_use]
pub fn signing_key_for_algorithm(&self, alg: &JsonWebSignatureAlg) -> Option<&JsonWebKey<P>>
where
P: ParametersInfo,
{
let constraints = ConstraintSet::new([
Constraint::alg(alg),
Constraint::use_(&mas_iana::jose::JsonWebKeyUse::Sig),
]);
self.find_key(&constraints)
}
#[must_use]
pub fn available_signing_algorithms(&self) -> Vec<JsonWebSignatureAlg>
where
P: ParametersInfo,
{
let mut algs: Vec<_> = self
.keys
.iter()
.flat_map(|key| key.params().possible_algs())
.cloned()
.collect();
algs.sort();
algs.dedup();
algs
}
}
impl<P> FromIterator<JsonWebKey<P>> for JsonWebKeySet<P> {
fn from_iter<T: IntoIterator<Item = JsonWebKey<P>>>(iter: T) -> Self {
let keys = iter.into_iter().collect();
Self { keys }
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::constraints::ConstraintSet;
#[test]
fn load_google_keys() {
let jwks = serde_json::json!({
"keys": [
{
"alg": "RS256",
"kty": "RSA",
"n": "tCwhHOxX_ylh5kVwfVqW7QIBTIsPjkjCjVCppDrynuF_3msEdtEaG64eJUz84ODFNMCC0BQ57G7wrKQVWkdSDxWUEqGk2BixBiHJRWZdofz1WOBTdPVicvHW5Zl_aIt7uXWMdOp_SODw-O2y2f05EqbFWFnR2-1y9K8KbiOp82CD72ny1Jbb_3PxTs2Z0F4ECAtTzpDteaJtjeeueRjr7040JAjQ-5fpL5D1g8x14LJyVIo-FL_y94NPFbMp7UCi69CIfVHXFO8WYFz949og-47mWRrID5lS4zpx-QLuvNhUb_lSqmylUdQB3HpRdOcYdj3xwy4MHJuu7tTaf0AmCQ",
"use": "sig",
"kid": "d98f49bc6ca4581eae8dfadd494fce10ea23aab0",
"e": "AQAB"
},
{
"use": "sig",
"kty": "RSA",
"kid": "03e84aed4ef4431014e8617567864c4efaaaede9",
"n": "ma2uRyBeSEOatGuDpCiV9oIxlDWix_KypDYuhQfEzqi_BiF4fV266OWfyjcABbam59aJMNvOnKW3u_eZM-PhMCBij5MZ-vcBJ4GfxDJeKSn-GP_dJ09rpDcILh8HaWAnPmMoi4DC0nrfE241wPISvZaaZnGHkOrfN_EnA5DligLgVUbrA5rJhQ1aSEQO_gf1raEOW3DZ_ACU3qhtgO0ZBG3a5h7BPiRs2sXqb2UCmBBgwyvYLDebnpE7AotF6_xBIlR-Cykdap3GHVMXhrIpvU195HF30ZoBU4dMd-AeG6HgRt4Cqy1moGoDgMQfbmQ48Hlunv9_Vi2e2CLvYECcBw",
"e": "AQAB",
"alg": "RS256"
}
]
});
let jwks: PublicJsonWebKeySet = serde_json::from_value(jwks).unwrap();
for jwk in &jwks.keys {
let p = jwk.params().rsa().expect("an RSA key");
rsa::RsaPublicKey::try_from(p).unwrap();
}
let constraints = ConstraintSet::default()
.use_(&JsonWebKeyUse::Sig)
.kty(&JsonWebKeyType::Rsa)
.alg(&JsonWebSignatureAlg::Rs256);
let candidates = constraints.filter(&jwks.keys);
assert_eq!(candidates.len(), 2);
let constraints = ConstraintSet::default()
.use_(&JsonWebKeyUse::Sig)
.kty(&JsonWebKeyType::Rsa)
.kid("03e84aed4ef4431014e8617567864c4efaaaede9");
let candidates = constraints.filter(&jwks.keys);
assert_eq!(candidates.len(), 1);
}
#[allow(clippy::too_many_lines)]
#[test]
fn load_keycloak_keys() {
let jwks = serde_json::json!({
"keys": [
{
"kid": "SuGUPE9Sr-1Gha2NLse33r5NQu3XoS_I3Qds3bcmfQE",
"kty": "RSA",
"alg": "RS256",
"use": "sig",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H3fPX1prWOic5x46Bu7IqoEqZtDszt8F+uteruRsHVHCiWx5dW7goeIa8YsUK0A4mnOy5kViSvs5L6Kq0N5uCB9EDu/Ew5R0/mi/UTm5L8CpzQig1pmvDtIy7ZnosHu7zYGSQiR04jn3Od0rdWzTCcs8W79+ewgJ0bdYmfvSnVehs1BR+cjivzBqMWMqdyz6eQXCy/esiG5KDIxH4F0HGLiiwXqHUYjJPex8TId+fz0MFScrEN5fjE+XltGzsPwlcgnAqE0pN0ExJSHwzBHNkJJQpjHrsEurWn9QGBqD75Vt9yVeHE8MZ4zMGj3ZkRmn1x6wVBdv1V12P3e4b8V5aG02FbREkJzFTXtGyDHtw/hlWGz9M9w0c5TAI6xYPa1gS6/Fw95J6S0V3n3JH+xqi6yv2H2cQHukFxFSPJW1cc/hh5DJ4Ag8+pKuO1Vdo9p+DltaGLWBabON7GZZojlYdx2WtBZK9CMRgrxobg+OBA44AHkiWkhflrqGLYul866wiNu6zLEfdQ=="
],
"x5t": "0lMdqEAhOWfUXDivtS-KwPvwKNY",
"x5t#S256": "aOjQ1awJmcaF7Yiz75ifjBKbjr4Eo-Ha5uNMi-TtuGw"
},
{
"kid": "VlsIs1LssBo6r8EuXJo81rDEoTYpUjiMkeq_PlapKfY",
"kty": "EC",
"alg": "ES256",
"use": "sig",
"crv": "P-256",
"x": "3kqy7us0mepJJblWwj0Exg2S7PtWaJvB7SI_ptg0jrA",
"y": "S5Z8d4AfCvRL-hUd6Pv-L3tH6H9T4RIwO2tvBS0hj1A"
},
{
"kid": "1yWLiqf8sa-em0hSbtZEjKmrardmQdYLR9gpzsypMCU",
"kty": "EC",
"alg": "ES384",
"use": "sig",
"crv": "P-384",
"x": "i4YYGQZd5QQ1JpUXcrZe5wpCid3pqFLnzxxy89Chn-NQ1oYDPTP2M8V9sfazeuB0",
"y": "xf4qN2ZuMLVh4GmRVt1PHhQooB2o61pF0lHrBlIod5hVamiRtUo_Np9PikPD8Uap"
},
{
"kid": "V5EwcLp9vmwAnstzI1Ndba-iWkX5oTBHK7GnYTyfuOE",
"kty": "EC",
"alg": "ES512",
"use": "sig",
"crv": "P-521",
"x": "rScgdd_n2cHLyzZvP8zw0u9vQyhu0VsbfQypheS7aDoHRLcXccPQTsmrQLrLuKX8PPkITjL_BJDSm7Bo8gv5Sd4",
"y": "Vu3rTFNn_9zWTki95UGT1Bd9PN84KDXmttCrJ1bsYHTWQCaEONk8iwA3U6mEDrg4xtZSTXXKCFdFP13ONWB9oZ4"
}
]
});
let jwks: PublicJsonWebKeySet = serde_json::from_value(jwks).unwrap();
let mut keys = jwks.keys.into_iter();
rsa::RsaPublicKey::try_from(keys.next().unwrap().params().rsa().unwrap()).unwrap();
rsa::RsaPublicKey::try_from(keys.next().unwrap().params().rsa().unwrap()).unwrap();
rsa::RsaPublicKey::try_from(keys.next().unwrap().params().rsa().unwrap()).unwrap();
rsa::RsaPublicKey::try_from(keys.next().unwrap().params().rsa().unwrap()).unwrap();
rsa::RsaPublicKey::try_from(keys.next().unwrap().params().rsa().unwrap()).unwrap();
rsa::RsaPublicKey::try_from(keys.next().unwrap().params().rsa().unwrap()).unwrap();
elliptic_curve::PublicKey::<p256::NistP256>::try_from(
keys.next().unwrap().params().ec().unwrap(),
)
.unwrap();
elliptic_curve::PublicKey::<p384::NistP384>::try_from(
keys.next().unwrap().params().ec().unwrap(),
)
.unwrap();
keys.next().unwrap().params().ec().unwrap();
}
}