feathers-authentication-keystone
Keystone authentication strategy for feathers-authentication using Passport.
Installation
$ npm install feathers-authentication-keystone --save
Documentation
Please refer to the feathers-authentication-keystone documentation for more details.
Default Options
name: 'keystone' // the name to use when invoking the authentication Strategy entity: 'user' // the entity that will be added to the request, socket, and hook.params. (ie. req.user, socket.user, hook.params.user) service: 'users' // the service to look up the entity passReqToCallback: true // whether the request object should be passed to `verify` authUrl: 'http://<address>:<port>' // keystone endpoint with configured v3 authentication usernameField: 'username' // key name of username field passwordField: 'password' // key name of password field Verifier: Verifier // A Verifier class. Defaults to the built-in one but can be a custom one. See below for details.
Verifier
This is the verification class that receives the users identity (if verification is successful), populates the entity (normally a user) and returns both the entity and the payload. It has the following methods that can all be overridden.
// the class constructor verify(req, payload, done) // queries the configured service}
Customizing the Verifier
The Verifier
class can be extended so that you customize it's behavior without having to rewrite and test a totally custom local Passport implementation. Although that is always an option if you don't want use this plugin.
An example of customizing the Verifier:
; // The verify function has the exact same inputs and // return values as a vanilla passport strategy { // do your custom stuff. You can call internal Verifier methods // and reference this.app and this.options. This method must be implemented. ; } app;
Complete Example
Here's an example of a Feathers server that uses feathers-authentication-keystone
.
const feathers = ;const rest = ;const hooks = ;const memory = ;const bodyParser = ;const errorHandler = ;const auth = ;const jwt = ;const keystone = ; // Initialize the application.const app = ; app // Needed for parsing bodies (login). // Configure feathers-authentication. // Configure authentication by JWT token. // Keystone endpoint, this value should be taken from the config in real application. ; app; console;
License
Copyright (c) 2017
Licensed under the MIT license.