Last active
March 8, 2018 21:21
-
-
Save snewell92/1226ee76fe465aa7e58f9f07a7443555 to your computer and use it in GitHub Desktop.
Feathers JWT doesn't have userID
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
// CLIENT | |
import feathers from '@feathersjs/feathers' | |
import socketio from '@feathersjs/socketio-client' | |
import auth from '@feathersjs/authentication-client' | |
import io from 'socket.io-client' | |
const socket = io('http://localhost:3030') | |
const app = feathers() | |
// Set up Socket.io client with the socket | |
app.configure(socketio(socket)) | |
.configure(auth({ storage: window.localStorage })) | |
export default app |
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
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') | |
] | |
} | |
}); | |
}; |
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
{ | |
// snippet | |
"dependencies": { | |
"@feathersjs/authentication-client": "^1.0.2", | |
"@feathersjs/feathers": "^3.1.1", | |
"@feathersjs/socketio-client": "^1.1.0", | |
"socket.io-client": "^2.0.4", | |
"vue": "^2.5.2", | |
"vue-router": "^3.0.1", | |
"vuetify": "^1.0.3" | |
} | |
} |
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
{ | |
"host": "localhost", | |
"port": 3030, | |
"public": "../public/", | |
"paginate": { | |
"default": 10, | |
"max": 50 | |
}, | |
"mysql": "USE_ENVIRONMENT_VARIABLES_FOR_CONNECTION_STRING", | |
"authentication": { | |
"secret": "longsecureguy", | |
"strategies": [ | |
"jwt", | |
"local" | |
], | |
"path": "/authentication", | |
"service": "users", | |
"jwt": { | |
"header": { | |
"typ": "access" | |
}, | |
"audience": "localhost", | |
"subject": "anonymous", | |
"issuer": "feathers", | |
"algorithm": "HS256", | |
"expiresIn": "1d" | |
}, | |
"local": { | |
"entity": "users", | |
"usernameField": "\\username", | |
"passwordField": "password" | |
} | |
} | |
} |
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
{ | |
// snippet | |
"dependencies": { | |
"@feathersjs/authentication": "^2.1.1", | |
"@feathersjs/authentication-jwt": "^2.0.0", | |
"@feathersjs/authentication-local": "^1.1.0", | |
"@feathersjs/configuration": "^1.0.2", | |
"@feathersjs/errors": "^3.2.2", | |
"@feathersjs/express": "^1.1.2", | |
"@feathersjs/feathers": "^3.1.0", | |
"@feathersjs/socketio": "^3.1.0", | |
"compression": "^1.7.1", | |
"cors": "^2.8.4", | |
"db-migrate": "^0.10.5", | |
"db-migrate-mysql": "^1.1.10", | |
"feathers-sequelize": "^3.0.0", | |
"helmet": "^3.10.0", | |
"mysql2": "^1.5.1", | |
"node-fetch": "^2.0.0", | |
"sequelize": "^4.32.2", | |
"serve-favicon": "^2.4.5", | |
"winston": "^2.4.0" | |
}, | |
"devDependencies": { | |
"@feathersjs/cli": "^3.6.0", | |
"eslint": "^4.16.0", | |
"mocha": "^5.0.0", | |
"nodemon": "^1.14.12", | |
"request": "^2.83.0", | |
"request-promise": "^4.2.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment