Documentation ¶
Index ¶
- Variables
- func Check(ctx iris.Context, currentUser *entity.User) error
- func CreateToken(user *entity.User) ([]byte, error)
- func CreateTokenPair(user *entity.User) (jwt.TokenPair, error)
- func CurrentUser(ctx iris.Context) *entity.User
- func GenerateToken(ctx iris.Context, user *entity.User) []byte
- func GenerateTokenPair(ctx iris.Context, user *entity.User) *jwt.TokenPair
- func Protected(ctx iris.Context)
- func RefreshToken(ctx iris.Context, user *entity.User) *jwt.TokenPair
- func ServeHTTP(ctx iris.Context)
- func Set(app *iris.Application)
- func VerifyToken(token []byte, currentUser *entity.User) (string, string, time.Duration, error)
- type UserClaims
- type UserController
- func (this *UserController) CurrentUser(ctx iris.Context) *entity.User
- func (this *UserController) GetCurrentUser(ctx iris.Context)
- func (this *UserController) GetCurrentUserName(ctx iris.Context) string
- func (this *UserController) Login(ctx iris.Context)
- func (this *UserController) Logout(ctx iris.Context)
- func (this *UserController) ParseJSON(json []byte) (interface{}, error)
- func (this *UserController) Regist(ctx iris.Context)
Constants ¶
This section is empty.
Variables ¶
View Source
var CasbinMemCache = cache.NewMemCache("casbin", 60, 10)
View Source
var MemCache = cache.NewMemCache("sessionUser", 60, 10)
Functions ¶
func GenerateToken ¶
* 产生新token,并设置cooki
func RefreshToken ¶
There are various methods of refresh token, depending on the application requirements. In this example we will accept a refresh token only, we will verify only a refresh token and we re-generate a whole new pair. An alternative would be to accept a token pair of both access and refresh tokens, verify the refresh, verify the access with a Leeway time and check if its going to expire soon, then generate a single access token.
Types ¶
type UserClaims ¶
type UserClaims struct {
UserName string `json:"userName"`
}
type UserController ¶
type UserController struct {
controller.BaseController
}
* 控制层代码需要做数据转换,调用服务层的代码,由于数据转换的结构不一致,因此每个实体(外部rest方式访问)的控制层都需要写一遍
func GetUserController ¶
func GetUserController() *UserController
func (*UserController) CurrentUser ¶
func (this *UserController) CurrentUser(ctx iris.Context) *entity.User
func (*UserController) GetCurrentUser ¶
func (this *UserController) GetCurrentUser(ctx iris.Context)
func (*UserController) GetCurrentUserName ¶
func (this *UserController) GetCurrentUserName(ctx iris.Context) string
func (*UserController) Login ¶
func (this *UserController) Login(ctx iris.Context)
func (*UserController) Logout ¶
func (this *UserController) Logout(ctx iris.Context)
func (*UserController) ParseJSON ¶
func (this *UserController) ParseJSON(json []byte) (interface{}, error)
func (*UserController) Regist ¶
func (this *UserController) Regist(ctx iris.Context)
Click to show internal directories.
Click to hide internal directories.