#[non_exhaustive]pub struct Jwk {
pub algorithm: Algorithm,
pub operations: HashSet<KeyOperation>,
pub material: KeyMaterial,
pub kid: Option<KeyId>,
pub scope: Option<Scope>,
}Expand description
JWK, almost to spec (https://datatracker.ietf.org/doc/html/rfc7517) but not quite the same because it’s annoying to implement.
This is the serialized form of a key, with plain fields you can build and edit. It is not
usable on its own: call import to validate it and get a usable Key, and
Key::export to go back the other way. What that key may do is whatever key_ops allows,
so a verify-only JWK imports fine and simply cannot sign.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.algorithm: AlgorithmThe algorithm used by the key.
operations: HashSet<KeyOperation>The permitted operations, defaulting to sign and verify when key_ops is absent
(optional per RFC 7517 section 4.3).
material: KeyMaterialThe key material. Defaults to KeyMaterial::OCT when kty is absent.
kid: Option<KeyId>The key ID, useful for rotating keys.
scope: Option<Scope>Optional authorization limits for tokens signed by this key.
Implementations§
Source§impl<'de> Jwk
impl<'de> Jwk
pub fn deserialize<__D>(__deserializer: __D) -> Result<Jwk, __D::Error>where
__D: Deserializer<'de>,
Source§impl Jwk
impl Jwk
Sourcepub fn new(algorithm: Algorithm, material: KeyMaterial) -> Self
pub fn new(algorithm: Algorithm, material: KeyMaterial) -> Self
A key that can both sign and verify, with no key ID or scope.
Set the remaining fields on the returned value. The struct is #[non_exhaustive], so
building it this way keeps working as JWK parameters are added.
Sourcepub fn import(self) -> Result<Key>
pub fn import(self) -> Result<Key>
Validate the parameters and import this as a usable Key.
The inverse of Key::export. Named rather than only a TryFrom impl so the conversion
is discoverable from here, and import/export rather than validate because the
validate methods elsewhere in this crate check without converting.