Should I obscure primary key values?

后端 未结 10 2173
借酒劲吻你
借酒劲吻你 2021-02-13 02:33

I\'m building a web application where the front end is a highly-specialized search engine. Searching is handled at the main URL, and the user is passed off to a sub-directory wh

10条回答
  •  闹比i
    闹比i (楼主)
    2021-02-13 03:10

    On the dangers of exposing your primary key, you'll want to read "autoincrement considered harmful", By Joshua Schachter.

    URLs that include an identifier will let you down for three reasons.

    The first is that given the URL for some object, you can figure out the URLs for objects that were created around it. This exposes the number of objects in your database to possible competitors or other people you might not want having this information (as famously demonstrated by the Allies guessing German tank production levels by looking at the serial numbers.)

    Secondly, at some point some jerk will get the idea to write a shell script with a for-loop and try to fetch every single object from your system; this is definitely no fun.

    Finally, in the case of users, it allows people to derive some sort of social hierarchy. Witness the frequent hijacking and/or hacking of high-prestige low-digit ICQ ids.

提交回复
热议问题