MCPcopy
hub / github.com/appleboy/gin-jwt / TokenStore

Interface TokenStore

core/store.go:19–39  ·  view source on GitHub ↗

TokenStore defines the interface for storing and retrieving refresh tokens

Source from the content-addressed store, hash-verified

17
18// TokenStore defines the interface for storing and retrieving refresh tokens
19type TokenStore interface {
20 // Set stores a refresh token with associated user data and expiration
21 // Returns an error if the operation fails
22 Set(ctx context.Context, token string, userData any, expiry time.Time) error
23
24 // Get retrieves user data associated with a refresh token
25 // Returns ErrRefreshTokenNotFound if token doesn't exist or is expired
26 Get(ctx context.Context, token string) (any, error)
27
28 // Delete removes a refresh token from storage
29 // Returns an error if the operation fails, but should not error if token doesn't exist
30 Delete(ctx context.Context, token string) error
31
32 // Cleanup removes expired tokens (optional, for cleanup routines)
33 // Returns the number of tokens cleaned up and any error encountered
34 Cleanup(ctx context.Context) (int, error)
35
36 // Count returns the total number of active refresh tokens
37 // Useful for monitoring and debugging
38 Count(ctx context.Context) (int, error)
39}
40
41// RefreshTokenData holds the data stored with each refresh token
42type RefreshTokenData struct {

Callers 27

middlewareImplMethod · 0.65
LogoutHandlerMethod · 0.65
storeRefreshTokenMethod · 0.65
ParseTokenMethod · 0.65
testLoginAndRefreshFlowFunction · 0.65
testRedisStoreOperationsFunction · 0.65
getRefreshTokenFromLoginFunction · 0.65
TestLoginHandlerFunction · 0.65
TestRefreshHandlerRS256Function · 0.65

Implementers 2

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…