auth

package
v1.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAuthorizeCode

func GetAuthorizeCode(c *gin.Context)

func GetToken

func GetToken(c *gin.Context)

func GetUserByToken added in v1.9.1

func GetUserByToken(accessToken string) (u entity.User, err error)

func InitAuthRouter

func InitAuthRouter(r gin.IRouter)

Types

type GetAuthorizeCodeReq

type GetAuthorizeCodeReq struct {
	ClientID     string   `json:"client_id"`
	ResponseType string   `json:"response_type"` // 此处应固定填写为code
	State        string   `json:"state"`         // 第三方指定任意值
	Scopes       []string `json:"scope"`         // 获取的权限,可选
	AccessToken  string   `json:"access_token"`  // access_token
}

type GetAuthorizeCodeResp

type GetAuthorizeCodeResp struct {
	Code string `json:"code"`
}

type GetTokenReq

type GetTokenReq struct {
	GrantType    string `json:"grant_type"` // 授权类型
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`

	Code string `json:"code"` // grant type为authorization_code时使用

	AccountName string `json:"account_name"` // 密码授权模式
	Password    string `json:"password"`     // 密码授权模式

	RefreshToken string `json:"refresh_token"` // 刷新token

	AreaID uint64   `json:"area_id"`
	Scopes []string `json:"scopes"`
}

func (*GetTokenReq) HandleTokenRequest

func (req *GetTokenReq) HandleTokenRequest(c *gin.Context) (oauth2.GrantType, *oauth2.TokenGenerateRequest, error)

HandleTokenRequest 处理token请求

type GetTokenResp

type GetTokenResp struct {
	TokenInfo TokenInfo       `json:"token_info"`
	UserInfo  entity.UserInfo `json:"user_info,omitempty"`
}

type TokenInfo

type TokenInfo struct {
	AccessToken     string `json:"access_token" `
	AccessTokenExp  int64  `json:"access_token_exp"`
	RefreshToken    string `json:"refresh_token"`
	RefreshTokenExp int64  `json:"refresh_token_exp"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL