Documentation ¶
Index ¶
- Constants
- func NewTransactionHandler(client *mongo.Client, tcfg *TokenConfig) *transactionHandler
- func NewTransactionWorker(t *TokenConfig, cl *mongo.Client) *transactionWorker
- type ClientConfig
- type ClientStore
- type Config
- type OAuth2TokenUsageInfo
- type PersistentIDContextKey
- type StoreConfig
- type TokenConfig
- type TokenStore
- func (ts *TokenStore) Close()
- func (ts *TokenStore) Create(ctx context.Context, info oauth2.TokenInfo) (err error)
- func (ts *TokenStore) GetAccessByBasicID(ctx context.Context, basic string) (access string, err error)
- func (ts *TokenStore) GetAllPersistentIDsOfUser(ctx context.Context, userID uint64) (persistentID []string, err error)
- func (ts *TokenStore) GetByAccess(ctx context.Context, access string) (ti oauth2.TokenInfo, err error)
- func (ts *TokenStore) GetByCode(ctx context.Context, code string) (ti oauth2.TokenInfo, err error)
- func (ts *TokenStore) GetByRefresh(ctx context.Context, refresh string) (ti oauth2.TokenInfo, err error)
- func (ts *TokenStore) GetByUserID(ctx context.Context, userID uint64) (ti []OAuth2TokenUsageInfo, err error)
- func (ts *TokenStore) GetIDsByAccess(ctx context.Context, access string) (basicID string, persistentID string, err error)
- func (ts *TokenStore) GetPersistentIDByBasicID(ctx context.Context, basic string) (persistentID string, err error)
- func (ts *TokenStore) GetPersistentIDByRefresh(ctx context.Context, refresh string) (persistentID string, err error)
- func (ts *TokenStore) GetRefreshByBasicID(ctx context.Context, basic string) (refresh string, err error)
- func (ts *TokenStore) RemoveAccessByBasicID(ctx context.Context, basicID string) (err error)
- func (ts *TokenStore) RemoveByAccess(ctx context.Context, access string) (err error)
- func (ts *TokenStore) RemoveByCode(ctx context.Context, code string) (err error)
- func (ts *TokenStore) RemoveByRefresh(ctx context.Context, refresh string) (err error)
- func (ts *TokenStore) RemoveByUserID(ctx context.Context, userID uint64) (err error)
- func (ts *TokenStore) RemoveMultipleByTokenID(ctx context.Context, tokenIDs []string) (err error)
- func (ts *TokenStore) RemoveRefreshByBasicID(ctx context.Context, basicID string) (err error)
- func (ts *TokenStore) RemoveWholeTokenByAccess(ctx context.Context, access string) (err error)
- func (ts *TokenStore) RemoveWholeTokenByBasicID(ctx context.Context, tokenID string) (err error)
- func (ts *TokenStore) UpdateTokenUsage(ctx context.Context, basicID string) (err error)
- type TransactionWorker
- type UIData
- type UIDataContextKey
Constants ¶
const (
UserAgentKey = "User-Agent-Sn"
)
Variables ¶
This section is empty.
Functions ¶
func NewTransactionHandler ¶
func NewTransactionHandler(client *mongo.Client, tcfg *TokenConfig) *transactionHandler
func NewTransactionWorker ¶
func NewTransactionWorker(t *TokenConfig, cl *mongo.Client) *transactionWorker
Types ¶
type ClientConfig ¶
type ClientConfig struct { // store clients data collection name(The default is oauth2_clients) ClientsCName string // contains filtered or unexported fields }
ClientConfig client configuration parameters
func NewDefaultClientConfig ¶
func NewDefaultClientConfig(strCfgs *StoreConfig) *ClientConfig
NewDefaultClientConfig create a default client configuration
type ClientStore ¶
type ClientStore struct {
// contains filtered or unexported fields
}
ClientStore MongoDB storage for OAuth 2.0
func NewClientStore ¶
func NewClientStore(cfg *Config, scfgs ...*StoreConfig) *ClientStore
NewClientStore create a client store instance based on mongodb
func NewClientStoreWithSession ¶
func NewClientStoreWithSession(client *mongo.Client, cfg *Config, scfgs ...*StoreConfig) *ClientStore
NewClientStoreWithSession create a client store instance based on mongodb
func (*ClientStore) Create ¶
func (cs *ClientStore) Create(info oauth2.ClientInfo) (err error)
Create create client information
func (*ClientStore) GetByID ¶
func (cs *ClientStore) GetByID(ctx context.Context, id string) (info oauth2.ClientInfo, err error)
GetByID according to the ID for the client information
func (*ClientStore) RemoveByID ¶
func (cs *ClientStore) RemoveByID(id string) (err error)
RemoveByID use the client id to delete the client information
type Config ¶
type Config struct { URL string DB string Username string Password string Service string IsReplicaSet bool }
Config mongodb configuration parameters
func NewConfigNonReplicaSet ¶
NewConfigNonReplicaSet create mongodb configuration for a non-replicaSet
func NewConfigReplicaSet ¶
NewConfigReplicaSet create mongodb configuration for a ReplicaSet
type OAuth2TokenUsageInfo ¶
type PersistentIDContextKey ¶ added in v4.0.12
type PersistentIDContextKey struct{}
PersistentIDContextKey Persistent ID key to get/set from context
type StoreConfig ¶
type StoreConfig struct {
// contains filtered or unexported fields
}
StoreConfig hold configs common to all Configs(ClientConfig, TokenConfig)
func NewDefaultStoreConfig ¶
func NewDefaultStoreConfig(db, service string, isReplicasSet bool) *StoreConfig
func NewStoreConfig ¶
func NewStoreConfig(ctout, rtout int) *StoreConfig
type TokenConfig ¶
type TokenConfig struct { // store txn collection name(The default is oauth2) TxnCName string // store token based data collection name(The default is oauth2_basic) BasicCName string // store access token data collection name(The default is oauth2_access) AccessCName string // store refresh token data collection name(The default is oauth2_refresh) RefreshCName string // contains filtered or unexported fields }
TokenConfig token configuration parameters
func NewDefaultTokenConfig ¶
func NewDefaultTokenConfig(strConfig *StoreConfig) *TokenConfig
NewDefaultTokenConfig create a default token configuration
type TokenStore ¶
type TokenStore struct {
// contains filtered or unexported fields
}
TokenStore MongoDB storage for OAuth 2.0
func NewTokenStore ¶
func NewTokenStore(cfg *Config, scfgs ...*StoreConfig) (store *TokenStore)
NewTokenStore create a token store instance based on mongodb
func NewTokenStoreWithSession ¶
func NewTokenStoreWithSession(client *mongo.Client, cfg *Config, scfgs ...*StoreConfig) (store *TokenStore)
NewTokenStoreWithSession create a token store instance based on mongodb
func (*TokenStore) Create ¶
func (ts *TokenStore) Create(ctx context.Context, info oauth2.TokenInfo) (err error)
Create create and store the new token information
func (*TokenStore) GetAccessByBasicID ¶ added in v4.0.17
func (ts *TokenStore) GetAccessByBasicID(ctx context.Context, basic string) (access string, err error)
GetAccessByBasicID use the access token for token information data
func (*TokenStore) GetAllPersistentIDsOfUser ¶ added in v4.0.16
func (ts *TokenStore) GetAllPersistentIDsOfUser(ctx context.Context, userID uint64) (persistentID []string, err error)
GetAllPersistentIDsOfUser returns persistent IDs of all of the users tokens
func (*TokenStore) GetByAccess ¶
func (ts *TokenStore) GetByAccess(ctx context.Context, access string) (ti oauth2.TokenInfo, err error)
GetByAccess use the access token for token information data
func (*TokenStore) GetByCode ¶
func (ts *TokenStore) GetByCode(ctx context.Context, code string) (ti oauth2.TokenInfo, err error)
GetByCode use the authorization code for token information data
func (*TokenStore) GetByRefresh ¶
func (ts *TokenStore) GetByRefresh(ctx context.Context, refresh string) (ti oauth2.TokenInfo, err error)
GetByRefresh use the refresh token for token information data
func (*TokenStore) GetByUserID ¶
func (ts *TokenStore) GetByUserID(ctx context.Context, userID uint64) (ti []OAuth2TokenUsageInfo, err error)
GetByUserID returns all tokens of the specified user from the DB
func (*TokenStore) GetIDsByAccess ¶ added in v4.0.11
func (ts *TokenStore) GetIDsByAccess(ctx context.Context, access string) (basicID string, persistentID string, err error)
GetIDsByAccess returns both the persistent token ID and current basic ID of basic token info based on access token
func (*TokenStore) GetPersistentIDByBasicID ¶ added in v4.0.16
func (ts *TokenStore) GetPersistentIDByBasicID(ctx context.Context, basic string) (persistentID string, err error)
GetPersistentIDByBasicID returns the persistent token ID based on basic ID
func (*TokenStore) GetPersistentIDByRefresh ¶ added in v4.0.16
func (ts *TokenStore) GetPersistentIDByRefresh(ctx context.Context, refresh string) (persistentID string, err error)
GetPersistentIDByRefresh returns the persistent token ID of basic token info based on refresh token
func (*TokenStore) GetRefreshByBasicID ¶ added in v4.0.17
func (ts *TokenStore) GetRefreshByBasicID(ctx context.Context, basic string) (refresh string, err error)
GetRefreshByBasicID use the access token for token information data
func (*TokenStore) RemoveAccessByBasicID ¶ added in v4.0.8
func (ts *TokenStore) RemoveAccessByBasicID(ctx context.Context, basicID string) (err error)
RemoveAccessByBasic deletes an access token by its BasicID value
func (*TokenStore) RemoveByAccess ¶
func (ts *TokenStore) RemoveByAccess(ctx context.Context, access string) (err error)
RemoveByAccess use the access token to delete the token information
func (*TokenStore) RemoveByCode ¶
func (ts *TokenStore) RemoveByCode(ctx context.Context, code string) (err error)
RemoveByCode use the authorization code to delete the token information
func (*TokenStore) RemoveByRefresh ¶
func (ts *TokenStore) RemoveByRefresh(ctx context.Context, refresh string) (err error)
RemoveByRefresh use the refresh token to delete the token information
func (*TokenStore) RemoveByUserID ¶
func (ts *TokenStore) RemoveByUserID(ctx context.Context, userID uint64) (err error)
RemoveByUserID deletes OAuth token information from the DB of all OAuth tokens of the specified user
func (*TokenStore) RemoveMultipleByTokenID ¶
func (ts *TokenStore) RemoveMultipleByTokenID(ctx context.Context, tokenIDs []string) (err error)
RemoveMultipleByTokenID deletes the OAuth token information from the DB for the specified tokens TODO: This function should also remove entries from Access and Refresh collections
func (*TokenStore) RemoveRefreshByBasicID ¶ added in v4.0.8
func (ts *TokenStore) RemoveRefreshByBasicID(ctx context.Context, basicID string) (err error)
RemoveRefreshByBasic deletes a refresh token by its BasicID value
func (*TokenStore) RemoveWholeTokenByAccess ¶ added in v4.0.15
func (ts *TokenStore) RemoveWholeTokenByAccess(ctx context.Context, access string) (err error)
RemoveWholeTokenByAccess deletes the OAuth token information from all of the DB collections (access, refresh, basic) based on access token
func (*TokenStore) RemoveWholeTokenByBasicID ¶ added in v4.0.15
func (ts *TokenStore) RemoveWholeTokenByBasicID(ctx context.Context, tokenID string) (err error)
RemoveWholeTokenByBasicID deletes the OAuth token information from all the relevant collections (access, refresh, basic)
func (*TokenStore) UpdateTokenUsage ¶ added in v4.0.11
func (ts *TokenStore) UpdateTokenUsage(ctx context.Context, basicID string) (err error)
UpdateTokenUsage updates the LastUsedTime field to current time
type TransactionWorker ¶
type TransactionWorker interface {
// contains filtered or unexported methods
}
type UIDataContextKey ¶ added in v4.0.5
type UIDataContextKey struct{}
UIDataContextKey UI data key to get/set from context