-
Notifications
You must be signed in to change notification settings - Fork 27
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
Is there any way to implement HTTP Only Cookies? #47
Comments
Managed to do some workarounds for now but it's a shoddy approach. Overrode AuthenticationController and set the access + refresh tokens after it's generated and set in the headers by api_guard. I took a look at the gem's core code further and I think we could probably add support for HTTP Only Cookie as an alternative to using Request Headers. My suggestion is to:
Would love to give this a try if you're open to it. |
@gczh Thanks for your suggestion, it looks good. We need to support three ways of sending tokens in response:
I am also thinking about using the access & refresh tokens from cookies (if present) for authenticating the request when
Let me know if you are willing to do these changes. |
Happy to tackle this if you're up to code review my changes(: |
Yes. I can. Please proceed 👍 |
Will work on this! |
Is there any update on this, cc @Gokul595? |
I got refresh tokens in cookies working in my startup, I am gonna fork the repository and start working on it :) |
and also I think we need to make the http cookie implementation default ? |
#63 here is the implementation and also something is wrong in repository, needs Cognitive Complexity of 5, but I am exceeding in it, I write a custom tokenscontroller and registration controller and also authentication controller, to get yourself ready as fast as possible, is combining the three response methods, I am storing the refresh token in the cookie with ( jit as a keyword) and leaving the access token in the headers because in the frontend, I will store it, in the state using redux and access it from the state and do my logic and when you signed in or signed up, I am returning the access token in the response body |
Implemented this gem for JWT auth and it works like a charm, even with GraphQL.
However, using localstorage to store the Bearer token isn't very secure. Using HTTP Only Cookies seem to be a reasonable solution to that security issue. However, it seems that api_guard only supports the use of HTTP Headers to retrieve the tokens (including the refresh tokens)
Would it be possible to override the controllers to implement support for using HTTP Only cookies to retrieve the bearer and refresh tokens?
The text was updated successfully, but these errors were encountered: