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

Anonymous Token? #36

Closed
epicwhale opened this issue Oct 17, 2014 · 2 comments
Closed

Anonymous Token? #36

epicwhale opened this issue Oct 17, 2014 · 2 comments

Comments

@epicwhale
Copy link

I am using the JWT token (via data modifiers) to pass additional data like say a unique traceable session id to maintain state across a guest checkout. In this case, authentication is optional and the login token will not have the 'username' field set.

How do I go about achieving the above?

  1. Is there an anonymous token implementation in this bundle?
  2. If I override the JWTProvider's authenticate(..) function, would that suffice? I was thinking of removing the AuthenticationException which is thrown when !isset($payload['username')) and instead doing something here that treats this request as anonymous.

What are your thoughts on this?

@lopsided
Copy link

I am looking to do a very similar thing. @epicwhale did you get this working in the end?

@epicwhale
Copy link
Author

@lopsided excuse my delayed reply. Yes, I did via writing complete custom code and overriding some handles and registering events listeners.

There isn't a simple recipe. But the trick for me was to decode the token before this bundle does it and if its a guest, don't pass it on to JWT, so the user field is never checked. You can store the session id in some other field in the token.

gzim324 pushed a commit to gzim324/LexikJWTAuthenticationBundle that referenced this issue Jan 10, 2025
Using a custom UserProvider (issue lexik#36)
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

3 participants