auth

package
v7.25.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 13 Imported by: 94

Documentation

Index

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

func WithCredentialsType(ctx context.Context, cred *Credentials, t TokenType) context.Context

WithCredentialsType 返回一个context, 保存了密钥信息和token类型

Types

type Credentials

type Credentials struct {
	AccessKey string
	SecretKey []byte
}
七牛鉴权类,用于生成Qbox, Qiniu, Upload签名

AK/SK可以从 https://portal.qiniu.com/user/key 获取

func Default added in v7.21.0

func Default() *Credentials

Default 构建默认的 Credentials 对象

func New

func New(accessKey, secretKey string) *Credentials

New 构建一个Credentials对象

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 验证上传回调请求是否来自七牛

type TokenType

type TokenType int

七牛签名算法的类型: QBoxToken, QiniuToken, BearToken, QiniuMacToken

const (
	TokenQiniu TokenType = iota
	TokenQBox
)

Directories

Path Synopsis
qbox 包提供了该SDK需要的相关鉴权方法
qbox 包提供了该SDK需要的相关鉴权方法

Jump to

Keyboard shortcuts

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