Documentation
¶
Index ¶
- func ClientBasicHandler(r *http.Request) (clientID, clientSecret string, err error)
- func ClientFormHandler(r *http.Request) (clientID, clientSecret string, err error)
- type AuthorizeRequest
- type ClientAuthorizedHandler
- type ClientInfoHandler
- type ClientScopeHandler
- type Config
- type ErrorHandler
- type PasswordAuthorizationHandler
- type RefreshingScopeHandler
- type Server
- func (s *Server) CheckGrantType(gt oauth2.GrantType) bool
- func (s *Server) CheckResponseType(rt oauth2.ResponseType) bool
- func (s *Server) GetAccessToken(gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest) (ti oauth2.TokenInfo, rerr, ierr error)
- func (s *Server) GetAuthorizeData(rt oauth2.ResponseType, ti oauth2.TokenInfo) (data map[string]interface{})
- func (s *Server) GetAuthorizeToken(req *AuthorizeRequest) (ti oauth2.TokenInfo, rerr, ierr error)
- func (s *Server) GetErrorData(rerr, ierr error) (data map[string]interface{})
- func (s *Server) GetRedirectURI(req *AuthorizeRequest, data map[string]interface{}) (uri string, err error)
- func (s *Server) GetTokenData(ti oauth2.TokenInfo) (data map[string]interface{})
- func (s *Server) HandleAuthorizeRequest(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) HandleTokenRequest(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) SetAllowedGrantType(types ...oauth2.GrantType)
- func (s *Server) SetAllowedResponseType(types ...oauth2.ResponseType)
- func (s *Server) SetClientAuthorizedHandler(handler ClientAuthorizedHandler)
- func (s *Server) SetClientInfoHandler(handler ClientInfoHandler)
- func (s *Server) SetClientScopeHandler(handler ClientScopeHandler)
- func (s *Server) SetErrorHandler(handler ErrorHandler)
- func (s *Server) SetPasswordAuthorizationHandler(handler PasswordAuthorizationHandler)
- func (s *Server) SetRefreshingScopeHandler(handler RefreshingScopeHandler)
- func (s *Server) SetUserAuthorizationHandler(handler UserAuthorizationHandler)
- func (s *Server) ValidationAuthorizeRequest(r *http.Request) (req *AuthorizeRequest, rerr, ierr error)
- func (s *Server) ValidationTokenRequest(r *http.Request) (gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest, rerr, ierr error)
- type UserAuthorizationHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientBasicHandler ¶
ClientBasicHandler Get client data from basic authorization
Types ¶
type AuthorizeRequest ¶
type AuthorizeRequest struct { ResponseType oauth2.ResponseType ClientID string Scope string RedirectURI string State string UserID string }
AuthorizeRequest The authorization request
type ClientAuthorizedHandler ¶
type ClientAuthorizedHandler func(clientID string, grantType oauth2.GrantType) (allowed bool, err error)
ClientAuthorizedHandler Check the client allows to use this authorization grant type
type ClientInfoHandler ¶
ClientInfoHandler Get client info from request
type ClientScopeHandler ¶
ClientScopeHandler Check the client allows to use scope
type Config ¶
type Config struct { TokenType string // TokenType token type(Default is Bearer) AllowedResponseTypes []oauth2.ResponseType // Allow the authorization type(Default is all) AllowedGrantTypes []oauth2.GrantType // Allow the grant type(Default is all) }
Config Configuration parameters
type PasswordAuthorizationHandler ¶
PasswordAuthorizationHandler Get user id from username and password
type RefreshingScopeHandler ¶
RefreshingScopeHandler Check the scope of the refreshing token
type Server ¶
type Server struct { Config *Config Manager oauth2.Manager ClientInfoHandler ClientInfoHandler ClientAuthorizedHandler ClientAuthorizedHandler ClientScopeHandler ClientScopeHandler UserAuthorizationHandler UserAuthorizationHandler PasswordAuthorizationHandler PasswordAuthorizationHandler RefreshingScopeHandler RefreshingScopeHandler ErrorHandler ErrorHandler }
Server Provide authorization server
func (*Server) CheckGrantType ¶
CheckGrantType Check allows grant type
func (*Server) CheckResponseType ¶
CheckResponseType Check allows response type
func (*Server) GetAccessToken ¶
func (s *Server) GetAccessToken(gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest) (ti oauth2.TokenInfo, rerr, ierr error)
GetAccessToken Get access token
func (*Server) GetAuthorizeData ¶
func (s *Server) GetAuthorizeData(rt oauth2.ResponseType, ti oauth2.TokenInfo) (data map[string]interface{})
GetAuthorizeData Get authorization response data
func (*Server) GetAuthorizeToken ¶
func (s *Server) GetAuthorizeToken(req *AuthorizeRequest) (ti oauth2.TokenInfo, rerr, ierr error)
GetAuthorizeToken Get authorization token(code)
func (*Server) GetErrorData ¶
GetErrorData Get error response data
func (*Server) GetRedirectURI ¶
func (s *Server) GetRedirectURI(req *AuthorizeRequest, data map[string]interface{}) (uri string, err error)
GetRedirectURI Get redirect uri
func (*Server) GetTokenData ¶
GetTokenData Get token data
func (*Server) HandleAuthorizeRequest ¶
HandleAuthorizeRequest The authorization request handling
func (*Server) HandleTokenRequest ¶
HandleTokenRequest The token request handling
func (*Server) SetAllowedGrantType ¶
func (s *Server) SetAllowedGrantType(types ...oauth2.GrantType)
SetAllowedGrantType Allow the grant types
func (*Server) SetAllowedResponseType ¶
func (s *Server) SetAllowedResponseType(types ...oauth2.ResponseType)
SetAllowedResponseType Allow the authorization types
func (*Server) SetClientAuthorizedHandler ¶
func (s *Server) SetClientAuthorizedHandler(handler ClientAuthorizedHandler)
SetClientAuthorizedHandler Check the client allows to use this authorization grant type
func (*Server) SetClientInfoHandler ¶
func (s *Server) SetClientInfoHandler(handler ClientInfoHandler)
SetClientInfoHandler Get client info from request
func (*Server) SetClientScopeHandler ¶
func (s *Server) SetClientScopeHandler(handler ClientScopeHandler)
SetClientScopeHandler Check the client allows to use scope
func (*Server) SetErrorHandler ¶
func (s *Server) SetErrorHandler(handler ErrorHandler)
SetErrorHandler Error handling
func (*Server) SetPasswordAuthorizationHandler ¶
func (s *Server) SetPasswordAuthorizationHandler(handler PasswordAuthorizationHandler)
SetPasswordAuthorizationHandler Get user id from username and password
func (*Server) SetRefreshingScopeHandler ¶
func (s *Server) SetRefreshingScopeHandler(handler RefreshingScopeHandler)
SetRefreshingScopeHandler Check the scope of the refreshing token
func (*Server) SetUserAuthorizationHandler ¶
func (s *Server) SetUserAuthorizationHandler(handler UserAuthorizationHandler)
SetUserAuthorizationHandler Get user id from request authorization
func (*Server) ValidationAuthorizeRequest ¶
func (s *Server) ValidationAuthorizeRequest(r *http.Request) (req *AuthorizeRequest, rerr, ierr error)
ValidationAuthorizeRequest The authorization request validation
type UserAuthorizationHandler ¶
type UserAuthorizationHandler func(w http.ResponseWriter, r *http.Request) (userID string, err error)
UserAuthorizationHandler Get user id from request authorization