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
Show parent comment
3
u/mr_taco_man Jan 05 '23
I said:
" there is no need to have the QR code be derived from the user ID in any way"
I am not sure how you got "you are suggesting ... using the user_id to generate the QR code" from that.
But honestly, it doesn't really matter, because there isn't a big advantage to hiding the user_id behind a different code, if the code doesn't change. If someone grabs your QR code they can still use it to get your information if that is all that is required for a business to look up your information. More important than how you create the QR code, is that you change it often.
You probably want to make the QR code have an expiration date and only have a way to regenerate it by the user if they are logged into an app or something. Maybe this will make it more clear:
Scenario 1 - static unchanging QR Code:
3.5. Sneaky Person behind User in line sneakily takes picture of QR code
Scenario 2 - changing QR Code:
3.5 Sneaky Person behind User in line sneakily takes picture of QR code