32
How to store user's access tokens/API keys without hashing them?
(lemmy.pe1uca.dev)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
Here's a simple approach:
Initial request -> server looks for Authorization header, falls back to X-Auth header -> generates JWT and sends back to client in Authorization header (or whatever makes sense)
Subsequent request -> server looks for Authorization header -> checks JWT against revocation database/table and that it isn't expired
Subsequent request with expired token -> server returns 401, client retries using X-Auth header -> server sends back JWT on Authorization header -> client updates locally-stored JWT for future requests
There are probably ways to make this more standard or optimal, but this is a simple approach.