base64是对Firestore的自定义文档ID进行编码的好选择吗? [英] Is base64 a good option for encoding custom Document IDS for Firestore?

查看:48
本文介绍了base64是对Firestore的自定义文档ID进行编码的好选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力在Firebase应用程序中创建一些用户,我想提供自定义用户ID,以便他们通过外部服务进行身份验证.

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.

例如,我的用户ID生成由如下两部分组成:

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

AuthService:AuthServiceUsername

在现实中看起来可能像这样:

That can look in reality like:

Instragram:dimitrioskanellopoulos

但是我不希望将此字符串用作用户ID,因此我将其编码为base64,如下所示:

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');

我这样做有什么危险吗?在查询参数方面还可以使用base64吗?

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

推荐答案

Firestore文档ID在允许和不允许的内容上非常灵活.请参见 https://firebase.google.com/docs/firestore/quotas#limits.

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

但是base64实际上并不安全,因为它包含/,这在Firestore文档ID中是不允许的

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

这篇关于base64是对Firestore的自定义文档ID进行编码的好选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆