Hello, after a bit of reading (not much, I admit!)...
# prisma-whats-new
p
Hello, after a bit of reading (not much, I admit!) I’m not sure whether or not
prisma token
generates a “permanent” HS256 token that never expires (equivalent to Graphcool Framework’s PAT) or… not!?
l
I didn't know the answer, but it's a good question! So here's what I did to figure it out. JWT payloads are readable, so I stuck my prisma token into JWT.io and the iat (issued at) was March 13 and the exp is March 20. So they do expire after a week.
n
I can confirm 🙂 But you can mint your own tokens with custom expiry @picosam, which is different to GCF. On the other hand, there is no way to "revoke" a token, so creating one with long duration needs to be done with double care.
l
Changing the secret revokes the token, right? (And obviously kills all tokens in the process)
n
That's correct.
j
nilan you can revoke JWT tokens by storing it in a db on the server whenever you issue new ones. Then you can lookup
n
@lawjolla one more comment,
secret
in
prisma.yml
is actually a comma separated list, so you can reroll secrets without loss of connection @James yup, that's right 🙂 But no such system is employed for Prisma tokens.
👍 1
l
But by using a db, you lose the entire point of a JWT. That's fine if you don't need or what the efficiency of trusted claims. I think Auth0 has it right. Give a long term idToken with an accessToken that expires every hour or so, and make the client reup the accesstoken. That minimizes the revoking problem
👍 1
p
Thank you all, I’m back after dinner 😛 I second what @lawjolla says indeed.
@nilan what library do you currently use to generate a JWT token when we run
prisma token
?
l
It should be in the CLI. I'll take a look
p
I saw
"jwt-decode": "^2.2.0"
but I thought that couldn’t be it
Ah, I think it’s indeed there:
"jsonwebtoken": "^8.1.0"
l
Nice! And for an easter egg, reading the source code yielded prisma token -c copies it to the clipboard!
p
LOL, cool! May you tell me which file you found the command in?
l