authx

package
v0.0.0-...-11273d6 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	UnauthorizedErrorCode = "unauthorized"
	TokenExpiredErrorCode = "token_expired"
)

Variables

This section is empty.

Functions

func MemeoryStore

func MemeoryStore(server *Server)

export

func NewFileTokenStore

func NewFileTokenStore(filename string) (oauth2.TokenStore, error)

func NewMemoryTokenStore

func NewMemoryTokenStore() oauth2.TokenStore

func NewMultiLevelTokenStore

func NewMultiLevelTokenStore(stores ...oauth2.TokenStore) oauth2.TokenStore

func NewTokenExtension

func NewTokenExtension(tes ...TokenExtension) func(oauth2.TokenInfo) map[string]interface{}

func UserExtension

func UserExtension(fieldsValue map[string]interface{}, ti oauth2.TokenInfo)

Types

type AuthClient

type AuthClient models.Client

func (*AuthClient) GetDomain

func (ac *AuthClient) GetDomain() string

func (*AuthClient) GetID

func (ac *AuthClient) GetID() string

func (*AuthClient) GetSecret

func (ac *AuthClient) GetSecret() string

func (*AuthClient) GetUserID

func (ac *AuthClient) GetUserID() string

type AuthOption

type AuthOption func(server *Server)

func AppTokenCfg

func AppTokenCfg(exps ...time.Duration) AuthOption

export

func FileStore

func FileStore(file string) AuthOption

export

func WebTokenCfg

func WebTokenCfg(exps ...time.Duration) AuthOption

export

type ClientInfo

type ClientInfo interface {
	oauth2.ClientInfo
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewOAuthServer

func NewOAuthServer() *Server

func SetupPasswordAuthServer

func SetupPasswordAuthServer(client ClientInfo, pwdHandler func(username, password string) (string, error), tokenStore oauth2.TokenStore, opts ...AuthOption) *Server

export nolint[lll]

func (*Server) HandleTokenRequest

func (as *Server) HandleTokenRequest(w http.ResponseWriter, r *http.Request)

func (*Server) RemoveAccessToken

func (as *Server) RemoveAccessToken(access string) (err error)

func (*Server) RemoveRefreshToken

func (as *Server) RemoveRefreshToken(refresh string) (err error)

func (*Server) SetClientStore

func (as *Server) SetClientStore(clientStore oauth2.ClientStore)

func (*Server) SetClients

func (as *Server) SetClients(clients ...ClientInfo)

func (*Server) SetExtensionFieldsHandler

func (as *Server) SetExtensionFieldsHandler(handler func(ti oauth2.TokenInfo) map[string]interface{})

func (*Server) SetPasswordAuthorizationHandler

func (as *Server) SetPasswordAuthorizationHandler(handler func(username, password string) (string, error))

func (*Server) SetPasswordTokenCfg

func (as *Server) SetPasswordTokenCfg(accessTokenExp, refreshTokenExp time.Duration, isGenerateRefresh bool)

func (*Server) SetRefreshTokenCfg

func (as *Server) SetRefreshTokenCfg(accessTokenExp, refreshTokenExp time.Duration, isGenerateRefresh, isRemoveAccess, isRemoveRefreshing bool, isResetRefreshTime bool)

nolint[lll]

func (*Server) SetTokenStorage

func (as *Server) SetTokenStorage(tokenStore oauth2.TokenStore)

func (*Server) ValidateToken

func (as *Server) ValidateToken(w http.ResponseWriter, r *http.Request) (ti oauth2.TokenInfo, err error)

type TokenExtension

type TokenExtension func(map[string]interface{}, oauth2.TokenInfo)

Jump to

Keyboard shortcuts

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