Crate biscuit [] [src]

Build Status Dependency Status Crates.io Repository Documentation

A library to work with Javascript Object Signing and Encryption(JOSE), including JSON Web Tokens (JWT), JSON Web Signature (JWS) and JSON Web Encryption (JWE)

This was based off Keats/rust-jwt.

Installation

Add the following to Cargo.toml:

biscuit = "0.0.4"

To use the latest master branch, for example:

biscuit = { git = "https://github.com/lawliet89/biscuit", branch = "master" }

See [JWT] for common usage examples.

Supported Features

The crate does not support all, and probably will never support all of the features described in the various RFCs, including some algorithms and verification.

See the documentation for more information.

References

RFCs

Modules

errors

Errors returned will be converted to one of the structs in this module.

jwa

JSON Web Algorithms

jwe

JSON Web Encryption

jwk

JSON Web Key

jws

JSON Web Signatures, including JWT signing and headers

Structs

Base64Url

A newtype wrapper around a string to indicate it's base64 URL encoded

ClaimsSet

A collection of claims, both registered and your custom private claims.

Compact

A collection of CompactParts that have been converted to Base64Url

Empty

An empty struct that derives Serialize and Deserialize. Can be used, for example, in places where a type for custom values (such as private claims in a ClaimsSet) is required but you have nothing to implement.

RegisteredClaims

Registered claims defined by RFC7519#4.1

TemporalValidationOptions

Options for claims time validation By default, no temporal claims (namely iat, exp, nbf) are required, and they will pass validation if they are missing. Should any temporal claims be needed, set the appropriate fields. To deal with clock drifts, you might want to provide an epsilon error margin in the form of a std::time::Duration to allow time comparisons to fall within the margin.

Timestamp

Wrapper around DateTime<UTC> to allow us to do custom de(serialization)

Url

A parsed URL record.

Enums

ParseError

Errors that can occur during parsing.

SingleOrMultiple

Represents a choice between a single value or multiple values. This value is serialized by serde untagged.

StringOrUri

Represents a choice between a URI or an arbitrary string. Both variants will serialize to a string. According to RFC 7519, any string containing the ":" character will be deserialized as a URL. Any invalid URLs will be treated as a deserialization failure. The URL is parsed according to the URL Standard which supersedes RFC 3986 as required in the JWT RFC.

Traits

CompactJson

A marker trait that indicates that the object is to be serialized to JSON and deserialized from JSON. This is primarily used in conjunction with the CompactPart trait which will serialize structs to JSON before base64 encoding, and vice-versa.

CompactPart

A "part" of the compact representation of JWT/JWS/JWE. Parts are first serialized to some form and then base64 encoded and separated by periods.

Type Definitions

JWE

A convenience type alias of a "JWE" which is a compact JWE that contains a signed/unsigned compact JWS.

JWT

A convenience type alias of the common "JWT" which is a secured/unsecured compact JWS. Type T is the type of the private claims, and type H is the type of private header fields