Making the Auth client cacheable on AppEngine

时间:2017-12-18 08:01:01

标签: google-app-engine firebase go firebase-authentication firebase-admin

This is about using the Firebase Admin SDK for Go: https://github.com/firebase/firebase-admin-go/ (in Google AppEngine)

Is there a nice way (without forking the firebase-admin-go repo) to make the created Auth clients cacheable on AppEngine? They cannot be cached as such because the supplied Context will rot quite soon (resulting after a while in: Call error 3: invalid security ticket). The reason they should be cached is that the client internally fetches the public keys over the internet, making any token verification take almost 200ms on that first time.

If I were to modify this myself, I'd probably do something like this:

  1. create a new client every request (as per how Context works in AppEngine)
  2. have the client accept some kind of configuration option that would enable me to pass an old client instance to it
  3. have the new client instance would check the old client's key cache and use it if it is still non-expired

As far as I can tell, this is not possible with the current API. Any workarounds I could be missing? Suggesting a breaking change to the library is not something I'd lightly be willing to do.

0 个答案:

没有答案