Enum biscuit::jws::Compact [] [src]

pub enum Compact<T, H> {
    Decoded {
        header: Header<H>,
        payload: T,
    },
    Encoded(Compact),
}

Compact representation of a JWS

This representation contains a payload (type T) (e.g. a claims set) and is (optionally) signed. This is the most common form of tokens used. The JWS can contain additional header fields provided by type H.

Serialization/deserialization is handled by serde. Before you transport the token, make sure you turn it into the encoded form first.

Examples

Signing and verifying a JWT with HS256

See an example in the biscuit::JWT type alias.

Variants

Decoded form of the JWS. This variant cannot be serialized or deserialized and will return an error.

Fields of Decoded

Embedded header

Payload, usually a claims set

Encoded and (optionally) signed JWT. Use this form to send to your clients

Methods

impl<T, H> Compact<T, H> where
    T: CompactPart,
    H: Serialize + DeserializeOwned
[src]

[src]

New decoded JWT

[src]

New encoded JWT

[src]

Consumes self and convert into encoded form. If the token is already encoded, this is a no-op.

[src]

Encode the JWT passed and sign the payload using the algorithm from the header and the secret The secret is dependent on the signing algorithm

[src]

Consumes self and convert into decoded form, verifying the signature, if any. If the token is already decoded, this is a no-op

[src]

Decode a token into the JWT struct and verify its signature If the token or its signature is invalid, it will return an error

[src]

Convenience method to get a reference to the encoded string from an encoded compact JWS

[src]

Convenience method to get a mutable reference to the encoded string from an encoded compact JWS

[src]

Convenience method to get a reference to the claims set from a decoded compact JWS

[src]

Convenience method to get a reference to the claims set from a decoded compact JWS

[src]

Convenience method to get a reference to the header from a decoded compact JWS

[src]

Convenience method to get a reference to the header from a decoded compact JWS

[src]

Consumes self, and move the payload and header out and return them as a tuple

Panics

Panics if the JWS is not decoded

[src]

Consumes self, and move the encoded Compact out and return it

Panics

Panics if the JWS is not encoded

[src]

Without decoding and verifying the JWS, retrieve a copy of the header.

Warning

Use this at your own risk. It is not advisable to trust unverified content.

[src]

Without decoding and verifying the JWS, retrieve a copy of the payload.

Warning

Use this at your own risk. It is not advisable to trust unverified content.

[src]

Get a copy of the signature

impl<P, H> Compact<ClaimsSet<P>, H> where
    ClaimsSet<P>: CompactPart,
    H: Serialize + DeserializeOwned
[src]

Convenience implementation for a Compact that contains a ClaimsSet

[src]

Validate the temporal claims in the decoded token

If None is provided for options, the defaults will apply.

By default, no temporal claims (namely iat, exp, nbf) are required, and they will pass validation if they are missing.

Trait Implementations

impl<T: Clone, H: Clone> Clone for Compact<T, H>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: Debug, H: Debug> Debug for Compact<T, H>
[src]

[src]

Formats the value using the given formatter.

impl<T: Eq, H: Eq> Eq for Compact<T, H>
[src]

impl<T: PartialEq, H: PartialEq> PartialEq for Compact<T, H>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<T: CompactPart, H: Serialize + DeserializeOwned> CompactPart for Compact<T, H>
[src]

Implementation for embedded inside a JWE.

[src]

Convert this part into bytes

[src]

Convert a sequence of bytes into Self

[src]

Base64 decode into Self

[src]

Serialize Self to some form and then base64URL Encode