PHP 클래스 JWT

PHP version 5
저자: Neuman Vong ([email protected])
저자: Anant Narayanan ([email protected])
파일 보기 프로젝트 열기: sjardim/Hugopit 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$methods

공개 메소드들

메소드 설명
decode ( string $jwt, string | Array | null $key = null, boolean $verify = true ) : object Decodes a JWT string into a PHP object.
encode ( object | array $payload, string $key, string $algo = 'HS256', $keyId = null ) : string Converts and signs a PHP object or array into a JWT string.
jsonDecode ( string $input ) : object Decode a JSON string into a PHP object.
jsonEncode ( object | array $input ) : string Encode a PHP object into a JSON string.
sign ( string $msg, string | resource $key, string $method = 'HS256' ) : string Sign a string with a given key and algorithm.
urlsafeB64Decode ( string $input ) : string Decode a string with URL-safe Base64.
urlsafeB64Encode ( string $input ) : string Encode a string with URL-safe Base64.
verify ( string $msg, string $signature, string | resource $key, string $method = 'HS256' ) : boolean Verify a signature with the mesage, key and method. Not all methods are symmetric, so we must have a separate verify and sign method.

비공개 메소드들

메소드 설명
handleJsonError ( integer $errno ) : void Helper method to create a JSON error.

메소드 상세

decode() 공개 정적인 메소드

Decodes a JWT string into a PHP object.
public static decode ( string $jwt, string | Array | null $key = null, boolean $verify = true ) : object
$jwt string The JWT
$key string | Array | null The secret key, or map of keys
$verify boolean Don't skip verification process
리턴 object The JWT's payload as a PHP object

encode() 공개 정적인 메소드

Converts and signs a PHP object or array into a JWT string.
public static encode ( object | array $payload, string $key, string $algo = 'HS256', $keyId = null ) : string
$payload object | array PHP object or array
$key string The secret key
$algo string The signing algorithm. Supported algorithms are 'HS256', 'HS384' and 'HS512'
리턴 string A signed JWT

jsonDecode() 공개 정적인 메소드

Decode a JSON string into a PHP object.
public static jsonDecode ( string $input ) : object
$input string JSON string
리턴 object Object representation of JSON string

jsonEncode() 공개 정적인 메소드

Encode a PHP object into a JSON string.
public static jsonEncode ( object | array $input ) : string
$input object | array A PHP object or array
리턴 string JSON representation of the PHP object or array

sign() 공개 정적인 메소드

Sign a string with a given key and algorithm.
public static sign ( string $msg, string | resource $key, string $method = 'HS256' ) : string
$msg string The message to sign
$key string | resource The secret key
$method string The signing algorithm. Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
리턴 string An encrypted message

urlsafeB64Decode() 공개 정적인 메소드

Decode a string with URL-safe Base64.
public static urlsafeB64Decode ( string $input ) : string
$input string A Base64 encoded string
리턴 string A decoded string

urlsafeB64Encode() 공개 정적인 메소드

Encode a string with URL-safe Base64.
public static urlsafeB64Encode ( string $input ) : string
$input string The string you want encoded
리턴 string The base64 encode of what you passed in

verify() 공개 정적인 메소드

Verify a signature with the mesage, key and method. Not all methods are symmetric, so we must have a separate verify and sign method.
public static verify ( string $msg, string $signature, string | resource $key, string $method = 'HS256' ) : boolean
$msg string the original message
$signature string
$key string | resource for HS*, a string key works. for RS*, must be a resource of an openssl public key
$method string
리턴 boolean

프로퍼티 상세

$methods 공개적으로 정적으로 프로퍼티

public static $methods