Documentation ¶
Index ¶
- Constants
- func ClientStore() oauth2.ClientStore
- func Init()
- func InitClientStore() oauth2.ClientStore
- func NewDatabaseClientStore() (oauth2.ClientStore, error)
- func ScopeJoin(scope []Scope) string
- func ValidationBearerToken(c *gin.Context) (oauth2.TokenInfo, error)
- type ContextKey
- type DatabaseClientStore
- type IEmailUserHandler
- type IMobileUserHandler
- type ISocialUserHandler
- type IUserHandler
- type LoginForm
- type OAuth2Controller
- func (o *OAuth2Controller) Auth(c *gin.Context)
- func (o *OAuth2Controller) Authorize(c *gin.Context)
- func (o *OAuth2Controller) GetTokenRedis(method, code string) (oauth2.TokenInfo, error)
- func (o *OAuth2Controller) HandleTokenRequest(c *gin.Context)
- func (c *OAuth2Controller) InitRouter(g *gin.RouterGroup) *gin.RouterGroup
- func (o *OAuth2Controller) Login(c *gin.Context)
- func (o *OAuth2Controller) QueryToken(c *gin.Context)
- type OAuth2Server
- func (s *OAuth2Server) ClientInfoHandler(r *http.Request) (string, string, error)
- func (s *OAuth2Server) GetTokenData(ti oauth2.TokenInfo) map[string]interface{}
- func (s *OAuth2Server) HandleAuthorizeRequest(w http.ResponseWriter, r *http.Request) error
- func (s *OAuth2Server) HandleTokenRequest(w http.ResponseWriter, r *http.Request) error
- func (s *OAuth2Server) ValidationBearerToken(r *http.Request) (oauth2.TokenInfo, error)
- type OAuthClient
- type Scope
Constants ¶
View Source
const AppIdContextKey = ContextKey("appId")
View Source
const (
ErrorsNoToken string = "no Token Verifier"
)
Variables ¶
This section is empty.
Functions ¶
func ClientStore ¶
func ClientStore() oauth2.ClientStore
func InitClientStore ¶
func InitClientStore() oauth2.ClientStore
func NewDatabaseClientStore ¶
func NewDatabaseClientStore() (oauth2.ClientStore, error)
NewClientStore create client store *
- Database Client Store
func ValidationBearerToken ¶
Types ¶
type ContextKey ¶
type ContextKey string
type DatabaseClientStore ¶
ClientStore client information store
type IEmailUserHandler ¶
type IEmailUserHandler interface {
GetEmailUserDetails(ctx context.Context, email string, code string) (*SecurityModel.UserDetails, error)
}
type IMobileUserHandler ¶
type IMobileUserHandler interface {
GetMobileUserDetails(ctx context.Context, mobile string, code string) (*SecurityModel.UserDetails, error)
}
type ISocialUserHandler ¶
type ISocialUserHandler interface {
GetSocialUserDetails(ctx context.Context, social string, code string) (*SecurityModel.UserDetails, error)
}
type IUserHandler ¶
type IUserHandler interface {
GetUserDetails(ctx context.Context, username string, password string) (*SecurityModel.UserDetails, error)
}
type OAuth2Controller ¶
type OAuth2Controller struct { controller.ResourceController OAuth2Server *OAuth2Server `inject:"oauth2Server"` TokenStore oauth2.TokenStore `inject:"tokenStore"` // contains filtered or unexported fields }
func (*OAuth2Controller) Auth ¶
func (o *OAuth2Controller) Auth(c *gin.Context)
*
- GET /auth *
- OK => auth.html 授权页面
func (*OAuth2Controller) Authorize ¶
func (o *OAuth2Controller) Authorize(c *gin.Context)
*
- POST /authorize *
- 授权接口:
func (*OAuth2Controller) GetTokenRedis ¶
func (o *OAuth2Controller) GetTokenRedis(method, code string) (oauth2.TokenInfo, error)
func (*OAuth2Controller) HandleTokenRequest ¶
func (o *OAuth2Controller) HandleTokenRequest(c *gin.Context)
*
- POST /token *
- 处理token请求
func (*OAuth2Controller) InitRouter ¶
func (c *OAuth2Controller) InitRouter(g *gin.RouterGroup) *gin.RouterGroup
func (*OAuth2Controller) QueryToken ¶
func (o *OAuth2Controller) QueryToken(c *gin.Context)
*
- GET /token *
- 根据授权码获取已授权的Token
type OAuth2Server ¶
type OAuth2Server struct { ClientStore oauth2.ClientStore `inject:"clientStore"` TokenStore oauth2.TokenStore `inject:"tokenStore"` AccessGenerate oauth2.AccessGenerate `inject:"accessGenerate"` // AuthorizeGenerate oauth2.AuthorizeGenerate `inject:"authorizeGenerate"` UserHandler IUserHandler `inject:"userHandler"` MobileUserHandler IMobileUserHandler `inject:"userHandler"` EmailUserHandler IEmailUserHandler `inject:"userHandler"` SocialUserHandler ISocialUserHandler `inject:"userHandler"` // contains filtered or unexported fields }
func (*OAuth2Server) ClientInfoHandler ¶
func (*OAuth2Server) GetTokenData ¶
func (s *OAuth2Server) GetTokenData(ti oauth2.TokenInfo) map[string]interface{}
func (*OAuth2Server) HandleAuthorizeRequest ¶
func (s *OAuth2Server) HandleAuthorizeRequest(w http.ResponseWriter, r *http.Request) error
func (*OAuth2Server) HandleTokenRequest ¶
func (s *OAuth2Server) HandleTokenRequest(w http.ResponseWriter, r *http.Request) error
func (*OAuth2Server) ValidationBearerToken ¶
func (s *OAuth2Server) ValidationBearerToken(r *http.Request) (oauth2.TokenInfo, error)
type OAuthClient ¶
type OAuthClient struct { ClientId string `gorm:"primaryKey"` ClientSecret string `` ResourceIds string `` Scope string `` CreatedBy string `json:"created_by"` CreatedTime time.Time `gorm:"autoCreateTime;type:TIMESTAMP;default:CURRENT_TIMESTAMP;<-:create" json:"created_time"` ModifiedBy string `json:"modified_by"` ModifiedTime time.Time `gorm:"autoUpdateTime;type:TIMESTAMP;default:CURRENT_TIMESTAMP on update current_timestamp" json:"modified_time"` DelFlag bool `gorm:"default:false" json:"del_flag"` }
*
- OAuth2 Client: webapp/1234567890
func (*OAuthClient) GetDomain ¶
func (c *OAuthClient) GetDomain() string
func (*OAuthClient) GetID ¶
func (c *OAuthClient) GetID() string
func (*OAuthClient) GetSecret ¶
func (c *OAuthClient) GetSecret() string
func (*OAuthClient) GetUserID ¶
func (c *OAuthClient) GetUserID() string
func (*OAuthClient) IsPublic ¶
func (c *OAuthClient) IsPublic() bool
func (*OAuthClient) TableName ¶
func (c *OAuthClient) TableName() string
func (*OAuthClient) VerifyPassword ¶
func (c *OAuthClient) VerifyPassword(password string) bool
*
- OAuth2 校验 ClientSecret 方法
- TODO: 数据库保存ClientSecret
Source Files ¶
Click to show internal directories.
Click to hide internal directories.