Claims

public protocol Claims: Codable

A protocol for representing the claims on a JSON web token. https://tools.ietf.org/html/rfc7519#section-4.1

Usage Example:

struct AdminClaims: Claims {
    var sub: String
    var isAdmin: Bool
    var exp: Date?
}
 let jwt = JWT(claims: AdminClaims(sub: "Kitura", isAdmin: true, exp: Date(timeIntervalSinceNow: 3600)))
  • exp Default implementation

    The exp (expiration time) claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing. The processing of the exp claim requires that the current date/time MUST be before the expiration date/time listed in the exp claim. Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew.

    Default Implementation

    Declaration

    Swift

    var exp: Date?
  • nbf Default implementation

    The nbf (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. The processing of the nbf claim requires that the current date/time MUST be after or equal to the not-before date/time listed in the nbf claim. Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew.

    Default Implementation

    Declaration

    Swift

    var nbf: Date?
  • iat Default implementation

    The iat (issued at) claim identifies the time at which the JWT was issued. This claim can be used to determine the age of the JWT.

    Default Implementation

    Declaration

    Swift

    var iat: Date?
  • encode() Default implementation

    Encode the Claim object as a Base64 String.

    Default Implementation

    Declaration

    Swift

    func encode() throws -> String