Documentation ¶
Index ¶
- func ClientBasicHandler(r *http.Request) (string, string, error)
- func ClientFormHandler(r *http.Request) (string, string, error)
- type AccessTokenExpHandler
- type AuthorizeRequest
- type AuthorizeScopeHandler
- type ClientAuthorizedHandler
- type ClientInfoHandler
- type ClientScopeHandler
- type Config
- type ExtensionFieldsHandler
- type InternalErrorHandler
- type PasswordAuthorizationHandler
- type RefreshingScopeHandler
- type ResponseErrorHandler
- type Server
- func (s *Server) BearerAuth(r *http.Request) (string, bool)
- 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 *AuthorizeRequest) (oauth2.TokenInfo, error)
- func (s *Server) GetErrorData(err error) (map[string]interface{}, int, http.Header)
- func (s *Server) GetRedirectURI(req *AuthorizeRequest, data map[string]interface{}) (string, error)
- func (s *Server) GetTokenData(ti oauth2.TokenInfo) map[string]interface{}
- func (s *Server) HandleAuthorizeRequest(w http.ResponseWriter, r *http.Request) error
- func (s *Server) HandleTokenRequest(w http.ResponseWriter, r *http.Request) error
- func (s *Server) SetAccessTokenExpHandler(handler AccessTokenExpHandler)
- func (s *Server) SetAllowGetAccessRequest(allow bool)
- func (s *Server) SetAllowedGrantType(types ...oauth2.GrantType)
- func (s *Server) SetAllowedResponseType(types ...oauth2.ResponseType)
- func (s *Server) SetAuthorizeScopeHandler(handler AuthorizeScopeHandler)
- func (s *Server) SetClientAuthorizedHandler(handler ClientAuthorizedHandler)
- func (s *Server) SetClientInfoHandler(handler ClientInfoHandler)
- func (s *Server) SetClientScopeHandler(handler ClientScopeHandler)
- func (s *Server) SetExtensionFieldsHandler(handler ExtensionFieldsHandler)
- func (s *Server) SetInternalErrorHandler(handler InternalErrorHandler)
- func (s *Server) SetPasswordAuthorizationHandler(handler PasswordAuthorizationHandler)
- func (s *Server) SetRefreshingScopeHandler(handler RefreshingScopeHandler)
- func (s *Server) SetResponseErrorHandler(handler ResponseErrorHandler)
- func (s *Server) SetTokenType(tokenType string)
- func (s *Server) SetUserAuthorizationHandler(handler UserAuthorizationHandler)
- func (s *Server) ValidationAuthorizeRequest(r *http.Request) (*AuthorizeRequest, error)
- func (s *Server) ValidationBearerToken(r *http.Request) (oauth2.TokenInfo, error)
- func (s *Server) ValidationTokenRequest(r *http.Request) (oauth2.GrantType, *oauth2.TokenGenerateRequest, 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 AccessTokenExpHandler ¶
type AccessTokenExpHandler func(w http.ResponseWriter, r *http.Request) (exp time.Duration, err error)
AccessTokenExpHandler set expiration date for the access token
type AuthorizeRequest ¶
type AuthorizeRequest struct { ResponseType oauth2.ResponseType ClientID string Scope string RedirectURI string State string UserID string AccessTokenExp time.Duration Request *http.Request }
AuthorizeRequest authorization request
type AuthorizeScopeHandler ¶
AuthorizeScopeHandler set the authorized scope
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 ClientInfoHandler ¶
ClientInfoHandler get client info from request
type ClientScopeHandler ¶
ClientScopeHandler check the client allows to use scope
type Config ¶
type Config struct { TokenType string // token type AllowGetAccessRequest bool // to allow GET requests for the token AllowedResponseTypes []oauth2.ResponseType // allow the authorization type AllowedGrantTypes []oauth2.GrantType // allow the grant type }
Config configuration parameters
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 ¶
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 *Config Manager oauth2.Manager ClientInfoHandler ClientInfoHandler ClientAuthorizedHandler ClientAuthorizedHandler ClientScopeHandler ClientScopeHandler UserAuthorizationHandler UserAuthorizationHandler PasswordAuthorizationHandler PasswordAuthorizationHandler RefreshingScopeHandler RefreshingScopeHandler ResponseErrorHandler ResponseErrorHandler InternalErrorHandler InternalErrorHandler ExtensionFieldsHandler ExtensionFieldsHandler AccessTokenExpHandler AccessTokenExpHandler AuthorizeScopeHandler AuthorizeScopeHandler }
Server Provide authorization server
func NewDefaultServer ¶
func NewDefaultServer(manager oauth2.Manager) *Server
NewDefaultServer create a default authorization server
func (*Server) BearerAuth ¶
BearerAuth parse bearer token
func (*Server) CheckGrantType ¶
CheckGrantType check allows grant type
func (*Server) CheckResponseType ¶
CheckResponseType check allows response type
func (*Server) GetAccessToken ¶
func (s *Server) GetAccessToken(ctx context.Context, gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest) (oauth2.TokenInfo, error)
GetAccessToken access token
func (*Server) GetAuthorizeData ¶
func (s *Server) GetAuthorizeData(rt oauth2.ResponseType, ti oauth2.TokenInfo) map[string]interface{}
GetAuthorizeData get authorization response data
func (*Server) GetAuthorizeToken ¶
func (s *Server) GetAuthorizeToken(ctx context.Context, req *AuthorizeRequest) (oauth2.TokenInfo, 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{}) (string, error)
GetRedirectURI get redirect uri
func (*Server) GetTokenData ¶
GetTokenData token data
func (*Server) HandleAuthorizeRequest ¶
HandleAuthorizeRequest the authorization request handling
func (*Server) HandleTokenRequest ¶
HandleTokenRequest token request handling
func (*Server) SetAccessTokenExpHandler ¶
func (s *Server) SetAccessTokenExpHandler(handler AccessTokenExpHandler)
SetAccessTokenExpHandler set expiration date for the access token
func (*Server) SetAllowGetAccessRequest ¶
SetAllowGetAccessRequest to allow GET requests for the token
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) SetAuthorizeScopeHandler ¶
func (s *Server) SetAuthorizeScopeHandler(handler AuthorizeScopeHandler)
SetAuthorizeScopeHandler set scope for the access token
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) SetExtensionFieldsHandler ¶
func (s *Server) SetExtensionFieldsHandler(handler ExtensionFieldsHandler)
SetExtensionFieldsHandler in response to the access token with the extension of the field
func (*Server) SetInternalErrorHandler ¶
func (s *Server) SetInternalErrorHandler(handler InternalErrorHandler)
SetInternalErrorHandler internal 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) SetResponseErrorHandler ¶
func (s *Server) SetResponseErrorHandler(handler ResponseErrorHandler)
SetResponseErrorHandler response error handling
func (*Server) SetTokenType ¶
SetTokenType token type
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) (*AuthorizeRequest, error)
ValidationAuthorizeRequest the authorization request validation
func (*Server) ValidationBearerToken ¶
ValidationBearerToken validation the bearer tokens https://tools.ietf.org/html/rfc6750
type UserAuthorizationHandler ¶
type UserAuthorizationHandler func(w http.ResponseWriter, r *http.Request) (userID string, err error)
UserAuthorizationHandler get user id from request authorization