suweal/auth

Types

The payload structure for JWT authentication, containing standard claims and custom fields.

pub type Payload {
  Payload(
    issued_at: timestamp.Timestamp,
    not_valid_before: timestamp.Timestamp,
    expire_at: timestamp.Timestamp,
    issuer: String,
    jwt_id: String,
    namespace: String,
    database: String,
    access: String,
    id: String,
  )
}

Constructors

Values

pub fn generate_jwt(payload: Payload, key: key.Key) -> String

Generates a JWT token with the given payload and signs it using the provided key. It constructs the JWT header and payload, then signs the token to produce a JWT string.

pub fn verify_jwt(
  jwt: String,
  key: key.Key,
) -> Result(Payload, Nil)

Verifies a JWT string using the provided key. It checks the signature, extracts claims, and validates the token’s timing constraints.

✨ Search Document