Documentation ¶
Index ¶
- Constants
- Variables
- func CheckRequest(instance Auth, r *http.Request) error
- func CheckURI(instance Auth, url *url.URL) error
- func Init()
- func SignRequest(instance Auth, r *http.Request, expires int64) *http.Request
- func SignURI(instance Auth, uri string, expires int64) (*url.URL, error)
- type Auth
- type HMACAuth
Constants ¶
View Source
const CrHeaderPrefix = "X-Cr-"
Variables ¶
View Source
var ( ErrAuthFailed = serializer.NewError(serializer.CodeNoPermissionErr, "鉴权失败", nil) ErrAuthHeaderMissing = serializer.NewError(serializer.CodeNoPermissionErr, "authorization header is missing", nil) ErrExpiresMissing = serializer.NewError(serializer.CodeNoPermissionErr, "expire timestamp is missing", nil) ErrExpired = serializer.NewError(serializer.CodeSignExpired, "签名已过期", nil) )
Functions ¶
func CheckRequest ¶
CheckRequest 对复杂请求进行签名验证
func SignRequest ¶
SignRequest 对PUT\POST等复杂HTTP请求签名,只会对URI部分、 请求正文、`X-Cr-`开头的header进行签名
Types ¶
type Auth ¶
type Auth interface { // 对给定Body进行签名,expires为0表示永不过期 Sign(body string, expires int64) string // 对给定Body和Sign进行检查 Check(body string, sign string) error }
Auth 鉴权认证
var General Auth
General 通用的认证接口
Click to show internal directories.
Click to hide internal directories.