diff options
Diffstat (limited to 'src/authentication.js')
-rw-r--r-- | src/authentication.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/authentication.js b/src/authentication.js new file mode 100644 index 0000000..3312a46 --- /dev/null +++ b/src/authentication.js @@ -0,0 +1,27 @@ +const authentication = require('@feathersjs/authentication'); +const jwt = require('@feathersjs/authentication-jwt'); +const local = require('@feathersjs/authentication-local'); + + +module.exports = function (app) { + const config = app.get('authentication'); + + // Set up authentication with the secret + app.configure(authentication(config)); + app.configure(jwt()); + app.configure(local()); + + // The `authentication` service is used to create a JWT. + // The before `create` hook registers strategies that can be used + // to create a new valid JWT (e.g. local or oauth2) + app.service('authentication').hooks({ + before: { + create: [ + authentication.hooks.authenticate(config.strategies) + ], + remove: [ + authentication.hooks.authenticate('jwt') + ] + } + }); +}; |