Back

[Solved] Go-to path for JWT tokens

  • 0
  • Self Hosted
fafa
22 Nov, 2023, 08:37

What's your go-to path for JWT tokens?

I currently store the a_session_projectid as a cookie, but secure and without HTTPOnly. Normally you should use HTTPOnly but I don't want to create a new JWT token for every request. Or should I?

The token is as you said 15 minutes valid. Do I store it for 15 minutes and create a new one after that? Do I check for the JWT validation the entire time to create a new one? 😄

or do I just create a JWT token every time I do a request? (Which is a lot)

TL;DR
The user is asking for advice on the best approach for handling JWT tokens. They currently store the token as a cookie, but without HTTPOnly for ease of use. The suggestion is to use HTTPOnly for security reasons. JWT tokens are intended for one-off use, so it might be best to create a new token for each request. The token is valid for 15 minutes, so the user can either create a new token after the expiration or continuously validate and create new tokens during each request.
ideclon
22 Nov, 2023, 08:39

I think in general, the JWTs are really intended for one-off use where a function/script needs to act as a specific User

ideclon
22 Nov, 2023, 08:39

They're not really intended for long-term use

fafa
22 Nov, 2023, 08:40

So you think the a_session_projectid token should just be without HTTPOnly?

fafa
22 Nov, 2023, 08:40

In general, sensitive tokens should be with, however this makes it unreadable for JS

fafa
22 Nov, 2023, 08:40

(and there's only one token 😄 )

ideclon
22 Nov, 2023, 08:40

I think you should probably be using the Cookies instead

fafa
22 Nov, 2023, 08:41

The header?

ideclon
22 Nov, 2023, 08:41

Yeah. Cookie auth is intended to be used the way you're using JWTs

fafa
22 Nov, 2023, 08:41

Thanks, will do!

ideclon
22 Nov, 2023, 08:47

If your issue has been solved, you can close this post by adding “[SOLVED]” to the beginning of the title

fafa
22 Nov, 2023, 09:20

You actually opened up a whole new scene for me haha. I am really grateful. Thanks!

fafa
22 Nov, 2023, 09:20

[Solved] Go-to path for JWT tokens

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more