Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a client side component for authentication #44

Closed
ekryski opened this Issue Feb 7, 2016 · 1 comment

Comments

Projects
None yet
1 participant
@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

This comment has been minimized.

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 referenced this issue Feb 12, 2016

Merged

Decoupling #49

@ekryski ekryski closed this Feb 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.