Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

Add a client side component for authentication #44

Closed
12 tasks done
ekryski opened this issue Feb 7, 2016 · 1 comment
Closed
12 tasks done

Add a client side component for authentication #44

ekryski opened this issue Feb 7, 2016 · 1 comment
Milestone

Comments

@ekryski
Copy link
Member

ekryski commented Feb 7, 2016

Since Feathers is isomorphic we should follow a similar convention to some of our other libs and expose a client side portion.

Auth can get pretty complicated. We don't need to go so far as implementing everything Auth0's Lock provides but it would be nice to have something that at a minimum provides:

  • a mechanism for managing storing a valid token (ie. localStorage)
  • handling a 401 error
  • refreshing tokens
  • refreshing and storing the logged-in user's data
  • exposes a client side hook for adding the token to the header or socket body
  • handles pulling the JWT from the feathers-jwt cookie after successful OAuth authentication

Things that need to happen to work on this

  • Add header support for feathers REST client
  • Fix providers to work with new params format
    • REST
    • socket.io
    • primus
  • Add ability to determine which providers are enabled in the client
    • REST
    • socket.io
    • primus
  • Pass params.query instead of params into makeUrl (see this)
  • Add a default service hook if feathers authentication is enabled that attempts to grab the JWT from local storage (falling back to cookie) and stores it on hook.params.token
  • allow configuring some custom options for client side feathers-authentication module
    • a custom user endpoint (default is /users)
    • a custom auth header field (default is Authorization)
    • custom token endpoint (default is /auth/token)
    • custom local auth endpoint (default is /auth/local)
@ekryski ekryski added this to the 1.0 release milestone Feb 7, 2016
@ekryski
Copy link
Member Author

ekryski commented Feb 11, 2016

Once #48 is merged it's as simple as:

var socket = io(host, {
  transport: ['websockets']
});

window.app = feathers()
  .configure(feathers.socketio(socket))
  .configure(feathers.hooks())
  .configure(feathers.authentication());

app.io.on('connect', function(){
  app.authenticate({
    type: 'local',
    'email': 'admin@feathersjs.com',
    'password': 'admin'
  }).then(function(result){
    console.log('Authenticated!', result);
  }).catch(function(error){
    console.error('Error authenticating!', error);
  });
});

@ekryski ekryski mentioned this issue Feb 12, 2016
@ekryski ekryski closed this as completed Feb 12, 2016
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant