pub struct Header {
pub algorithm: Algorithm,
pub key_id: Option<String>,
pub obj_type: Option<String>,
pub required_extensions: Option<Vec<String>>,
}Fields§
§algorithm: AlgorithmThe algorithm that this object is/will be signed with.
Corresponds to the alg header parameter.
key_id: Option<String>The type of the object that is encoded with this header.
Corresponds to the kid header parameter.
obj_type: Option<String>The type of the object that is encoded with this header.
Corresponds to the typ header parameter.
required_extensions: Option<Vec<String>>A list of parameters, i.e. field names, that the JWS implementation (i.e. jwt2) is
required to process.
Corresponds to the crit header parameter.
This is a field that jwt2 doesn’t really support yet, but it is left in for the sake of
being standards-compliant.
To validate this, use the Header::required_extensions function.
Implementations§
Source§impl Header
impl Header
pub fn new(algorithm: Algorithm) -> Self
pub fn recommended<R>(recommender: &R) -> Selfwhere
R: RecommendHeaderParams + ?Sized,
Sourcepub fn supports_required_extensions(&self) -> bool
pub fn supports_required_extensions(&self) -> bool
Checks if this library supports the required extensions.
§Implementation details
For now, this will return true if Self::required_extensions is Some.
This is standards-compliant and “correct” behaviour since if it returns true:
- the array is empty, which is not standards-compliant:
Producers MUST NOT use the empty list
[]as thecritvalue. - the array contains headers which are technically supported by
jwt2. At the moment,jwt2only supports header parameters that are specified by the JWS RFC or those specified by the JWA RFC.Recipients MAY consider the JWS to be invalid if the critical list contains any Header Parameter names defined by this specification or JWA for use with JWS or if any other constraints on its use are violated.
- the array specifies any parameter that
jwt2does not recognise, being the genuinely correct case.If any of the listed extension Header Parameters are not understood and supported by the recipient, then the JWS is invalid.
In the future, however, this function should properly check if the parameters are handled.