Enforce free QR code limit across incognito/private browsing sessions via server-side IP tracking#31
Draft
Enforce free QR code limit across incognito/private browsing sessions via server-side IP tracking#31
Conversation
… tracking Co-authored-by: mplik <187812982+mplik@users.noreply.github.com>
Co-authored-by: mplik <187812982+mplik@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix QR code generation limit in Cognito mode
Enforce free QR code limit across incognito/private browsing sessions via server-side IP tracking
Mar 19, 2026
Owner
|
Yes, that's one of the next tasks we will be working on. Thanks--Rafał Emme Właściciel mplik.pl(+48)533 789 ***@***.*** Zachęcamy do odwiedzenia naszej strony na Githubie.Znajdziesz tam wiele ciekawych projektów i zasobów!https://mplik.github.io/domeny-web/Sprawdź nas na GitHub oraz odkryj nasze wyjątkowe produkty na mplik.pl19 mar 2026 04:28 Copilot ***@***.***> napisał(a):
@copilot requested your review on: mplik/qr-code-generator#31 Enforce free QR code limit across incognito/private browsing sessions via server-side IP tracking.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because your review was requested.Message ID: ***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 3-free-QR-code limit was stored exclusively in the Flask session cookie, which resets on every new incognito/private window — making the paywall trivially bypassable.
Changes
_ip_qr_counts: OrderedDict[str, int]): moves the authoritative counter server-side, keyed by client IP, so it survives session resets_check_and_increment_ip): limit check and counter update happen inside a singlethreading.Lockacquisition — eliminates the TOCTOU race where concurrent requests at count=2 could both slip throughget_client_ip): reads the last entry inX-Forwarded-For(appended by Railway/Render's trusted proxy, not controllable by the client); falls back torequest.remote_addr_MAX_TRACKED_IPS = 100_000):OrderedDict-based LRU eviction prevents unbounded growthsession['qr_count']writeOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.