manage

package
v3.9.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func DefaultValidateURI(baseURI string, redirectURI string) (err error)

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 NewManager

func NewManager() *Manager

NewManager create to authorization management instance

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) GetClient

func (m *Manager) GetClient(clientID string) (cli oauth2.ClientInfo, err error)

GetClient get the client information

func (*Manager) LoadAccessToken

func (m *Manager) LoadAccessToken(access string) (info oauth2.TokenInfo, err error)

LoadAccessToken according to the access token for corresponding token information

func (*Manager) LoadRefreshToken

func (m *Manager) LoadRefreshToken(refresh string) (info oauth2.TokenInfo, err error)

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(tgr *oauth2.TokenGenerateRequest) (accessToken oauth2.TokenInfo, err error)

RefreshAccessToken refreshing an access token

func (*Manager) RemoveAccessToken

func (m *Manager) RemoveAccessToken(access string) (err error)

RemoveAccessToken use the access token to delete the token information

func (*Manager) RemoveRefreshToken

func (m *Manager) RemoveRefreshToken(refresh string) (err error)

RemoveRefreshToken use the refresh token to delete the token information

func (*Manager) SetAuthorizeCodeExp

func (m *Manager) SetAuthorizeCodeExp(exp time.Duration)

SetAuthorizeCodeExp set the authorization code expiration time

func (*Manager) SetAuthorizeCodeTokenCfg

func (m *Manager) SetAuthorizeCodeTokenCfg(cfg *Config)

SetAuthorizeCodeTokenCfg set the authorization code grant token config

func (*Manager) SetClientTokenCfg

func (m *Manager) SetClientTokenCfg(cfg *Config)

SetClientTokenCfg set the client grant token config

func (*Manager) SetImplicitTokenCfg

func (m *Manager) SetImplicitTokenCfg(cfg *Config)

SetImplicitTokenCfg set the implicit grant token config

func (*Manager) SetPasswordTokenCfg

func (m *Manager) SetPasswordTokenCfg(cfg *Config)

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

type ValidateURIHandler func(baseURI, redirectURI string) (err error)

ValidateURIHandler validates that redirectURI is contained in baseURI

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL