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 PreRedirectErrorHandler
- type RefreshingScopeHandler
- type RefreshingValidationHandler
- type ResponseErrorHandler
- type ResponseTokenHandler
- type Server
- func (s *Server) BearerAuth(r *http.Request) (string, bool)
- func (s *Server) CheckCodeChallengeMethod(ccm oauth2.CodeChallengeMethod) 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) SetPreRedirectErrorHandler(handler PreRedirectErrorHandler)
- func (s *Server) SetRefreshingScopeHandler(handler RefreshingScopeHandler)
- func (s *Server) SetRefreshingValidationHandler(handler RefreshingValidationHandler)
- func (s *Server) SetResponseErrorHandler(handler ResponseErrorHandler)
- func (s *Server) SetResponseTokenHandler(handler ResponseTokenHandler)
- 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 CodeChallenge string CodeChallengeMethod oauth2.CodeChallengeMethod 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 AllowedCodeChallengeMethods []oauth2.CodeChallengeMethod ForcePKCE bool }
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 ¶
type PasswordAuthorizationHandler func(ctx context.Context, clientID, username, password string) (userID string, err error)
PasswordAuthorizationHandler get user id from username and password
type PreRedirectErrorHandler ¶ added in v4.4.3
type PreRedirectErrorHandler func(w http.ResponseWriter, req *AuthorizeRequest, err error) error
PreRedirectErrorHandler is used to override "redirect-on-error" behavior
type RefreshingScopeHandler ¶
type RefreshingScopeHandler func(tgr *oauth2.TokenGenerateRequest, oldScope string) (allowed bool, err error)
RefreshingScopeHandler check the scope of the refreshing token
type RefreshingValidationHandler ¶ added in v4.2.0
RefreshingValidationHandler check if refresh_token is still valid. eg no revocation or other
type ResponseErrorHandler ¶
ResponseErrorHandler response error handing
type ResponseTokenHandler ¶ added in v4.4.2
type ResponseTokenHandler func(w http.ResponseWriter, data map[string]interface{}, header http.Header, statusCode ...int) error
ResponseTokenHandler response token handing
type Server ¶
type Server struct { Config *Config Manager oauth2.Manager ClientInfoHandler ClientInfoHandler ClientAuthorizedHandler ClientAuthorizedHandler ClientScopeHandler ClientScopeHandler UserAuthorizationHandler UserAuthorizationHandler PasswordAuthorizationHandler PasswordAuthorizationHandler RefreshingValidationHandler RefreshingValidationHandler PreRedirectErrorHandler PreRedirectErrorHandler RefreshingScopeHandler RefreshingScopeHandler ResponseErrorHandler ResponseErrorHandler InternalErrorHandler InternalErrorHandler ExtensionFieldsHandler ExtensionFieldsHandler AccessTokenExpHandler AccessTokenExpHandler AuthorizeScopeHandler AuthorizeScopeHandler ResponseTokenHandler ResponseTokenHandler }
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) CheckCodeChallengeMethod ¶ added in v4.2.0
CheckCodeChallengeMethod checks for allowed code challenge method
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) SetPreRedirectErrorHandler ¶ added in v4.4.3
func (s *Server) SetPreRedirectErrorHandler(handler PreRedirectErrorHandler)
SetPreRedirectErrorHandler sets the PreRedirectErrorHandler in current Server instance
func (*Server) SetRefreshingScopeHandler ¶
func (s *Server) SetRefreshingScopeHandler(handler RefreshingScopeHandler)
SetRefreshingScopeHandler check the scope of the refreshing token
func (*Server) SetRefreshingValidationHandler ¶ added in v4.2.0
func (s *Server) SetRefreshingValidationHandler(handler RefreshingValidationHandler)
SetRefreshingValidationHandler check if refresh_token is still valid. eg no revocation or other
func (*Server) SetResponseErrorHandler ¶
func (s *Server) SetResponseErrorHandler(handler ResponseErrorHandler)
SetResponseErrorHandler response error handling
func (*Server) SetResponseTokenHandler ¶ added in v4.4.2
func (s *Server) SetResponseTokenHandler(handler ResponseTokenHandler)
SetResponseTokenHandler response token handing
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