mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-06-06 11:29:35 +08:00
- Updated all references from v6 to v7 for `github.com/router-for-me/CLIProxyAPI`. - Ensured consistency in imports within core libraries, tests, and integration tests. - Added missing tests for new features in Redis Protocol integration.
36 lines
697 B
Go
36 lines
697 B
Go
package auth
|
|
|
|
import (
|
|
"sync"
|
|
|
|
coreauth "github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/auth"
|
|
)
|
|
|
|
var (
|
|
storeMu sync.RWMutex
|
|
registeredStore coreauth.Store
|
|
)
|
|
|
|
// RegisterTokenStore sets the global token store used by the authentication helpers.
|
|
func RegisterTokenStore(store coreauth.Store) {
|
|
storeMu.Lock()
|
|
registeredStore = store
|
|
storeMu.Unlock()
|
|
}
|
|
|
|
// GetTokenStore returns the globally registered token store.
|
|
func GetTokenStore() coreauth.Store {
|
|
storeMu.RLock()
|
|
s := registeredStore
|
|
storeMu.RUnlock()
|
|
if s != nil {
|
|
return s
|
|
}
|
|
storeMu.Lock()
|
|
defer storeMu.Unlock()
|
|
if registeredStore == nil {
|
|
registeredStore = NewFileTokenStore()
|
|
}
|
|
return registeredStore
|
|
}
|