Documentation ¶
Index ¶
- Variables
- func ClientBasicHandler(r *http.Request) (clientID, clientSecret string, err error)
- func ClientFormHandler(r *http.Request) (clientID, clientSecret string, err error)
- type AuthorizeRequest
- type ClientHandler
- type Config
- type ScopeHandler
- type Server
- func (s *Server) GetAuthorizeRequest(r *http.Request) (authReq *AuthorizeRequest, err error)
- func (s *Server) HandleAuthorizeRequest(w http.ResponseWriter, authReq *AuthorizeRequest) (err error)
- func (s *Server) HandleTokenRequest(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) ResJSON(w http.ResponseWriter, ti oauth2.TokenInfo) (err error)
- func (s *Server) ResRedirectURI(w http.ResponseWriter, authReq *AuthorizeRequest, ti oauth2.TokenInfo) (err error)
- func (s *Server) SetAllowedGrantType(allowedTypes ...oauth2.GrantType)
- func (s *Server) SetAllowedResponseType(allowedTypes ...oauth2.ResponseType)
- func (s *Server) SetClientHandler(handler ClientHandler)
- func (s *Server) SetScopeHandler(handler ScopeHandler)
- func (s *Server) SetTokenType(tokenType string)
- func (s *Server) SetUserHandler(handler UserHandler)
- type TokenRequestHandler
- type UserHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrRequestMethodInvalid Request method invalid ErrRequestMethodInvalid = errors.New("request method invalid") // ErrResponseTypeInvalid Response type invalid ErrResponseTypeInvalid = errors.New("response type invalid") // ErrGrantTypeInvalid Grant type invalid ErrGrantTypeInvalid = errors.New("grant type invalid") // ErrClientInvalid Client invalid ErrClientInvalid = errors.New("client invalid") // ErrUserInvalid User invalid ErrUserInvalid = errors.New("user invalid") // ErrAuthorizationFormInvalid Authorization form invalid ErrAuthorizationFormInvalid = errors.New("authorization form invalid") // ErrAuthorizationHeaderInvalid Authorization header invalid ErrAuthorizationHeaderInvalid = errors.New("authorization header invalid") // ErrRefreshInvalid Refresh token invalid ErrRefreshInvalid = errors.New("refresh token invalid") )
Functions ¶
func ClientBasicHandler ¶
ClientBasicHandler 客户端基础认证信息
Types ¶
type AuthorizeRequest ¶
type AuthorizeRequest struct { Type oauth2.ResponseType ClientID string Scope string RedirectURI string State string UserID string }
AuthorizeRequest 授权请求
type ClientHandler ¶
ClientHandler 客户端处理(获取请求的客户端认证信息)
type Config ¶
type Config struct { // TokenType 令牌类型(默认为Bearer) TokenType string // AllowedResponseType 允许的授权类型(默认code) AllowedResponseType []oauth2.ResponseType // AllowedGrantType 允许的授权模式(默认authorization_code) AllowedGrantType []oauth2.GrantType // Handler 令牌请求处理 Handler *TokenRequestHandler }
Config 配置参数
type ScopeHandler ¶
ScopeHandler 授权范围处理(更新令牌时的授权范围检查)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server OAuth2服务处理
func (*Server) GetAuthorizeRequest ¶
func (s *Server) GetAuthorizeRequest(r *http.Request) (authReq *AuthorizeRequest, err error)
GetAuthorizeRequest 获取授权请求参数
func (*Server) HandleAuthorizeRequest ¶
func (s *Server) HandleAuthorizeRequest(w http.ResponseWriter, authReq *AuthorizeRequest) (err error)
HandleAuthorizeRequest 处理授权请求
func (*Server) HandleTokenRequest ¶
HandleTokenRequest 处理令牌请求 cli 获取客户端信息 user 获取用户信息
func (*Server) ResJSON ¶
func (s *Server) ResJSON(w http.ResponseWriter, ti oauth2.TokenInfo) (err error)
ResJSON 响应Json数据
func (*Server) ResRedirectURI ¶
func (s *Server) ResRedirectURI(w http.ResponseWriter, authReq *AuthorizeRequest, ti oauth2.TokenInfo) (err error)
ResRedirectURI 响应数据到重定向URI
func (*Server) SetAllowedGrantType ¶
func (s *Server) SetAllowedGrantType(allowedTypes ...oauth2.GrantType)
SetAllowedGrantType 允许的授权模式
func (*Server) SetAllowedResponseType ¶
func (s *Server) SetAllowedResponseType(allowedTypes ...oauth2.ResponseType)
SetAllowedResponseType 设置允许的授权类型
func (*Server) SetClientHandler ¶
func (s *Server) SetClientHandler(handler ClientHandler)
SetClientHandler 设置客户端处理
func (*Server) SetScopeHandler ¶
func (s *Server) SetScopeHandler(handler ScopeHandler)
SetScopeHandler 设置授权范围处理
func (*Server) SetUserHandler ¶
func (s *Server) SetUserHandler(handler UserHandler)
SetUserHandler 设置用户处理
type TokenRequestHandler ¶
type TokenRequestHandler struct { ClientHandler ClientHandler UserHandler UserHandler ScopeHandler ScopeHandler }
TokenRequestHandler 令牌请求处理
type UserHandler ¶
UserHandler 用户处理(密码模式,根据用户名、密码获取用户标识)
Click to show internal directories.
Click to hide internal directories.