Struct jwt_compact::Header [−][src]
#[non_exhaustive]pub struct Header {
pub key_set_url: Option<String>,
pub key_id: Option<String>,
pub certificate_url: Option<String>,
pub certificate_sha1_thumbprint: Option<[u8; 20]>,
pub certificate_thumbprint: Option<[u8; 32]>,
pub token_type: Option<String>,
}
Expand description
JWT header.
See RFC 7515 for the description
of the fields. The purpose of all fields except token_type
is to determine
the verifying key. Since these values will be provided by the adversary in the case of
an attack, they require additional verification (e.g., a provided certificate might
be checked against the list of “acceptable” certificate authorities).
A Header
can be created using Default
implementation, which does not set any fields.
For added fluency, you may use with_*
methods:
use sha2::{digest::Digest, Sha256};
let my_key_cert = // DER-encoded key certificate
let header = Header::default()
.with_key_id("my-key-id")
.with_certificate_thumbprint(Sha256::digest(my_key_cert).into());
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.key_set_url: Option<String>
URL of the JSON Web Key Set containing the key that has signed the token.
This field is renamed to jku
for serialization.
key_id: Option<String>
Identifier of the key that has signed the token. This field is renamed to kid
for serialization.
certificate_url: Option<String>
URL of the X.509 certificate for the signing key. This field is renamed to x5u
for serialization.
certificate_sha1_thumbprint: Option<[u8; 20]>
SHA-1 thumbprint of the X.509 certificate for the signing key.
This field is renamed to x5t
for serialization.
certificate_thumbprint: Option<[u8; 32]>
SHA-256 thumbprint of the X.509 certificate for the signing key.
This field is renamed to x5t#S256
for serialization.
token_type: Option<String>
Application-specific token type. This field is renamed to typ
for serialization.
Implementations
Sets the key_set_url
field for this header.
Sets the key_id
field for this header.
Sets the certificate_url
field for this header.
Sets the certificate_sha1_thumbprint
field for this header.
Sets the certificate_thumbprint
field for this header.
Sets the token_type
field for this header.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Header
impl UnwindSafe for Header
Blanket Implementations
Mutably borrows from an owned value. Read more