nuisance is a hapi plugin that allows multiple authentication strategies to be aggregated into a single strategy. hapi allows you specify multiple strategies on a route, however this approach only requires that a single strategy is successful.
nuisance, on the other hand, requires that all of the strategies are successful.
If all of the authentication strategies are successful,
request.auth.credentials will be populated with the credentials from each strategy. If any of the strategies fail, an Unauthorized error will be returned.
// Given the following auth strategies in your server:serverauth;serverauth;serverauth;// You can define an aggregate strategy based on the nuisance scheme:serverauth;// Then use the aggregate strategy as needed:server;
strategies(array) - An array of strings or objects, representing the authentication strategies to be tested. The strategies are tested one at a time. As soon as one strategy fails, no additional strategies are tried. If an array element is a string, it must be the name of an existing auth strategy. If an array element is an object, it must adhere to the following schema.
name(string) - The name of the auth strategy to test.
failureCredentials(function) - A synchronous function that is called if authentication fails for the strategy in question. This function takes a hapi
requestobject as its only argument, and returns a credentials object. This is useful for setting default credentials on failed authentication. If this function is not provided for a failing strategy, the default behavior is to fail the aggregate authentication.