The Settings Object - fachsimpeln/EasyJWT GitHub Wiki

Description

The options for the JWT are saved in this object. It contains the signature algorithm, it provides the header and contains the reserved claims object.

This object is optional, if you don't define it, it will be automatically created with the default settings.

Parameters

The JWTOptions constructor accepts an optional string for the algorithm, an optional JWTReservedClaims object, an optional allow private claims option and that's it.

JWTOptions::__construct( string $jwt_algorithm = "HS256",  $jwt_reserved_claims = null, boolean $allow_private_claims = true )
Parameter Description
$jwt_algorithm The algorithm to use for signing
$jwt_reserved_claims JWTReservedClaims object which contains all reserved claims
$allow_private_claims Restricts claim names to those specified in the IANA JSON Web Token Registry when set to false

The default value is HS256, allow private claims and only the IAT (issued at) reserved claim.

Supported Algorithms

Signing Algorithm What is this?
HS256 HMAC-SHA256
HS384 HMAC-SHA384
HS512 HMAC-SHA512
none not recommended

Example

Instead of the default algorithm HS256, let's use HS512:

$jwt_options = new EasyJWT\JWTOptions('HS512');