| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- /**
- * Config source: https://git.io/JY0mp
- *
- * Feel free to let us know via PR, if you find something broken in this config
- * file.
- */
- import type { AuthConfig } from '@ioc:Adonis/Addons/Auth'
- /*
- |--------------------------------------------------------------------------
- | Authentication Mapping
- |--------------------------------------------------------------------------
- |
- | List of available authentication mapping. You must first define them
- | inside the `contracts/auth.ts` file before mentioning them here.
- |
- */
- const authConfig: AuthConfig = {
- guard: 'api',
- guards: {
- /*
- |--------------------------------------------------------------------------
- | Web Guard
- |--------------------------------------------------------------------------
- |
- | Web guard uses classic old school sessions for authenticating users.
- | If you are building a standard web application, it is recommended to
- | use web guard with session driver
- |
- */
- web: {
- driver: 'session',
- provider: {
- /*
- |--------------------------------------------------------------------------
- | Driver
- |--------------------------------------------------------------------------
- |
- | Name of the driver
- |
- */
- driver: 'lucid',
- /*
- |--------------------------------------------------------------------------
- | Identifier key
- |--------------------------------------------------------------------------
- |
- | The identifier key is the unique key on the model. In most cases specifying
- | the primary key is the right choice.
- |
- */
- identifierKey: 'id',
- /*
- |--------------------------------------------------------------------------
- | Uids
- |--------------------------------------------------------------------------
- |
- | Uids are used to search a user against one of the mentioned columns. During
- | login, the auth module will search the user mentioned value against one
- | of the mentioned columns to find their user record.
- |
- */
- uids: ['username', 'phone', 'email'],
- /*
- |--------------------------------------------------------------------------
- | Model
- |--------------------------------------------------------------------------
- |
- | The model to use for fetching or finding users. The model is imported
- | lazily since the config files are read way earlier in the lifecycle
- | of booting the app and the models may not be in a usable state at
- | that time.
- |
- */
- model: () => import('App/Models/User')
- }
- },
- /*
- |--------------------------------------------------------------------------
- | OAT Guard
- |--------------------------------------------------------------------------
- |
- | OAT (Opaque access tokens) guard uses database backed tokens to authenticate
- | HTTP request. This guard DOES NOT rely on sessions or cookies and uses
- | Authorization header value for authentication.
- |
- | Use this guard to authenticate mobile apps or web clients that cannot rely
- | on cookies/sessions.
- |
- */
- api: {
- driver: 'oat',
- /*
- |--------------------------------------------------------------------------
- | Tokens provider
- |--------------------------------------------------------------------------
- |
- | Uses SQL database for managing tokens. Use the "database" driver, when
- | tokens are the secondary mode of authentication.
- | For example: The Github personal tokens
- |
- | The foreignKey column is used to make the relationship between the user
- | and the token. You are free to use any column name here.
- |
- */
- tokenProvider: {
- type: 'api',
- driver: 'database',
- table: 'api_tokens',
- foreignKey: 'user_id'
- },
- provider: {
- /*
- |--------------------------------------------------------------------------
- | Driver
- |--------------------------------------------------------------------------
- |
- | Name of the driver
- |
- */
- driver: 'lucid',
- /*
- |--------------------------------------------------------------------------
- | Identifier key
- |--------------------------------------------------------------------------
- |
- | The identifier key is the unique key on the model. In most cases specifying
- | the primary key is the right choice.
- |
- */
- identifierKey: 'id',
- /*
- |--------------------------------------------------------------------------
- | Uids
- |--------------------------------------------------------------------------
- |
- | Uids are used to search a user against one of the mentioned columns. During
- | login, the auth module will search the user mentioned value against one
- | of the mentioned columns to find their user record.
- |
- */
- uids: ['username', 'phone', 'email'],
- /*
- |--------------------------------------------------------------------------
- | Model
- |--------------------------------------------------------------------------
- |
- | The model to use for fetching or finding users. The model is imported
- | lazily since the config files are read way earlier in the lifecycle
- | of booting the app and the models may not be in a usable state at
- | that time.
- |
- */
- model: () => import('App/Models/User')
- }
- }
- }
- }
- export default authConfig
|