Documentation ¶
Index ¶
- func ParseBasicAuth(auth string) (username, password string, ok bool)
- type ClientAuthorizedHandler
- type ClientScopeHandler
- type ClientStore
- type ExtensionFieldsHandler
- type InternalErrorHandler
- type PasswordAuthorizationHandler
- type RefreshingScopeHandler
- type ResponseErrorHandler
- type Server
- func (s *Server) CheckGrantType(gt oauth2.GrantType) bool
- func (s *Server) CheckResponseType(rt oauth2.ResponseType) bool
- func (s *Server) GetAccessToken(ctx context.Context, gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest) (oauth2.TokenInfo, error)
- func (s *Server) GetAuthorizeData(rt oauth2.ResponseType, ti oauth2.TokenInfo) map[string]interface{}
- func (s *Server) GetAuthorizeToken(ctx context.Context, req *oauth.OauthReq) (ti oauth2.TokenInfo, err error)
- func (s *Server) GetErrorData(err error) (map[string]interface{}, int, http.Header)
- func (s *Server) GetRedirectURI(req *oauth.OauthReq, data map[string]interface{}) (uri string, err error)
- func (s *Server) GetTokenData(ti oauth2.TokenInfo) map[string]interface{}
- func (s *Server) HandleAuthorizeRequest(ctx context.Context, req *oauth.OauthReq, token string) (w *response.HttpResponse)
- func (s *Server) HandleTokenRequest(ctx context.Context, r *oauth.OauthReq) (*response.HttpResponse, error)
- func (s *Server) ValidationAuthorizeRequest(req *oauth.OauthReq) error
- func (s *Server) ValidationTokenRequest(r *oauth.OauthReq) (*oauth2.TokenGenerateRequest, error)
- type UserAuthorizationHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseBasicAuth ¶
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 ¶
ClientScopeHandler check the client allows to use scope
type ClientStore ¶
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 ¶
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 ¶
RefreshingScopeHandler check the scope of the refreshing token
type ResponseErrorHandler ¶
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 (*Server) CheckGrantType ¶
func (*Server) CheckResponseType ¶
func (*Server) GetAccessToken ¶
func (*Server) GetAuthorizeData ¶
func (*Server) GetAuthorizeToken ¶
func (*Server) GetErrorData ¶
func (*Server) GetRedirectURI ¶
func (*Server) GetTokenData ¶
func (*Server) HandleAuthorizeRequest ¶
func (*Server) HandleTokenRequest ¶
func (*Server) ValidationAuthorizeRequest ¶
type UserAuthorizationHandler ¶
UserAuthorizationHandler get user id from request authorization