是否可以将mongo ObjectId转换为字符串并将其用于URL? [英] Is it ok to turn the mongo ObjectId into a string and use it for URLs?

查看:186
本文介绍了是否可以将mongo ObjectId转换为字符串并将其用于URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

document/show?id=4cf8ce8a8aad6957ff00005b


推荐答案

一般来说,我认为你应该谨慎地向客户端公开内部(如DB ID)。 URL可以很容易地被操纵,用户可以访问你不想让他拥有的对象。

Generally I think you should be cautious to expose internals (such as DB ids) to the client. The URL can easily be manipulated and the user has possibly access to objects you don't want him to have.

对于MongoDB来说,对象ID甚至可能会显示一些额外内部(请参阅此处),即它们不是完全随机的。这可能也是一个问题。

For MongoDB in special, the object ID might even reveal some additional internals (see here), i.e. they aren't completely random. That might be an issue too.

除此之外,我认为没有理由不使用id。

Besides that, I think there's no reason not to use the id.

这篇关于是否可以将mongo ObjectId转换为字符串并将其用于URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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