Documentation ¶
Index ¶
- Constants
- 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 (c *Credentials) Get(ctx context.Context) (*Credentials, error)
- func (ath *Credentials) IsIAMKey() bool
- 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 ¶
View Source
const ( IAMKeyLen = 33 IAMKeyPrefix = "IAM-" AuthorizationPrefixQiniu = "Qiniu " AuthorizationPrefixQBox = "QBox " )
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) Get ¶ added in v7.20.0
func (c *Credentials) Get(ctx context.Context) (*Credentials, error)
Get 实现 CredentialsProvider 接口
func (*Credentials) IsIAMKey ¶ added in v7.11.0
func (ath *Credentials) IsIAMKey() bool
IsIAMKey 判断AccessKey是否为IAM的Key
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.