1 | <?php |
||
7 | class JwtWrapper |
||
8 | { |
||
9 | |||
10 | protected $serverName; |
||
11 | |||
12 | /** |
||
13 | * @var JwtKeyInterface |
||
14 | */ |
||
15 | protected $jwtKey; |
||
16 | |||
17 | /** |
||
18 | * JwtWrapper constructor. |
||
19 | * @param string $serverName |
||
20 | * @param JwtKeyInterface $jwtKey |
||
21 | * @throws JwtWrapperException |
||
22 | */ |
||
23 | public function __construct($serverName, $jwtKey) |
||
32 | |||
33 | /** |
||
34 | * @param $data |
||
35 | * @param int $secondsExpire In Seconds |
||
36 | * @param int $secondsNotBefore In Seconds |
||
37 | * @return array |
||
38 | */ |
||
39 | public function createJwtData($data, $secondsExpire = 60, $secondsNotBefore = 0) |
||
59 | |||
60 | public function generateToken($jwtData) |
||
76 | |||
77 | /** |
||
78 | * Extract the key, which is coming from the config file. |
||
79 | * |
||
80 | * Best suggestion is the key to be a binary string and |
||
81 | * store it in encoded in a config file. |
||
82 | * |
||
83 | * Can be generated with base64_encode(openssl_random_pseudo_bytes(64)); |
||
84 | * |
||
85 | * keep it secure! You'll need the exact key to verify the |
||
86 | * token later. |
||
87 | * |
||
88 | * @param null $bearer |
||
89 | * @return object |
||
90 | * @throws JwtWrapperException |
||
91 | */ |
||
92 | public function extractData($bearer = null) |
||
112 | |||
113 | /** |
||
114 | * @return mixed |
||
115 | * @throws JwtWrapperException |
||
116 | */ |
||
117 | public function getAuthorizationBearer() |
||
128 | |||
129 | public static function generateSecret($bytes) |
||
133 | } |