I have an existing MySQL database schema in production for an PHP5 application. The application was built in a popular MVC framework (which one isn't important). We use Doctrine ORM 1.2.x as out ORM.
The default routing used a primary id, in our case simply an unsigned auto incremented integer. However some of the data is sensitive, and although we run under SSL, changing an ID value in the url could potentially give access to confidential data a user is not authorized to see.
The solution as I see it is to use some obscured value in place of the more obvious record ID.
Ideally we would just add a new column to affected table and generate some unique random or hashed value for that record right?
However, I can conceivably see a couple other tables/routes being in need of the same treatment sooner or later, and would like a reusable solution that can avoid a series of database updates. So I've been thinking about alternative methods and would like opinions on whether there are any major issues to be concerned about.
- simple obfuscating the value, i.e. shifting bits and/or base 64 encoding
- quick and nasty encryption
- using hmac to ensure the id given matches the given hmac
update As mentioned by Charles
, ACLs would be a preferred solution, however some portions of the site are open to the public, so ACLs for these areas are not possible. We do however make extensive use of ACL in the applications backend.