adonisjs / auth

Official Authentication package for AdonisJS
https://docs.adonisjs.com/guides/auth/introduction
MIT License
196 stars 63 forks source link

Multiple Auth for same Authentication Scheme #73

Closed anantab closed 6 years ago

anantab commented 6 years ago

Is it possible to use same authentication scheme like session and have separate auth with multiple tables, for example for admin section and customer section. Or could it be session for admin and jwt for customer section?

hoangmy92 commented 6 years ago

@anantab In the core of framework, they tried to find the suitable authentication provider (which was set on config/auth) https://github.com/adonisjs/adonis-auth/blob/1.0.7/middleware/Auth.js#L29

So you just need to change the authenticator and it should work http://www.adonisjs.com/docs/3.2/authentication#_switching_between_authenticators

thetutlage commented 6 years ago

Closing since no response from the issue reporter and not actionable as well

mdjamilaj commented 4 years ago

how to add multiple authenticator

mcordoba commented 4 years ago

Im doing something like this:

  jwt_customer: {
    serializer: 'lucid',
    model: 'App/Models/Customer',
    scheme: 'jwt',
    uid: 'email',
    password: 'password',
    options: {
      secret: Env.get('APP_KEY')
    }
  },

  jwt_user: {
    serializer: 'lucid',
    model: 'App/Models/User',
    scheme: 'jwt',
    uid: 'email',
    password: 'password',
    options: {
      secret: Env.get('APP_KEY')
    }
  },

Then, Im trying to switch between authenticators as specified here: https://adonisjs.com/docs/4.1/authentication#_switching_authenticators