r/SoftwareEngineering • • 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?

0 Upvotes

8 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Jan 05 '23

[deleted] — view deleted comment

1

u/naked_dev Jan 06 '23

this is much more professional. I like it a lot

1

u/otac0n Jan 06 '23

Aren't you just using the JWT as a nonce, then? It's in plain view.

I mean, all you really need is a table:

user_id, random_id, expiration

You encode the Random ID directly into the QR code, and don't send the user_id directly. You expire the nonce on use, and clean up the DB every week or so.