config.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <?php
  2. return [
  3. /*
  4. |--------------------------------------------------------------------------
  5. | JWT Authentication Secret
  6. |--------------------------------------------------------------------------
  7. |
  8. | Don't forget to set this in your .env file, as it will be used to sign
  9. | your tokens. A helper command is provided for this:
  10. | `php artisan jwt:secret`
  11. |
  12. | Note: This will be used for Symmetric algorithms only (HMAC),
  13. | since RSA and ECDSA use a private/public key combo (See below).
  14. |
  15. */
  16. 'secret' => env('JWT_SECRET'),
  17. /*
  18. |--------------------------------------------------------------------------
  19. | JWT Authentication Keys
  20. |--------------------------------------------------------------------------
  21. |
  22. | The algorithm you are using, will determine whether your tokens are
  23. | signed with a random string (defined in `JWT_SECRET`) or using the
  24. | following public & private keys.
  25. |
  26. | Symmetric Algorithms:
  27. | HS256, HS384 & HS512 will use `JWT_SECRET`.
  28. |
  29. | Asymmetric Algorithms:
  30. | RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below.
  31. |
  32. */
  33. 'keys' => [
  34. /*
  35. |--------------------------------------------------------------------------
  36. | Public Key
  37. |--------------------------------------------------------------------------
  38. |
  39. | A path or resource to your public key.
  40. |
  41. | E.g. 'file://path/to/public/key'
  42. |
  43. */
  44. 'public' => env('JWT_PUBLIC_KEY'),
  45. /*
  46. |--------------------------------------------------------------------------
  47. | Private Key
  48. |--------------------------------------------------------------------------
  49. |
  50. | A path or resource to your private key.
  51. |
  52. | E.g. 'file://path/to/private/key'
  53. |
  54. */
  55. 'private' => env('JWT_PRIVATE_KEY'),
  56. /*
  57. |--------------------------------------------------------------------------
  58. | Passphrase
  59. |--------------------------------------------------------------------------
  60. |
  61. | The passphrase for your private key. Can be null if none set.
  62. |
  63. */
  64. 'passphrase' => env('JWT_PASSPHRASE'),
  65. ],
  66. /*
  67. |--------------------------------------------------------------------------
  68. | JWT time to live
  69. |--------------------------------------------------------------------------
  70. |
  71. | Specify the length of time (in minutes) that the token will be valid for.
  72. | Defaults to 1 hour.
  73. |
  74. | You can also set this to null, to yield a never expiring token.
  75. | Some people may want this behaviour for e.g. a mobile app.
  76. | This is not particularly recommended, so make sure you have appropriate
  77. | systems in place to revoke the token if necessary.
  78. | Notice: If you set this to null you should remove 'exp' element from 'required_claims' list.
  79. |
  80. */
  81. 'ttl' => env('JWT_TTL', 60),
  82. /*
  83. |--------------------------------------------------------------------------
  84. | Refresh time to live
  85. |--------------------------------------------------------------------------
  86. |
  87. | Specify the length of time (in minutes) that the token can be refreshed
  88. | within. I.E. The user can refresh their token within a 2 week window of
  89. | the original token being created until they must re-authenticate.
  90. | Defaults to 2 weeks.
  91. |
  92. | You can also set this to null, to yield an infinite refresh time.
  93. | Some may want this instead of never expiring tokens for e.g. a mobile app.
  94. | This is not particularly recommended, so make sure you have appropriate
  95. | systems in place to revoke the token if necessary.
  96. |
  97. */
  98. 'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
  99. /*
  100. |--------------------------------------------------------------------------
  101. | JWT hashing algorithm
  102. |--------------------------------------------------------------------------
  103. |
  104. | Specify the hashing algorithm that will be used to sign the token.
  105. |
  106. | See here: https://github.com/namshi/jose/tree/master/src/Namshi/JOSE/Signer/OpenSSL
  107. | for possible values.
  108. |
  109. */
  110. 'algo' => env('JWT_ALGO', 'HS256'),
  111. /*
  112. |--------------------------------------------------------------------------
  113. | Required Claims
  114. |--------------------------------------------------------------------------
  115. |
  116. | Specify the required claims that must exist in any token.
  117. | A TokenInvalidException will be thrown if any of these claims are not
  118. | present in the payload.
  119. |
  120. */
  121. 'required_claims' => [
  122. 'iss',
  123. 'iat',
  124. 'exp',
  125. 'nbf',
  126. 'sub',
  127. 'jti',
  128. ],
  129. /*
  130. |--------------------------------------------------------------------------
  131. | Persistent Claims
  132. |--------------------------------------------------------------------------
  133. |
  134. | Specify the claim keys to be persisted when refreshing a token.
  135. | `sub` and `iat` will automatically be persisted, in
  136. | addition to the these claims.
  137. |
  138. | Note: If a claim does not exist then it will be ignored.
  139. |
  140. */
  141. 'persistent_claims' => [
  142. // 'foo',
  143. // 'bar',
  144. ],
  145. /*
  146. |--------------------------------------------------------------------------
  147. | Lock Subject
  148. |--------------------------------------------------------------------------
  149. |
  150. | This will determine whether a `prv` claim is automatically added to
  151. | the token. The purpose of this is to ensure that if you have multiple
  152. | authentication models e.g. `App\User` & `App\OtherPerson`, then we
  153. | should prevent one authentication request from impersonating another,
  154. | if 2 tokens happen to have the same id across the 2 different models.
  155. |
  156. | Under specific circumstances, you may want to disable this behaviour
  157. | e.g. if you only have one authentication model, then you would save
  158. | a little on token size.
  159. |
  160. */
  161. 'lock_subject' => true,
  162. /*
  163. |--------------------------------------------------------------------------
  164. | Leeway
  165. |--------------------------------------------------------------------------
  166. |
  167. | This property gives the jwt timestamp claims some "leeway".
  168. | Meaning that if you have any unavoidable slight clock skew on
  169. | any of your servers then this will afford you some level of cushioning.
  170. |
  171. | This applies to the claims `iat`, `nbf` and `exp`.
  172. |
  173. | Specify in seconds - only if you know you need it.
  174. |
  175. */
  176. 'leeway' => env('JWT_LEEWAY', 0),
  177. /*
  178. |--------------------------------------------------------------------------
  179. | Blacklist Enabled
  180. |--------------------------------------------------------------------------
  181. |
  182. | In order to invalidate tokens, you must have the blacklist enabled.
  183. | If you do not want or need this functionality, then set this to false.
  184. |
  185. */
  186. 'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
  187. /*
  188. | -------------------------------------------------------------------------
  189. | Blacklist Grace Period
  190. | -------------------------------------------------------------------------
  191. |
  192. | When multiple concurrent requests are made with the same JWT,
  193. | it is possible that some of them fail, due to token regeneration
  194. | on every request.
  195. |
  196. | Set grace period in seconds to prevent parallel request failure.
  197. |
  198. */
  199. 'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
  200. /*
  201. |--------------------------------------------------------------------------
  202. | Show blacklisted token option
  203. |--------------------------------------------------------------------------
  204. |
  205. | Specify if you want to show black listed token exception on the laravel logs.
  206. |
  207. */
  208. 'show_black_list_exception' => env('JWT_SHOW_BLACKLIST_EXCEPTION', 0),
  209. /*
  210. |--------------------------------------------------------------------------
  211. | Cookies encryption
  212. |--------------------------------------------------------------------------
  213. |
  214. | By default Laravel encrypt cookies for security reason.
  215. | If you decide to not decrypt cookies, you will have to configure Laravel
  216. | to not encrypt your cookie token by adding its name into the $except
  217. | array available in the middleware "EncryptCookies" provided by Laravel.
  218. | see https://laravel.com/docs/master/responses#cookies-and-encryption
  219. | for details.
  220. |
  221. | Set it to true if you want to decrypt cookies.
  222. |
  223. */
  224. 'decrypt_cookies' => false,
  225. /*
  226. |--------------------------------------------------------------------------
  227. | Providers
  228. |--------------------------------------------------------------------------
  229. |
  230. | Specify the various providers used throughout the package.
  231. |
  232. */
  233. 'providers' => [
  234. /*
  235. |--------------------------------------------------------------------------
  236. | JWT Provider
  237. |--------------------------------------------------------------------------
  238. |
  239. | Specify the provider that is used to create and decode the tokens.
  240. |
  241. */
  242. 'jwt' => PHPOpenSourceSaver\JWTAuth\Providers\JWT\Lcobucci::class,
  243. /*
  244. |--------------------------------------------------------------------------
  245. | Authentication Provider
  246. |--------------------------------------------------------------------------
  247. |
  248. | Specify the provider that is used to authenticate users.
  249. |
  250. */
  251. 'auth' => PHPOpenSourceSaver\JWTAuth\Providers\Auth\Illuminate::class,
  252. /*
  253. |--------------------------------------------------------------------------
  254. | Storage Provider
  255. |--------------------------------------------------------------------------
  256. |
  257. | Specify the provider that is used to store tokens in the blacklist.
  258. |
  259. */
  260. 'storage' => PHPOpenSourceSaver\JWTAuth\Providers\Storage\Illuminate::class,
  261. ],
  262. ];