zio.blocks.jwt

package zio.blocks.jwt

Members list

Type members

Classlikes

sealed trait Algorithm extends Product, Serializable

A JWT signing algorithm as defined in RFC 7518.

A JWT signing algorithm as defined in RFC 7518.

Attributes

Companion
object
Source
Algorithm.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
object ES256
object ES384
object ES512
object EdDSA
object HS256
object HS384
object HS512
object PS256
object PS384
object PS512
object RS256
object RS384
object RS512
Show all
object Algorithm

Supported JWT algorithms. Use Algorithm.fromString to parse an alg header value.

Supported JWT algorithms. Use Algorithm.fromString to parse an alg header value.

Attributes

Companion
trait
Source
Algorithm.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Algorithm.type
object Base64Url

Attributes

Source
Base64Url.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Base64Url.type
case object BuildInfo

This object was generated by sbt-buildinfo.

This object was generated by sbt-buildinfo.

Attributes

Source
BuildInfo.scala
Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
BuildInfo.type

Attributes

Source
JvmJwtCryptoBackend.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object Jwt

Pure-Scala JWT implementation (RFC 7519).

Pure-Scala JWT implementation (RFC 7519).

==Minimal usage==

JvmJwtCryptoBackend.install()          // once at startup
val token = Jwt.sign(claims, key, Algorithm.HS256).getOrElse(throw new RuntimeException(...))
val claims = Jwt.decode(token, key, Algorithm.HS256).getOrElse(throw new RuntimeException(...))

Attributes

Source
Jwt.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Jwt.type
sealed trait JwtAudience extends Product, Serializable

Attributes

Companion
object
Source
JwtAudience.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class Multiple
class Single
object JwtAudience

Attributes

Companion
trait
Source
JwtAudience.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
object JwtClaims

Attributes

Companion
class
Source
JwtClaims.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
JwtClaims.type
case class JwtClaims(iss: Option[String] = ..., sub: Option[String] = ..., aud: Option[JwtAudience] = ..., exp: Option[Long] = ..., nbf: Option[Long] = ..., iat: Option[Long] = ..., jti: Option[String] = ..., extra: Map[String, JwtValue] = ...)

The set of claims carried inside a JWT payload.

The set of claims carried inside a JWT payload.

Registered claim names follow RFC 7519 §4.1. Additional application-defined claims are collected in extra, preserving their original JSON value type as JwtValue.

NumericDate claims (exp, nbf, iat) accept integer and fractional/exponent JSON numbers. Fractional values are deterministically truncated toward zero (floor for non-negative values) to seconds. Non-finite, negative, or out-of-range values are rejected.

Use the methods on JwtClaims to deserialise and serialise.

Attributes

Companion
object
Source
JwtClaims.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object JwtCrypto

Global registry for the active JwtCryptoBackend.

Global registry for the active JwtCryptoBackend.

Call JvmJwtCryptoBackend.install() (JVM) or JsJwtCryptoBackend.install() (JS) once at application startup. Until then the default backend handles HMAC algorithms only.

Attributes

Source
Jwt.scala
Supertypes
class Object
trait Matchable
class Any
Self type
JwtCrypto.type

Platform-specific cryptographic operations for JWT.

Platform-specific cryptographic operations for JWT.

Call install() on a platform backend (e.g. JvmJwtCryptoBackend.install()) before signing or verifying tokens. The default backend (the built-in shared backend) supports HMAC-SHA2 algorithms only and requires no native dependencies.

Attributes

Source
Jwt.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
class
Source
Jwt.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class JwtDecodeOptions(clockSkewSeconds: Long = ..., issuer: Option[String] = ..., expectedAudience: Option[String] = ..., backend: Option[JwtCryptoBackend] = ..., nowSeconds: Option[Long] = ..., limits: JwtLimits = ...)

Options for authenticated JWT decoding.

Options for authenticated JWT decoding.

This is the source-compatible configuration value that groups optional parameters instead of adding many positional arguments. Existing call sites that use decode(token,key,alg,clockSkew,issuer) continue to work via the legacy overload which delegates to this options type.

Audience validation follows RFC 7519 §4.1.3 receiver contract: when expectedAudience is set, the token's aud claim must be present and contain the expected value (string match for single aud, membership for array aud). Missing aud yields MissingClaim("aud"); mismatch yields InvalidToken.

Value parameters

backend

explicit crypto backend to use for this operation; defaults to JwtCrypto.backend snapshot

clockSkewSeconds

allowable clock skew in seconds for exp/nbf validation

expectedAudience

if set, the aud claim must contain this audience

issuer

if set, the iss claim must match exactly

limits

resource limits for token/JSON parsing

nowSeconds

explicit current time in seconds since epoch for exp/nbf validation; defaults to System.currentTimeMillis()/1000

Attributes

Companion
object
Source
Jwt.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object JwtError

Attributes

Companion
trait
Source
JwtError.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
JwtError.type
sealed trait JwtError extends NoStackTrace

A failure that can occur during JWT signing or decoding.

A failure that can occur during JWT signing or decoding.

All subtypes extend scala.util.control.NoStackTrace to avoid capturing a stack trace on the hot decoding path.

Attributes

Companion
object
Source
JwtError.scala
Supertypes
trait NoStackTrace
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes
case class JwtHeader(alg: Algorithm, typ: String = ..., kid: Option[String] = ...)

Attributes

Companion
object
Source
JwtHeader.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object JwtHeader

Attributes

Companion
class
Source
JwtHeader.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
JwtHeader.type
final case class JwtLimits(maxTokenChars: Int = ..., maxSegmentChars: Int = ..., maxJsonChars: Int = ..., maxDepth: Int = ..., maxFields: Int = ..., maxArrayElements: Int = ...)

Conservative resource limits for JWT parsing and token validation.

Conservative resource limits for JWT parsing and token validation.

All limits are checked before allocation where possible.

Value parameters

maxArrayElements

maximum number of elements in a single JSON array

maxDepth

maximum nesting depth for JSON objects/arrays (root is depth 1)

maxFields

maximum number of fields in a single JSON object

maxJsonChars

maximum length of decoded JSON (header or payload) in characters

maxSegmentChars

maximum length of a single Base64Url segment (header/payload/signature)

maxTokenChars

maximum total compact token length in characters

Attributes

Companion
object
Source
Jwt.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object JwtLimits

Attributes

Companion
class
Source
Jwt.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
JwtLimits.type
final case class JwtSignOptions(backend: Option[JwtCryptoBackend] = ..., limits: JwtLimits = ...)

Options for JWT signing.

Options for JWT signing.

Value parameters

backend

explicit crypto backend to use for this operation; defaults to JwtCrypto.backend snapshot

limits

resource limits for header JSON validation

Attributes

Companion
object
Source
Jwt.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Source
Jwt.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object JwtValue

Attributes

Companion
trait
Source
JwtValue.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
JwtValue.type
sealed trait JwtValue extends Product, Serializable

Public JSON value ADT for JWT custom claims.

Public JSON value ADT for JWT custom claims.

Mirrors JSON value kinds: string, number, boolean, null, array, object. Numbers preserve their original JSON text to avoid loss of precision or formatting. Nested objects and arrays are fully supported; no values are silently dropped during parsing.

Attributes

Companion
object
Source
JwtValue.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class Arr
class Bool
object Null
class Num
class Obj
class Str
Show all