Created
October 6, 2015 15:34
-
-
Save devinivy/8dca9e01bf256c085dfb to your computer and use it in GitHub Desktop.
A mock auth scheme for testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mock scheme for testing | |
server.auth.scheme('mock', function(server, options) { | |
return { | |
authenticate: function(request, reply) { | |
reply({credentials: options}); | |
} | |
}; | |
}); | |
// To register a strategy that logs you in with this canned record | |
server.strategy('testing-strategy', 'mock', { user: { id: 1, username: 'baby-matt' } }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
const mockSchema = function () {
const authenticate = async (_request: Request, h: ResponseToolkit): Promise<Hapi.Auth<Hapi.UserCredentials>> =>{
h.authenticated({ credentials: {}});
}
return { authenticate };
};
server.auth.scheme('mock', mockSchema);
server.auth.strategy(<strategy_name>, 'mock');