Cheetah
FirebaseJwt.php
Go to the documentation of this file.
1 <?php
2 
3 namespace OAuth2\Encryption;
4 
10 {
11  public function __construct()
12  {
13  if (!class_exists('\JWT')) {
14  throw new \ErrorException('firebase/php-jwt must be installed to use this feature. You can do this by running "composer require firebase/php-jwt"');
15  }
16  }
17 
18  public function encode($payload, $key, $alg = 'HS256', $keyId = null)
19  {
20  return \JWT::encode($payload, $key, $alg, $keyId);
21  }
22 
23  public function decode($jwt, $key = null, $allowedAlgorithms = null)
24  {
25  try {
26 
27  //Maintain BC: Do not verify if no algorithms are passed in.
28  if (!$allowedAlgorithms) {
29  $key = null;
30  }
31 
32  return (array)\JWT::decode($jwt, $key, $allowedAlgorithms);
33  } catch (\Exception $e) {
34  return false;
35  }
36  }
37 
38  public function urlSafeB64Encode($data)
39  {
40  return \JWT::urlsafeB64Encode($data);
41  }
42 
43  public function urlSafeB64Decode($b64)
44  {
45  return \JWT::urlsafeB64Decode($b64);
46  }
47 }
OAuth2\Encryption\FirebaseJwt\encode
encode($payload, $key, $alg='HS256', $keyId=null)
Definition: FirebaseJwt.php:18
OAuth2\Encryption
Definition: EncryptionInterface.php:3
php
OAuth2\Encryption\FirebaseJwt\__construct
__construct()
Definition: FirebaseJwt.php:11
OAuth2\Encryption\FirebaseJwt\urlSafeB64Decode
urlSafeB64Decode($b64)
Definition: FirebaseJwt.php:43
OAuth2\Encryption\FirebaseJwt\decode
decode($jwt, $key=null, $allowedAlgorithms=null)
Definition: FirebaseJwt.php:23
OAuth2\Encryption\FirebaseJwt\urlSafeB64Encode
urlSafeB64Encode($data)
Definition: FirebaseJwt.php:38
OAuth2\Encryption\FirebaseJwt
Definition: FirebaseJwt.php:10
OAuth2\Encryption\EncryptionInterface
Definition: EncryptionInterface.php:6