-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix: Auto-enable clients with renewed subscriptions and Feature: Subscription Token Protection (As an example of implementation) #923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add sub_token and sub_exp fields to clients table - Implement subscription token generation and validation - Add token protection mechanism to subscription handler - Update client information and token expiration periodically - Modify subscription service to handle token generation and updates - Update README to reflect new subscription token protection feature
Feature: Subscription Token ProtectionOverviewThis security enhancement adds an extra layer of protection to subscription endpoints by requiring clients to use time-limited tokens to access their subscription data. Key ComponentsDatabase Changes
Token Management
Subscription Handler Security
Client Service Enhancements
Configuration
Security Benefits
Implementation ApproachThe implementation follows a non-breaking approach:
How It Works
Enabling Token ProtectionTo enable subscription token protection:
Token ManagementTokens are automatically managed by the system:
Frontend Compatibility NoticeThe frontend has not been modified or tested with these changes. All modifications and testing have been done through the API only. Need to modify frontend to easy use. |
|
The example problem: #928 |
Problem
When a client's subscription expires, the system automatically disables the client (enable = false). However, when the subscription is renewed (by updating the expiry date or increasing the volume limit), the client remains disabled and continues to show "Error!" when trying to access the subscription configuration.
Root Cause
The original logic checked if the client was disabled and returned an error before checking whether the subscription had been renewed. This meant that even after renewing a subscription, clients would remain in a disabled state indefinitely.
Solution
Reordered the validation logic to:
First check if the client is disabled
If disabled, verify if the subscription is now valid (not expired AND not over volume limit)
If valid, automatically re-enable the client in the database
Then perform the standard expiry and volume checks
Changes Made
Modified
sub/jsonService.go - getData() functionModified
sub/subService.go - GetSubs() functionBenefits
✅ Clients with renewed subscriptions are automatically re-enabled on their next request
✅ Works with unlimited subscriptions (expiry = 0)
✅ Works with unlimited traffic (volume = 0)
✅ No manual intervention required after renewing subscriptions
✅ Backward compatible with existing functionality
Testing
Tested with:
Expired subscription → renewed → client auto-enabled ✅
Exceeded volume limit → increased limit → client auto-enabled ✅
Unlimited subscription (expiry = 0) → always enabled ✅
Unlimited traffic (volume = 0) → always enabled ✅