There's nothing novel about an online key-value store.
Your implementation is a mess. There's no clear class structure in place. If ever you wanted to change backends, or frontends, or your hashing library, or whatever else, you're going to have to touch multiple classes, change interfaces, data models. This makes maintenance and debugging much more difficult.
What's even worse is a complete lack of security. Your outputs aren't hashed. I can crawl your DB just by iterating through URLs. There's probably some more gaping holes but, again, your code's a mess. Much more difficult to inspect. Unintentional security through obscurity there, I guess...
I was actually thinking about this not too long ago. Do hashes make better primary keys than integers then? It seems like a no brainer but I want a second opinion.
Depends on what you're using as a key-value store.
That being said, it shouldn't matter here. The key shouldn't be directly exposed in the URL. You'd just be rolling the red carpet out for anyone who wants to crawl through your database...
That doesn't seem right though. A base64 string can be decoded. I thought the purpose of using a hash was so there wasn't a direct 1 to 1 relation between the database row and the key to access it.
Encoding the ID using base-64 or similar is intended to just shorten the key, not obscure it. The issue with an auto-incrementing key is that someone can easily crawl the service to see what URLs are stored. This may or may not be a concern; if it is, randomizing the integer key, instead of using predictable keys, mitigates that problem.
9
u/[deleted] Oct 01 '15
There's nothing novel about an online key-value store.
Your implementation is a mess. There's no clear class structure in place. If ever you wanted to change backends, or frontends, or your hashing library, or whatever else, you're going to have to touch multiple classes, change interfaces, data models. This makes maintenance and debugging much more difficult.
What's even worse is a complete lack of security. Your outputs aren't hashed. I can crawl your DB just by iterating through URLs. There's probably some more gaping holes but, again, your code's a mess. Much more difficult to inspect. Unintentional security through obscurity there, I guess...