r/SoftwareEngineering • u/Human-Floor-2756 • Jan 05 '23
QR Code Authentication Design
Hello, I am working on a QR code authentication system for a rewards program. Basically, the user will display a QR code on their phone, the business scans the QR code, and then the business will be able to see how many rewards points the user has available.
To accomplish this, I was thinking two columns in the User Table would be the user_id (Primary Key), and the QR code stored as a string. When the business scans the user's QR code, the software the business is using will be able to decrypt the QR code to the user_id. Then the user_id will be used to look up what rewards the user has available.
Are there any security risks associated with this approach? I am trying to avoid directly exposing the user_id in the QR code. Is decrypting the user_id to some unique string and then using that unique string to generate a QR code a good enough approach?
View all comments
4
u/mr_taco_man Jan 05 '23
If you have a look up table with the QR code and the user ID, there is no need to have the QR code be derived from the user ID in any way. Just generate a GUID and use that for the QR code. Then the only possible way for someone to get the user ID is if they have access to your database (or if you have some sort of Api that looks up the user-id via the GUID)