oauth

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT, Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBasicAuth

func ParseBasicAuth(auth string) (username, password string, ok bool)

Types

type ClientAuthorizedHandler

type ClientAuthorizedHandler func(clientID string, grant oauth2.GrantType) (allowed bool, err error)

ClientAuthorizedHandler check the client allows to use this authorization grant type

type ClientScopeHandler

type ClientScopeHandler func(clientID, scope string) (allowed bool, err error)

ClientScopeHandler check the client allows to use scope

type ClientStore

type ClientStore interface {
	GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error)
	Set(cli oauth2.ClientInfo) (err error)
}

ClientStore client information store

type ExtensionFieldsHandler

type ExtensionFieldsHandler func(ti oauth2.TokenInfo) (fieldsValue map[string]interface{})

ExtensionFieldsHandler in response to the access token with the extension of the field

type InternalErrorHandler

type InternalErrorHandler func(err error) (re *errors.Response)

InternalErrorHandler internal error handing

type PasswordAuthorizationHandler

type PasswordAuthorizationHandler func(username, password, verifyCode string) (userID string, err error)

PasswordAuthorizationHandler get user id from username and password

type RefreshingScopeHandler

type RefreshingScopeHandler func(newScope, oldScope string) (allowed bool, err error)

RefreshingScopeHandler check the scope of the refreshing token

type ResponseErrorHandler

type ResponseErrorHandler func(re *errors.Response)

ResponseErrorHandler response error handing

type Server

type Server struct {
	Config                   *server.Config
	Manager                  oauth2.Manager
	ClientAuthorizedHandler  ClientAuthorizedHandler
	ClientScopeHandler       ClientScopeHandler
	UserAuthorizationHandler UserAuthorizationHandler
	RefreshingScopeHandler   RefreshingScopeHandler
	ResponseErrorHandler     ResponseErrorHandler
	InternalErrorHandler     InternalErrorHandler
	ExtensionFieldsHandler   ExtensionFieldsHandler
}

func NewDefaultServer

func NewDefaultServer(manager oauth2.Manager) *Server

func NewServer

func NewServer(cfg *server.Config, manager oauth2.Manager) *Server

NewServer create authorization server

func (*Server) CheckGrantType

func (s *Server) CheckGrantType(gt oauth2.GrantType) bool

func (*Server) CheckResponseType

func (s *Server) CheckResponseType(rt oauth2.ResponseType) bool

func (*Server) GetAccessToken

func (s *Server) GetAccessToken(ctx context.Context, gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest) (oauth2.TokenInfo, error)

func (*Server) GetAuthorizeData

func (s *Server) GetAuthorizeData(rt oauth2.ResponseType, ti oauth2.TokenInfo) map[string]interface{}

func (*Server) GetAuthorizeToken

func (s *Server) GetAuthorizeToken(ctx context.Context, req *param.OauthReq) (ti oauth2.TokenInfo, err error)

func (*Server) GetErrorData

func (s *Server) GetErrorData(err error) (map[string]interface{}, int, http.Header)

func (*Server) GetRedirectURI

func (s *Server) GetRedirectURI(req *param.OauthReq, data map[string]interface{}) (uri string, err error)

func (*Server) GetTokenData

func (s *Server) GetTokenData(ti oauth2.TokenInfo) map[string]interface{}

func (*Server) HandleAuthorizeRequest

func (s *Server) HandleAuthorizeRequest(ctx context.Context, req *param.OauthReq, token string, w http.ResponseWriter)

func (*Server) HandleTokenRequest

func (s *Server) HandleTokenRequest(ctx context.Context, r *param.OauthReq, w http.ResponseWriter) error

func (*Server) ValidationAuthorizeRequest

func (s *Server) ValidationAuthorizeRequest(req *param.OauthReq) error

func (*Server) ValidationTokenRequest

func (s *Server) ValidationTokenRequest(r *param.OauthReq) (*oauth2.TokenGenerateRequest, error)

type UserAuthorizationHandler

type UserAuthorizationHandler func(token string) (userID string, err error)

UserAuthorizationHandler get user id from request authorization

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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