Created
October 17, 2018 16:44
-
-
Save shsunmoonlee/6c1cfd51314f399a1dbb0a593ec5f969 to your computer and use it in GitHub Desktop.
feathers tutorial
This file contains hidden or 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
| const authentication = require('@feathersjs/authentication'); | |
| const jwt = require('@feathersjs/authentication-jwt'); | |
| const local = require('@feathersjs/authentication-local'); | |
| const oauth2 = require('@feathersjs/authentication-oauth2'); | |
| const Verifier = require('@feathersjs/authentication-oauth2').Verifier; | |
| const GoogleStrategy = require('passport-google-oauth20').Strategy; | |
| const FacebookStrategy = require('passport-facebook').Strategy; | |
| // const makeHandler = require('./oauth-handler'); | |
| const EmailFirstOAuth2Verifier = require('./verifier'); | |
| module.exports = function (app) { | |
| const config = app.get('authentication'); | |
| // const handler = makeHandler(app); | |
| // Set up authentication with the secret | |
| app.configure(authentication(config)); | |
| app.configure(jwt()); | |
| app.configure(local()); | |
| app.configure(oauth2(Object.assign({ | |
| name: 'google', | |
| Strategy: GoogleStrategy, | |
| Verifier: EmailFirstOAuth2Verifier, | |
| }, config.google))); | |
| app.configure(oauth2(Object.assign({ | |
| name: 'facebook', | |
| Strategy: FacebookStrategy, | |
| Verifier: EmailFirstOAuth2Verifier, | |
| }, config.facebook))); | |
| // 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') | |
| ] | |
| } | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment