You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Priority: Medium Phase: Phase 1 (Code Quality) Dependencies: #357, #359
📝 User Story
As a developer,
I want to eliminate the duplicated JWT validation logic in the auth middleware,
So that security fixes only need to be applied once and the code is DRY.
🎯 Scope & Requirements
Extract common JWT decode + validation logic from check_auth and check_customer_auth into a shared private function
Parameterize the middleware to differentiate admin vs. customer contexts via a generic or enum parameter
Remove the fully duplicated check_customer_auth function (lines 67-109 of auth_middleware.rs)
✅ Acceptance Criteria
Givenauth_middleware.rs, When reviewed, Then there is exactly one JWT decode implementation.
Given an expired admin JWT, When sent to an admin-protected route, Then a 401 is returned with "Token expired" message.
All existing integration tests pass.
🛠️ Technical Context / Notes
Both functions in auth_middleware.rs are identical except for the function name. This is a classic DRY violation.
📋 Task Checklist
Extract shared JWT validation into a private helper
Refactor check_auth and check_customer_auth to call the shared helper
Activity
unwrap()calls from production code #357