20 ms·
I have been looking into the viability of putting auth and basic user data in Worker + KV. For auth I'm currently using firebase/google auth and I'm wondering i
by jamesmcintyre 7y ago
I have been looking into the viability of putting auth and basic user data in Worker + KV. For auth I'm currently using firebase/google auth and I'm wondering if there's a strategy to authenticate with firebase that wouldn't require a auth request to firebase on every request but instead allow sessions and possibly caching session info in KV. Have any thoughts?
- steveklabnik 7y agoPM of KV here. People have certainly done auth with Workers and KV before. https://liftcodeplay.com/2018/10/16/pushing-my-api-to-the-edge-part-2-authentication-and-authorization/ https://liftcodeplay.com/2018/10/16/pushing-my-api-to-the-ed... and https://gist.github.com/bcnzer/04620abc992da72f83f6f1c61d71c93c https://gist.github.com/bcnzer/04620abc992da72f83f6f1c61d71c... are two examples I've seen using JWT. We added expirations to KV to handle these sorts of use cases. I don't have a pre-built firebase example handy, but I think this should work pretty well. You'd store the ID and refresh tokens in KV, and then use those when talking to Firebase. Sounds about right. Feel free to reach out if you give it a shot and run into issues: sklabnik@cloudflare.com
- jamesmcintyre 7y agoThanks @steveklabnik! That helps a lot! I'll reach out if I run into trouble!