Is base64 a good option for encoding custom Document IDS for Firestore?

这一生的挚爱 提交于 2019-12-11 16:42:07

问题


I am working on creating some users in my firebase app and I would like to provide custom user ids as they are authenticating with an external service.

For example my user ID generation is consisted by 2 parts like so:

AuthService:AuthServiceUsername

That can look in reality like:

Instragram:dimitrioskanellopoulos

But I dont like to have this string used as a user id so I encode it to base64 like so:

  const uid = Buffer.from(`instagram:${serviceUserID}`).toString('base64');

Is there any risk for me doing that ? Is base64 ok to be used also in regards to query params?


回答1:


Firestore document IDs are quite flexible on what's allowed and not. See https://firebase.google.com/docs/firestore/quotas#limits.

But base64 would actually not be safe, since it contains /, which is disallowed in Firestore document IDs



来源:https://stackoverflow.com/questions/56273672/is-base64-a-good-option-for-encoding-custom-document-ids-for-firestore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!