authentication

package
v0.0.0-...-150877d Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const UploadFileURL = "/web/v1/file/%s/%s?uuid=%s&exp=%d&hash=%s&crc=%s&sha1=%s"
View Source
const UploadSliceFileURL = "/web/v1/files/%s/%s/%d?sum=%d&uuid=%s&exp=%d&hash=%s&crc=%s&sha1=%s"

Variables

This section is empty.

Functions

func CreateLoginToken

func CreateLoginToken(claims LoginToken, secret []byte, expirationTime *duration.Duration) (signedToken string, err error)

CreateLoginToken 创建登录token

func CreateSliceUploadURL

func CreateSliceUploadURL(claims *UploadSliceFileClaims, secretKey *string) (string, error)

CreateSliceUploadURL 创建大文件分片文件上传使用的URL

func CreateUploadURL

func CreateUploadURL(claims *UploadFileClaims, secretKey *string) (string, error)

CreateUploadURL 创建单个文件上传使用的URL

func LoginAuthMiddleware

func LoginAuthMiddleware(secret []byte) middleware.Middleware

LoginAuthMiddleware 登录鉴权中间件

func ValidateLoginListMatcher

func ValidateLoginListMatcher(routers []string) selector.MatchFunc

ValidateLoginListMatcher 登录鉴权路由匹配器

func ValidateSliceUploadInfo

func ValidateSliceUploadInfo(claims *UploadSliceFileClaims, secretKey *string, hash *string) (bool, error)

ValidateSliceUploadInfo 验证分片文件上传信息

func ValidateUploadInfo

func ValidateUploadInfo(claims *UploadFileClaims, secretKey *string, hash *string) (bool, error)

ValidateUploadInfo 验证单个文件上传信息

Types

type LoginToken

type LoginToken struct {
	UserID    uint32 `json:"user_id"`    // 用户id
	UUID      string `json:"uuid"`       // 会话号
	CreateAt  int64  `json:"create_At"`  // 创建时间
	RenewalAt int64  `json:"renewal_At"` // 续签到期时间, 保活时间
	jwt.RegisteredClaims
}

LoginToken 登录token

func FromLoginTokenContext

func FromLoginTokenContext(ctx context.Context) (loginToken *LoginToken, ok bool)

FromLoginTokenContext 返回存储在context中的登录token,如果有

func ValidateLoginToken

func ValidateLoginToken(signedToken string, secret []byte) (claims *LoginToken, success bool)

ValidateLoginToken 验证登录token

type UploadFileClaims

type UploadFileClaims struct {
	Bucket    string    `json:"bucket"` // 需要上传文件所在的oss桶
	Name      string    `json:"name"`   // oss中设置的文件名
	UUID      uuid.UUID `json:"uuid"`   // 链接的唯一id 实现幂等性
	ExpiresAt uint32    `json:"exp"`    // 链接到期时间的时间戳
	CRC       string    `json:"crc"`    // 上传文件的crc-32-hash值
	SHA1      string    `json:"sha1"`   // 上传文件的sha1-hash值
}

UploadFileClaims 单个上传文件的token

type UploadSliceFileClaims

type UploadSliceFileClaims struct {
	UploadFileClaims
	SliceID uint32 `json:"slice_id"` // 文件分配的id
	Sum     uint32 `json:"sum"`      // 分片的数量总和
}

UploadSliceFileClaims 多文件分片上传文件的token

Jump to

Keyboard shortcuts

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