MongoDB: is it safe to use document's ID “in public”?

后端 未结 8 2453
名媛妹妹
名媛妹妹 2020-12-13 02:01

I really like MongoDB\'s automatically generated ids. They are really useful.

However, is it save to use them publicly?

Let\'s say there is a posts collecti

8条回答
  •  情歌与酒
    2020-12-13 02:17

    I thought mongodb _id was based on a datestamp, and sever address and other things you might prefer to keep private.

    If you're worried it might be worth encrypting mongoids and using the result as a client-side identifier (and then un-encrypting when requests come back in).

    If the encryption key is partially based on some unique attribute of the user or session in question, that makes it difficult for users to access content when they shouldn't.

    Obviously still important to validate the user by other means!

提交回复
热议问题