PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/config/jwt.php

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