Hapi: Support multiple default authentication strategies, executed in order

Created on 4 Sep 2014  路  2Comments  路  Source: hapijs/hapi

Reasoning:

In quite a few scenarios we need to support multiple authentication strategies, for example anonymous logins from mobile devices and bearer tokens if users had decided to log in. Right now it seems that the way to implement this is to create multiple strategies and set the auth.strategies property in each route. This gets a bit messy, especially when hapi servers are composed from smaller, individual modules. Having multiple default strategies allows us to determine access levels through scope and roles at the plugin level, but keep the auth code outside in the server where it belongs.

support

Most helpful comment

Does this cover what you're trying to do: http://hapijs.com/api#serverauthdefaultoptions?

So you would use it like:

server.auth.default({
    strategies: ['strategy1', 'strategy2', 'strategy3']
})

All 2 comments

Does this cover what you're trying to do: http://hapijs.com/api#serverauthdefaultoptions?

So you would use it like:

server.auth.default({
    strategies: ['strategy1', 'strategy2', 'strategy3']
})

Nice, I missed that. I think that should cover it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shamsher31 picture shamsher31  路  5Comments

hovmand picture hovmand  路  3Comments

leore picture leore  路  4Comments

jeremiahlee picture jeremiahlee  路  4Comments

jney picture jney  路  4Comments