diff options
Diffstat (limited to 'Authentication/JWT.php')
-rw-r--r-- | Authentication/JWT.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Authentication/JWT.php b/Authentication/JWT.php index 7d6665b..161424b 100644 --- a/Authentication/JWT.php +++ b/Authentication/JWT.php @@ -119,17 +119,21 @@ class JWT * @param string $key The secret key * @param string $alg The signing algorithm. Supported * algorithms are 'HS256', 'HS384' and 'HS512' + * @param array $head An array with header elements to attach * * @return string A signed JWT * @uses jsonEncode * @uses urlsafeB64Encode */ - public static function encode($payload, $key, $alg = 'HS256', $keyId = null) + public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null) { $header = array('typ' => 'JWT', 'alg' => $alg); if ($keyId !== null) { $header['kid'] = $keyId; } + if ( isset($head) && is_array($head) ) { + $header = array_merge($head, $header); + } $segments = array(); $segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($header)); $segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($payload)); |