simple-jwt.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of qbhy/simple-jwt.
  5. *
  6. * @link https://github.com/qbhy/simple-jwt
  7. * @document https://github.com/qbhy/simple-jwt/blob/master/README.md
  8. * @contact qbhy0715@qq.com
  9. * @license https://github.com/qbhy/simple-jwt/blob/master/LICENSE
  10. */
  11. use Qbhy\SimpleJwt\Encoders;
  12. use Qbhy\SimpleJwt\EncryptAdapters as Encrypter;
  13. return [
  14. /*
  15. * 必填
  16. * jwt 服务端身份标识
  17. */
  18. 'secret' => env('SIMPLE_JWT_SECRET'),
  19. /*
  20. * 可选配置
  21. * jwt 生命周期,单位秒,默认一天
  22. */
  23. 'ttl' => env('SIMPLE_JWT_TTL', 60 * 60 * 24),
  24. /*
  25. * 可选配置
  26. * 允许过期多久以内的 token 进行刷新,默认一周
  27. */
  28. 'refresh_ttl' => env('SIMPLE_JWT_REFRESH_TTL', 60 * 60 * 24 * 7),
  29. /*
  30. * 可选配置
  31. * 默认使用的加密类
  32. */
  33. 'default' => Encrypter\PasswordHashEncrypter::class,
  34. /*
  35. * 可选配置
  36. * 加密类必须实现 Qbhy\SimpleJwt\Interfaces\Encrypter 接口
  37. */
  38. 'drivers' => [
  39. Encrypter\PasswordHashEncrypter::alg() => Encrypter\PasswordHashEncrypter::class,
  40. Encrypter\CryptEncrypter::alg() => Encrypter\CryptEncrypter::class,
  41. Encrypter\SHA1Encrypter::alg() => Encrypter\SHA1Encrypter::class,
  42. Encrypter\Md5Encrypter::alg() => Encrypter\Md5Encrypter::class,
  43. Encrypter\HS256Encrypter::alg() => Encrypter\HS256Encrypter::class,
  44. ],
  45. /*
  46. * 可选配置
  47. * 编码类
  48. */
  49. 'encoder' => new Encoders\Base64UrlSafeEncoder(),
  50. /*
  51. * 可选配置
  52. * 缓存类,用于黑名单
  53. */
  54. 'cache' => new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir()),
  55. // 'encoder' => Encoders\Base64Encoder::class,
  56. /*
  57. * 可选配置
  58. * 缓存前缀
  59. */
  60. 'prefix' => env('JWT_CACHE_PREFIX', 'default'),
  61. ];