recommender/pkg/consts/auth.go

37 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-11-06 10:47:56 +00:00
package consts
import (
"errors"
2024-11-06 12:35:16 +00:00
"leafdev.top/Ecosystem/recommender/internal/schema"
2024-11-06 10:47:56 +00:00
)
2024-11-07 12:00:06 +00:00
type AuthMiddlewareKey string
2024-11-06 10:47:56 +00:00
const (
AuthHeader = "Authorization"
AuthPrefix = "Bearer"
//AnonymousUser schema.UserId = 1
AnonymousUser schema.UserId = "anonymous"
2024-11-07 12:00:06 +00:00
AuthMiddlewareKeyUser AuthMiddlewareKey = "auth.user"
AuthMiddlewareKeyApplication AuthMiddlewareKey = "auth.application"
2024-11-06 10:47:56 +00:00
)
2024-11-07 12:00:06 +00:00
func (a AuthMiddlewareKey) String() string {
return string(a)
}
2024-11-06 10:47:56 +00:00
var (
2024-11-07 12:00:06 +00:00
ErrBearerTokenNotFound = errors.New("bearer 令牌未找到")
ErrNotValidToken = errors.New("无效的 JWT 令牌")
ErrJWTFormatError = errors.New("JWT 格式错误")
ErrNotBearerType = errors.New("不是 Bearer 类型")
ErrEmptyResponse = errors.New("我们的服务器返回了空请求,可能某些环节出了问题")
ErrTokenError = errors.New("token 类型错误")
ErrBearerToken = errors.New("无效的 Bearer 令牌")
2024-11-06 10:47:56 +00:00
ErrNotYourResource = errors.New("你不能修改这个资源,因为它不是你创建的。")
ErrPermissionDenied = errors.New("没有权限访问此资源")
)