From b018adf240679ec59a7344e30be39400f1ecd8af Mon Sep 17 00:00:00 2001 From: vantezzen Date: Thu, 22 Aug 2019 11:12:36 +0200 Subject: Initial commit --- config/auth.js | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 config/auth.js (limited to 'config/auth.js') diff --git a/config/auth.js b/config/auth.js new file mode 100644 index 0000000..c70db3f --- /dev/null +++ b/config/auth.js @@ -0,0 +1,94 @@ +'use strict' + +/** @type {import('@adonisjs/framework/src/Env')} */ +const Env = use('Env') + +module.exports = { + /* + |-------------------------------------------------------------------------- + | Authenticator + |-------------------------------------------------------------------------- + | + | Authentication is a combination of serializer and scheme with extra + | config to define on how to authenticate a user. + | + | Available Schemes - basic, session, jwt, api + | Available Serializers - lucid, database + | + */ + authenticator: 'jwt', + + /* + |-------------------------------------------------------------------------- + | Session + |-------------------------------------------------------------------------- + | + | Session authenticator makes use of sessions to authenticate a user. + | Session authentication is always persistent. + | + */ + session: { + serializer: 'lucid', + model: 'App/Models/User', + scheme: 'session', + uid: 'email', + password: 'password' + }, + + /* + |-------------------------------------------------------------------------- + | Basic Auth + |-------------------------------------------------------------------------- + | + | The basic auth authenticator uses basic auth header to authenticate a + | user. + | + | NOTE: + | This scheme is not persistent and users are supposed to pass + | login credentials on each request. + | + */ + basic: { + serializer: 'lucid', + model: 'App/Models/User', + scheme: 'basic', + uid: 'email', + password: 'password' + }, + + /* + |-------------------------------------------------------------------------- + | Jwt + |-------------------------------------------------------------------------- + | + | The jwt authenticator works by passing a jwt token on each HTTP request + | via HTTP `Authorization` header. + | + */ + jwt: { + serializer: 'lucid', + model: 'App/Models/User', + scheme: 'jwt', + uid: 'email', + password: 'password', + options: { + secret: Env.get('APP_KEY') + } + }, + + /* + |-------------------------------------------------------------------------- + | Api + |-------------------------------------------------------------------------- + | + | The Api scheme makes use of API personal tokens to authenticate a user. + | + */ + api: { + serializer: 'lucid', + model: 'App/Models/User', + scheme: 'api', + uid: 'email', + password: 'password' + } +} -- cgit v1.2.3-70-g09d2