auth

package
v7.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

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

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 New

func New(accessKey, secretKey string) *Credentials

构建一个Credentials对象

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

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