Documentation ¶
Index ¶
- Variables
- func DefaultValidateURI(baseURI string, redirectURI string) (err error)
- type Config
- type Manager
- func (m *Manager) CheckInterface() error
- func (m *Manager) GenerateAccessToken(gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest) (accessToken oauth2.TokenInfo, err error)
- func (m *Manager) GenerateAuthToken(rt oauth2.ResponseType, tgr *oauth2.TokenGenerateRequest) (authToken oauth2.TokenInfo, err error)
- func (m *Manager) GetClient(clientID string) (cli oauth2.ClientInfo, err error)
- func (m *Manager) LoadAccessToken(access string) (info oauth2.TokenInfo, err error)
- func (m *Manager) LoadRefreshToken(refresh string) (info oauth2.TokenInfo, err 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) MapTokenModel(token oauth2.TokenInfo)
- 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(tgr *oauth2.TokenGenerateRequest) (accessToken oauth2.TokenInfo, err error)
- func (m *Manager) RemoveAccessToken(access string) (err error)
- func (m *Manager) RemoveRefreshToken(refresh string) (err 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{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 AccessTokenExp time.Duration // refresh token expiration time 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) CheckInterface ¶
CheckInterface check the interface implementation
func (*Manager) GenerateAccessToken ¶
func (m *Manager) GenerateAccessToken(gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest) (accessToken oauth2.TokenInfo, err error)
GenerateAccessToken generate the access token
func (*Manager) GenerateAuthToken ¶
func (m *Manager) GenerateAuthToken(rt oauth2.ResponseType, tgr *oauth2.TokenGenerateRequest) (authToken oauth2.TokenInfo, err error)
GenerateAuthToken generate the authorization token(code)
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) MapTokenModel ¶
func (m *Manager) MapTokenModel(token oauth2.TokenInfo)
MapTokenModel mapping the token information model
func (*Manager) MapTokenStorage ¶
func (m *Manager) MapTokenStorage(stor oauth2.TokenStore)
MapTokenStorage mapping the token store interface
func (*Manager) MustClientStorage ¶
MustClientStorage mandatory mapping the client store interface
func (*Manager) MustTokenStorage ¶
MustTokenStorage mandatory mapping the token store interface
func (*Manager) RefreshAccessToken ¶
func (m *Manager) RefreshAccessToken(tgr *oauth2.TokenGenerateRequest) (accessToken oauth2.TokenInfo, err 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 AccessTokenExp time.Duration // refresh token expiration time 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