Documentation ¶
Index ¶
- Variables
- func DefaultValidateURI(baseURI string, redirectURI string) error
- type Config
- type Manager
- func (m *Manager) GenerateAccessToken(ctx context.Context, gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest) (oauth2.TokenInfo, error)
- func (m *Manager) GenerateAuthToken(ctx context.Context, rt oauth2.ResponseType, tgr *oauth2.TokenGenerateRequest) (oauth2.TokenInfo, error)
- func (m *Manager) GetClient(ctx context.Context, clientID string) (cli oauth2.ClientInfo, err error)
- func (m *Manager) LoadAccessToken(ctx context.Context, access string) (oauth2.TokenInfo, error)
- func (m *Manager) LoadRefreshToken(ctx context.Context, refresh string) (oauth2.TokenInfo, error)
- func (m *Manager) MapAccessGenerate(gen oauth2.AccessGenerate)
- func (m *Manager) MapAuthorizeGenerate(gen oauth2.AuthorizeGenerate)
- func (m *Manager) MapClientStorage(stor oauth2.ClientStore)
- func (m *Manager) MapTokenStorage(stor oauth2.TokenStore)
- func (m *Manager) MustClientStorage(stor oauth2.ClientStore, err error)
- func (m *Manager) MustTokenStorage(stor oauth2.TokenStore, err error)
- func (m *Manager) RefreshAccessToken(ctx context.Context, tgr *oauth2.TokenGenerateRequest) (oauth2.TokenInfo, error)
- func (m *Manager) RemoveAccessToken(ctx context.Context, access string) error
- func (m *Manager) RemoveRefreshToken(ctx context.Context, refresh string) error
- func (m *Manager) SetAuthorizeCodeExp(exp time.Duration)
- func (m *Manager) SetAuthorizeCodeTokenCfg(cfg *Config)
- func (m *Manager) SetClientTokenCfg(cfg *Config)
- func (m *Manager) SetImplicitTokenCfg(cfg *Config)
- func (m *Manager) SetPasswordTokenCfg(cfg *Config)
- func (m *Manager) SetRefreshTokenCfg(cfg *RefreshingConfig)
- func (m *Manager) SetValidateURIHandler(handler ValidateURIHandler)
- type RefreshingConfig
- type ValidateURIHandler
Constants ¶
This section is empty.
Variables ¶
var ( DefaultCodeExp = time.Minute * 10 DefaultAuthorizeCodeTokenCfg = &Config{AccessTokenExp: time.Hour * 2, RefreshTokenExp: time.Hour * 24 * 3, IsGenerateRefresh: true} DefaultImplicitTokenCfg = &Config{AccessTokenExp: time.Hour * 1} DefaultPasswordTokenCfg = &Config{AccessTokenExp: time.Hour * 2, RefreshTokenExp: time.Hour * 24 * 7, IsGenerateRefresh: true} DefaultClientTokenCfg = &Config{AccessTokenExp: time.Hour * 2} DefaultRefreshTokenCfg = &RefreshingConfig{IsGenerateRefresh: true, IsRemoveAccess: true, IsRemoveRefreshing: true} )
default configs
Functions ¶
func DefaultValidateURI ¶
DefaultValidateURI validates that redirectURI is contained in baseURI
Types ¶
type Config ¶
type Config struct { // access token expiration time, 0 means it doesn't expire AccessTokenExp time.Duration // refresh token expiration time, 0 means it doesn't expire RefreshTokenExp time.Duration // whether to generate the refreshing token IsGenerateRefresh bool }
Config authorization configuration parameters
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provide authorization management
func NewDefaultManager ¶
func NewDefaultManager() *Manager
NewDefaultManager create to default authorization management instance
func (*Manager) GenerateAccessToken ¶
func (m *Manager) GenerateAccessToken(ctx context.Context, gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest) (oauth2.TokenInfo, error)
GenerateAccessToken generate the access token
func (*Manager) GenerateAuthToken ¶
func (m *Manager) GenerateAuthToken(ctx context.Context, rt oauth2.ResponseType, tgr *oauth2.TokenGenerateRequest) (oauth2.TokenInfo, error)
GenerateAuthToken generate the authorization token(code)
func (*Manager) GetClient ¶
func (m *Manager) GetClient(ctx context.Context, clientID string) (cli oauth2.ClientInfo, err error)
GetClient get the client information
func (*Manager) LoadAccessToken ¶
LoadAccessToken according to the access token for corresponding token information
func (*Manager) LoadRefreshToken ¶
LoadRefreshToken according to the refresh token for corresponding token information
func (*Manager) MapAccessGenerate ¶
func (m *Manager) MapAccessGenerate(gen oauth2.AccessGenerate)
MapAccessGenerate mapping the access token generate interface
func (*Manager) MapAuthorizeGenerate ¶
func (m *Manager) MapAuthorizeGenerate(gen oauth2.AuthorizeGenerate)
MapAuthorizeGenerate mapping the authorize code generate interface
func (*Manager) MapClientStorage ¶
func (m *Manager) MapClientStorage(stor oauth2.ClientStore)
MapClientStorage mapping the client store interface
func (*Manager) MapTokenStorage ¶
func (m *Manager) MapTokenStorage(stor oauth2.TokenStore)
MapTokenStorage mapping the token store interface
func (*Manager) MustClientStorage ¶
func (m *Manager) MustClientStorage(stor oauth2.ClientStore, err error)
MustClientStorage mandatory mapping the client store interface
func (*Manager) MustTokenStorage ¶
func (m *Manager) MustTokenStorage(stor oauth2.TokenStore, err error)
MustTokenStorage mandatory mapping the token store interface
func (*Manager) RefreshAccessToken ¶
func (m *Manager) RefreshAccessToken(ctx context.Context, tgr *oauth2.TokenGenerateRequest) (oauth2.TokenInfo, error)
RefreshAccessToken refreshing an access token
func (*Manager) RemoveAccessToken ¶
RemoveAccessToken use the access token to delete the token information
func (*Manager) RemoveRefreshToken ¶
RemoveRefreshToken use the refresh token to delete the token information
func (*Manager) SetAuthorizeCodeExp ¶
SetAuthorizeCodeExp set the authorization code expiration time
func (*Manager) SetAuthorizeCodeTokenCfg ¶
SetAuthorizeCodeTokenCfg set the authorization code grant token config
func (*Manager) SetClientTokenCfg ¶
SetClientTokenCfg set the client grant token config
func (*Manager) SetImplicitTokenCfg ¶
SetImplicitTokenCfg set the implicit grant token config
func (*Manager) SetPasswordTokenCfg ¶
SetPasswordTokenCfg set the password grant token config
func (*Manager) SetRefreshTokenCfg ¶
func (m *Manager) SetRefreshTokenCfg(cfg *RefreshingConfig)
SetRefreshTokenCfg set the refreshing token config
func (*Manager) SetValidateURIHandler ¶
func (m *Manager) SetValidateURIHandler(handler ValidateURIHandler)
SetValidateURIHandler set the validates that RedirectURI is contained in baseURI
type RefreshingConfig ¶
type RefreshingConfig struct { // access token expiration time, 0 means it doesn't expire AccessTokenExp time.Duration // refresh token expiration time, 0 means it doesn't expire RefreshTokenExp time.Duration // whether to generate the refreshing token IsGenerateRefresh bool // whether to reset the refreshing create time IsResetRefreshTime bool // whether to remove access token IsRemoveAccess bool // whether to remove refreshing token IsRemoveRefreshing bool }
RefreshingConfig refreshing token config
type ValidateURIHandler ¶
ValidateURIHandler validates that redirectURI is contained in baseURI