Commit 94d9220d authored by anton's avatar anton
Browse files

Add Auth0 auth strategy

parent 88f9c3c2
......@@ -8,10 +8,11 @@
},
"authentication": {
"entity": "user",
"entityId": "user_id",
"service": "users",
"secret": "M5Q6+pXQrAHKlwGz9v/fSw0mIGo=",
"authStrategies": [
"jwt",
"auth0",
"local"
],
"jwtOptions": {
......@@ -27,13 +28,10 @@
"usernameField": "email",
"passwordField": "password"
},
"oauth": {
"redirect": "/",
"auth0": {
"key": "<auth0 oauth key>",
"secret": "<auth0 oauth secret>",
"subdomain": "<auth0 subdomain>"
}
"auth0": {
"create": true,
"autoregister": true,
"domain": "auth.motionbank.org"
}
},
"mongodb": "mongodb://localhost:27017/motionbank_api",
......
......@@ -11,6 +11,7 @@ const express = require('@feathersjs/express')
const primus = require('@feathersjs/primus')
const { addIP } = require('@morphatic/feathers-auth0-strategy')
const middleware = require('./middleware')
const services = require('./services')
const appHooks = require('./app.hooks')
......@@ -43,6 +44,7 @@ app.configure(primus({ transformer: 'websockets' }))
app.configure(mongoose)
app.configure(mongodb)
// Configure other middleware (see `middleware/index.js`)
app.configure(addIP)
app.configure(middleware)
app.configure(authentication)
// Set up our services (see `services/index.js`)
......
const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication')
const { LocalStrategy } = require('@feathersjs/authentication-local')
const { expressOauth } = require('@feathersjs/authentication-oauth')
// const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication')
// const { LocalStrategy } = require('@feathersjs/authentication-local')
const { Auth0Service, Auth0Strategy } = require('@morphatic/feathers-auth0-strategy')
module.exports = app => {
const authentication = new AuthenticationService(app)
// const authentication = new AuthenticationService(app)
//
// authentication.register('jwt', new JWTStrategy())
// authentication.register('local', new LocalStrategy())
authentication.register('jwt', new JWTStrategy())
authentication.register('local', new LocalStrategy())
const authentication = new Auth0Service(app)
// register the strategy
authentication.register('auth0', new Auth0Strategy())
app.use('/authentication', authentication)
app.configure(expressOauth())
}
......@@ -10,7 +10,7 @@ module.exports = function (app) {
email: { type: String, unique: true, lowercase: true },
password: { type: String },
auth0Id: { type: String }
user_id: { type: String }
}, {
timestamps: true
......
const { authenticate } = require('@feathersjs/authentication').hooks
const { fromAuth0 } = require('@morphatic/feathers-auth0-strategy')
const { isProvider, some, unless } = require('feathers-hooks-common')
const {
hashPassword, protect
......@@ -6,13 +8,13 @@ const {
module.exports = {
before: {
all: [],
find: [authenticate('jwt')],
get: [authenticate('jwt')],
all: [unless(some(isProvider('server'), fromAuth0()), authenticate('auth0'))],
find: [], // [authenticate('jwt')],
get: [], // [authenticate('jwt')],
create: [hashPassword('password')],
update: [hashPassword('password'), authenticate('jwt')],
patch: [hashPassword('password'), authenticate('jwt')],
remove: [authenticate('jwt')]
update: [hashPassword('password')], // authenticate('jwt')],
patch: [hashPassword('password')], // authenticate('jwt')],
remove: [] // [authenticate('jwt')]
},
after: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment