middleware

package
v0.0.0-...-015e9e7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Services   map[string]interface{}
	AuthServer *server.Server
)

Functions

func Cors

func Cors() gin.HandlerFunc

Cors : 跨域配置

func GetCurrentUser

func GetCurrentUser(ctx *gin.Context) (string, *dto.UserDto)

GetCurrentUser: 获取当前请求登陆的用户

func JWT

func JWT() gin.HandlerFunc

JWT: OAUTH校验JWT TOKEN

func SaveServices

func SaveServices(service []interface{}) gin.HandlerFunc

SaveServices : 将服务实例存放到gin中

func TokenExpHandler

func TokenExpHandler(w http.ResponseWriter, r *http.Request) (exp time.Duration, err error)

TokenExpHandler: 令牌过期时间 默认两天

func UserAuthorizeHandler

func UserAuthorizeHandler(w http.ResponseWriter, r *http.Request) (userID string, err error)

UserAuthorizeHandler: 授权码式授权-用户授权环节-从请求中解析出userID

func ValidPasswordHandler

func ValidPasswordHandler(username, password string) (userID string, err error)

ValidPasswordHandler: 密码式授权-校验密码

Types

type ClientStore

type ClientStore struct {
}

func (*ClientStore) GetByID

func (c *ClientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error)

Jump to

Keyboard shortcuts

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