Skip to content

Conversation

@justin-layerv
Copy link
Contributor

Summary

  • Extract common TokenStore functionality into a generic implementation in nhp/common/tokenstore.go
  • Both AC and Server now use the shared TokenStore[E] with their respective entry types
  • Eliminates ~60 lines of duplicate code while maintaining behavior

Changes

  • Add generic TokenStore[E] with Store, Load, Delete, CleanExpired, and RunRefreshRoutine methods
  • Add TokenEntry interface for expiry time access
  • Refactor AC's AccessEntry to implement TokenEntry interface
  • Refactor Server's ACTokenEntry to implement TokenEntry interface
  • Remove duplicate map manipulation and refresh routine code
  • Add comprehensive unit tests for TokenStore

Preserved Behaviors

The refactoring maintains the specific behaviors of each component:

  • AC: Adds 5s buffer to expiry and extends expiry on token verification
  • Server: Uses exact expiry and doesn't extend on verification

Test Plan

  • All existing tests pass
  • New TokenStore unit tests pass (7 tests)
  • AC package builds successfully
  • Server package builds successfully

@justin-layerv justin-layerv self-assigned this Jan 4, 2026
@justin-layerv justin-layerv force-pushed the refactor/consolidate-tokenstore branch from 040f8f8 to 243be24 Compare January 4, 2026 17:07
Extract common TokenStore functionality into a generic implementation
in nhp/common/tokenstore.go. Both AC and Server now use the shared
TokenStore[E] with their respective entry types.

Changes:
- Add generic TokenStore[E] with Store, Load, Delete, CleanExpired, and
  RunRefreshRoutine methods
- Add TokenEntry interface for expiry time access
- Refactor AC's AccessEntry to implement TokenEntry interface
- Refactor Server's ACTokenEntry to implement TokenEntry interface
- Remove duplicate map manipulation and refresh routine code
- Add comprehensive unit tests for TokenStore

This eliminates ~60 lines of duplicate code between AC and Server
while maintaining their specific behaviors:
- AC adds 5s buffer to expiry and extends expiry on verify
- Server uses exact expiry and doesn't extend on verify
@justin-layerv justin-layerv force-pushed the refactor/consolidate-tokenstore branch from 243be24 to b9e03a0 Compare January 4, 2026 17:09
- Keep consolidated TokenStore implementation from PR
- Apply import grouping style from main
- Keep improved error message format from main
@craftleon craftleon merged commit 89aea4a into main Jan 7, 2026
10 checks passed
@craftleon craftleon deleted the refactor/consolidate-tokenstore branch January 7, 2026 08:06
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.

3 participants