Skip to content

feat(auth): add subscription tier enforcement middleware with granular feature gates#853

Merged
temma02 merged 1 commit into
StellerCraft:mainfrom
Darkdruce:feat/subscription-tier-enforcement-middleware
Jun 27, 2026
Merged

feat(auth): add subscription tier enforcement middleware with granular feature gates#853
temma02 merged 1 commit into
StellerCraft:mainfrom
Darkdruce:feat/subscription-tier-enforcement-middleware

Conversation

@Darkdruce

Copy link
Copy Markdown
Contributor

Closes #767

Centralises subscription tier enforcement into a reusable middleware.

  • Declarative FEATURE_GATES config maps route patterns to minimum required tiers
  • withTierEnforcement(requiredTier, handler) re-reads tier from Supabase on every request (not JWT cache) — single indexed SELECT for <5ms overhead
  • Returns 402 Payment Required with { error, upgradeUrl: '/pricing' } when tier is insufficient
  • Returns 401 for unauthenticated requests
  • Tier order: free < pro < enterprise
  • Tests cover all tier boundaries, 402 upgrade response, DB re-read assertion, and unauthenticated path

@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@Darkdruce Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@temma02 temma02 merged commit 2de2185 into StellerCraft:main Jun 27, 2026
0 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Subscription Tier Enforcement Middleware with Granular Feature Gate Evaluation

2 participants