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

Recommendations for working with JWTs and Sessionless APIs? #137

Open
viztastic opened this issue Aug 7, 2015 · 6 comments
Open

Recommendations for working with JWTs and Sessionless APIs? #137

viztastic opened this issue Aug 7, 2015 · 6 comments

Comments

@viztastic
Copy link

Hi there,

I notice that the user details is taken out of session store, is there a recommended way to handle this for the case where I intend to use a stateless authentication technology (such as JWT) ?

A solution that comes to mind is to simply have my JWT authentication middleware populate the session.id object before passing it on to ACL?

Thanks!

@pdfowler
Copy link

pdfowler commented Oct 7, 2015

I'm fighting this myself and debating what direction I want to take my project. I'm about 1/2 ACL and 1/2 middleware - but have to support JWT. I've tried working a passport.authenticate call into my main 'isAllowed' call, but with no luck ...

Did you figure anything out?

@yoher
Copy link

yoher commented Feb 1, 2016

Hi,
I'm just beginning to use node_acl and facing the same requirement.

I guess the right way to go would be to implement a JWT backend to get the info from the token, to be used instead of one of the existing backends (redis, mongo, memory).
The main difference would be that we won't be able to modify the user permissions without issuing a new token (as they would be immutably set and signed in the JWT payload by the authentication provider at creation time).
It's not a big problem: it's just the same kind of issue that forces you to logout/login into a linux session when you change your user groups. And with some token renewal mechanism it can be fully transparent to the user.

I'll try to share anything I can come up with on that topic.

/Yoann

@ianstormtaylor
Copy link

Did any of you end up solving this? Did you do it with node_acl or another library?

@yoher
Copy link

yoher commented Mar 21, 2016

Hi there.
Short answer: no.
I ended up going back to Java/Springboot for that project, and I've had no time to play with nodejs since then... Good luck with it!

@vigneshnrfs
Copy link

I am using meanjs.org in some of my projects and have implemented JWT on top of it.

After passport authenticates using jwt, the user is set in req.user.

You can then use acl.middleware() to get the user info from req.user and check for your permissions.

@darkyen
Copy link

darkyen commented Jul 10, 2016

@vigneshnrfs That will not work very-well with stateless api's which is exactly JWT's good for.
For instance express-jwt

Currently I re-wrote the middleware myself to read roles from JWT's, it treats sub as userId and role as a role claim from JWT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants