You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Hello,
I am using Authorizer instance deployed on railway.
React + express.
On production, for some reason, right after login, the token is no longer valid, and all subsequent requests fail.
My setup:
passing the token in the cookie to the backend
using getSession() to authenticate and get the user
Note: I didn't get getSession() to work as described in the docs - with bearer token. I'm passing the cookie to it as below:
My Frontend (Vue3) login direct to Authorizer and get Cookie (httpOnly with 365 days expire time) with json (access_token, ...etc) from response.
Now I'm save access_token to store (Pinia).
*** access_token will only store in memory when u close browser or tab it will remove. (for security reason)
*** Cookie that get from login (It not remove) now use have to use
const res = await authorizerRef.getSession();
to get new access_token
Backend -> Authorizer
My Backend (Golang API) I create middleware with receive access_token from Frontend (Vue3) and send it to Authorizer to Verify token
1.1 Valid token -> do handler
1.2 Invalid -> return 401
Activity
lakhansamani commentedon Oct 26, 2023
@mihaa1 for backend cookie session is not recommended,
We refresh cookie session with
sessionquery for security reasons.For backend I recommend using
access_token.mihaa1 commentedon Oct 26, 2023
Thanks.
Will it make sense to return the token I receive in the server to the client with Set-cookie?
bright-coder commentedon Nov 10, 2023
@mihaa1
In my project, i have
*** access_token will only store in memory when u close browser or tab it will remove. (for security reason)
*** Cookie that get from login (It not remove) now use have to use
to get new access_token
1.1 Valid token -> do handler
1.2 Invalid -> return 401
mihaa1 commentedon Nov 11, 2023
@bright-coder thank u.
Which method do u use on the backend to check the token?
bright-coder commentedon Nov 12, 2023
@mihaa1
Example in Golang SDK
`func (s *jwtAuthorizer) IsAuth() fiber.Handler {
return func(c *fiber.Ctx) error {
`
but i don't know the different between access_token and id_token.
lakhansamani commentedon Nov 16, 2023
@bright-coder
access_tokenis used for accessing the APIs of authorizerYou can use
id_tokento user identity and authorizing your apisbright-coder commentedon Nov 20, 2023
@lakhansamani Thank you. I think we should add this to document. ?
lakhansamani commentedon Nov 20, 2023
Sure will add it thanks 👍
mihaa1 commentedon Nov 26, 2023
@lakhansamani Im using the following code to authenticate on the backend:
Is this the correct way?
lakhansamani commentedon Nov 26, 2023
Yes