auth.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. 'use strict'
  2. /** @type {import('@adonisjs/framework/src/Env')} */
  3. const Env = use('Env')
  4. module.exports = {
  5. /*
  6. |--------------------------------------------------------------------------
  7. | Authenticator
  8. |--------------------------------------------------------------------------
  9. |
  10. | Authentication is a combination of serializer and scheme with extra
  11. | config to define on how to authenticate a user.
  12. |
  13. | Available Schemes - basic, session, jwt, api
  14. | Available Serializers - lucid, database
  15. |
  16. */
  17. authenticator: 'session',
  18. /*
  19. |--------------------------------------------------------------------------
  20. | Session
  21. |--------------------------------------------------------------------------
  22. |
  23. | Session authenticator makes use of sessions to authenticate a user.
  24. | Session authentication is always persistent.
  25. |
  26. */
  27. session: {
  28. serializer: 'lucid',
  29. model: 'App/Models/User',
  30. scheme: 'session',
  31. uid: 'username',
  32. password: 'password'
  33. },
  34. /*
  35. |--------------------------------------------------------------------------
  36. | Basic Auth
  37. |--------------------------------------------------------------------------
  38. |
  39. | The basic auth authenticator uses basic auth header to authenticate a
  40. | user.
  41. |
  42. | NOTE:
  43. | This scheme is not persistent and users are supposed to pass
  44. | login credentials on each request.
  45. |
  46. */
  47. basic: {
  48. serializer: 'lucid',
  49. model: 'App/Models/User',
  50. scheme: 'basic',
  51. uid: 'username',
  52. password: 'password'
  53. },
  54. /*
  55. |--------------------------------------------------------------------------
  56. | Jwt
  57. |--------------------------------------------------------------------------
  58. |
  59. | The jwt authenticator works by passing a jwt token on each HTTP request
  60. | via HTTP `Authorization` header.
  61. |
  62. */
  63. jwt: {
  64. serializer: 'lucid',
  65. model: 'App/Models/User',
  66. scheme: 'jwt',
  67. uid: 'username',
  68. password: 'password',
  69. options: {
  70. secret: Env.get('APP_KEY')
  71. }
  72. },
  73. /*
  74. |--------------------------------------------------------------------------
  75. | Api
  76. |--------------------------------------------------------------------------
  77. |
  78. | The Api scheme makes use of API personal tokens to authenticate a user.
  79. |
  80. */
  81. api: {
  82. serializer: 'lucid',
  83. model: 'App/Models/User',
  84. scheme: 'api',
  85. uid: 'username',
  86. password: 'password'
  87. }
  88. }