
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@feathersjs/authentication-client
Advanced tools
The authentication plugin for feathers-client
npm install @feathersjs/authentication-client --save
Note: This is only compatibile with feathers-authentication@1.x
and above.
This module contains:
The main feathers client instance has a few public methods:
app.authenticate(options)
- Authenticate by passing credentials.app.logout()
It also has a app.passport
instance that, like on the server, exposes utils functions for dealing with JWTs:
app.passport.getJWT()
- pull it from localstorage or the cookieapp.passport.verifyJWT(token)
- verify that a JWT is not expired and decode it to get the payload.Note: All these methods return promises.
In the event that your server goes down or the client loses connectivity, it will automatically handle attempting to re-authenticate the socket when the client regains connectivity with the server. In order to handle an authentication failure during automatic re-authentication you need to implement the following event listener:
const errorHandler = error => {
app.authenticate({
strategy: 'local',
email: 'admin@feathersjs.com',
password: 'admin'
}).then(response => {
// You are now authenticated again
});
};
// Handle when auth fails during a reconnect or a transport upgrade
app.on('reauthentication-error', errorHandler)
The following default options will be mixed in with the settings you pass in when configuring authentication. It will set the mixed options back to to the app so that they are available at any time by app.get('auth')
. They can all be overridden.
{
header: 'Authorization', // the default authorization header
path: '/authentication', // the server side authentication service path
jwtStrategy: 'jwt', // the name of the JWT authentication strategy
entity: 'user', // the entity you are authenticating (ie. a users)
service: 'users', // the service to look up the entity
cookie: 'feathers-jwt', // the name of the cookie to parse the JWT from when cookies are enabled server side
storageKey: 'feathers-jwt', // the key to store the accessToken in localstorage or AsyncStorage on React Native
}
There are 3 hooks. They are really meant for internal use and you shouldn't need to worry about them very often.
populateAccessToken
- Takes the token and puts in on hooks.params.accessToken
in case you need it in one of your client side services or hookspopulateHeader
- Add the accessToken to the authorization headerpopulateEntity
- Experimental. Populate an entity based on the JWT payload.Here's an example of a Feathers client that uses @feathersjs/authentication-client
.
const feathers = require('feathers/client');
const rest = require('feathers-rest/client');
const superagent = require('superagent');
const hooks = require('feathers-hooks');
const localStorage = require('localstorage-memory');
const auth = require('@feathersjs/authentication-client');
const client = feathers();
// NOTE: the order is important: auth must be configured _after_ rest/socket
client.configure(hooks())
.configure(rest('http://localhost:3030').superagent(superagent))
.configure(auth({ storage: localStorage }));
client.authenticate({
strategy: 'local',
email: 'admin@feathersjs.com',
password: 'admin'
})
.then(response => {
console.log('Authenticated!', response);
return client.passport.verifyJWT(response.accessToken);
})
.then(payload => {
console.log('JWT Payload', payload);
return client.service('users').get(payload.userId);
})
.then(user => {
client.set('user', user);
console.log('User', client.get('user'));
})
.catch(function(error){
console.error('Error authenticating!', error);
});
Copyright (c) 2016
Licensed under the MIT license.
FAQs
The authentication plugin for feathers-client
The npm package @feathersjs/authentication-client receives a total of 25,182 weekly downloads. As such, @feathersjs/authentication-client popularity was classified as popular.
We found that @feathersjs/authentication-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.