auth

package
v0.0.0-...-654a53c Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

用户认证相关服务

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckUserAccount

func CheckUserAccount(context context.Context, username, password string) (*domain.Account, error)

判断用户名、密码是否对应一个有效的用户

func PasswordEncoding

func PasswordEncoding(rawPassword string) string

将明文密码用Bcrypt加密为密文

func ValidatingJWTAccessToken

func ValidatingJWTAccessToken(tokenString string) (jwt.MapClaims, error)

解析JWT令牌字符串,验证有效性,如令牌有效,提取其中存放的信息以jwt.MapClaims的形式返回

Types

type JWT

type JWT struct {
	AccessToken  string   `json:"access_token"`
	RefreshToken string   `json:"refresh_token"`
	Authorities  []string `json:"authorities"`
	Expires      int64    `json:"expires_in"`
	Scope        string   `json:"scope"`
	TokenType    string   `json:"token_type"`
	Username     string   `json:"username"`
}

func BuildJWTAccessToken

func BuildJWTAccessToken(account *domain.Account) *JWT

根据指定用户信息输出JWT令牌

Jump to

Keyboard shortcuts

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