Documentation ¶
Index ¶
- func CredentialsFromContext(ctx context.Context) (cred *Credentials, t TokenType, ok bool)
- func WithCredentials(ctx context.Context, cred *Credentials) context.Context
- func WithCredentialsType(ctx context.Context, cred *Credentials, t TokenType) context.Context
- type Credentials
- func (ath *Credentials) AddToken(t TokenType, req *http.Request) error
- func (ath *Credentials) Sign(data []byte) (token string)
- func (ath *Credentials) SignRequest(req *http.Request) (token string, err error)
- func (ath *Credentials) SignRequestV2(req *http.Request) (token string, err error)
- func (ath *Credentials) SignWithData(b []byte) (token string)
- func (ath *Credentials) VerifyCallback(req *http.Request) (bool, error)
- type TokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CredentialsFromContext ¶
func CredentialsFromContext(ctx context.Context) (cred *Credentials, t TokenType, ok bool)
CredentialsFromContext 从context获取密钥信息
func WithCredentials ¶
func WithCredentials(ctx context.Context, cred *Credentials) context.Context
WithCredentials 返回一个包含密钥信息的context
func WithCredentialsType ¶
WithCredentialsType 返回一个context, 保存了密钥信息和token类型
Types ¶
type Credentials ¶
七牛鉴权类,用于生成Qbox, Qiniu, Upload签名
AK/SK可以从 https://portal.qiniu.com/user/key 获取。
func (*Credentials) AddToken ¶
func (ath *Credentials) AddToken(t TokenType, req *http.Request) error
SignToken 根据t的类型对请求进行签名,并把token加入req中
func (*Credentials) Sign ¶
func (ath *Credentials) Sign(data []byte) (token string)
Sign 对数据进行签名,一般用于私有空间下载用途
func (*Credentials) SignRequest ¶
func (ath *Credentials) SignRequest(req *http.Request) (token string, err error)
SignRequest 对数据进行签名,一般用于管理凭证的生成
func (*Credentials) SignRequestV2 ¶
func (ath *Credentials) SignRequestV2(req *http.Request) (token string, err error)
SignRequestV2 对数据进行签名,一般用于高级管理凭证的生成
func (*Credentials) SignWithData ¶
func (ath *Credentials) SignWithData(b []byte) (token string)
SignWithData 对数据进行签名,一般用于上传凭证的生成用途
func (*Credentials) VerifyCallback ¶
func (ath *Credentials) VerifyCallback(req *http.Request) (bool, error)
VerifyCallback 验证上传回调请求是否来自七牛
Click to show internal directories.
Click to hide internal directories.