oauth

package
v1.12.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: MIT Imports: 15 Imported by: 0

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 gorm.DB

ClientStore client information store

func NewClientStore

func NewClientStore(db *gorm.DB) *ClientStore

NewClientStore create client store

func (*ClientStore) GetByID

func (cs *ClientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error)

GetByID according to the ID for the client information

func (*ClientStore) Set

func (cs *ClientStore) Set(cli oauth2.ClientInfo) (err error)

Set set client information

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 *oauth.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 *oauth.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 *oauth.OauthReq, token string) (w *response.HttpResponse)

func (*Server) HandleTokenRequest

func (s *Server) HandleTokenRequest(ctx context.Context, r *oauth.OauthReq) (*response.HttpResponse, error)

func (*Server) ValidationAuthorizeRequest

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

func (*Server) ValidationTokenRequest

func (s *Server) ValidationTokenRequest(r *oauth.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