auth

package
v1.16.5 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package auth 鉴权管理接口

Index

Constants

View Source
const (
	// RSA_BITS  1024 bits
	RSA_BITS = 1024
	// RSA_SIGN_SRC RSA 签名数据
	RSA_SIGN_SRC = "BYTEDANCE"
)

Variables

This section is empty.

Functions

func NewPrivateKey added in v1.16.2

func NewPrivateKey(privateKey *rsa.PrivateKey) (string, error)

NewPrivateKey 生成新私钥,返回pem file

Types

type AddPublicKeyRequest

type AddPublicKeyRequest struct {
	// AdvertiserID 广告主ID
	AdvertiserID uint64 `json:"advertiser_id,omitempty"`
	// Credential 密钥对label,枚举值:“primary”或“backup”
	Credential enum.Credential `json:"credential,omitempty"`
	// PubKey RSA公钥(1024位)文本内容,格式为X.509 Certificate Subject Public Key Info,可使用openssl生成,详见附录。注意:使用openssl生成的公钥是多行文本,需要使用换行符“\n”将多行文本转为单行。
	PubKey string `json:"pubkey,omitempty"`
	// Signature 使用RS256签名算法和私钥对字符串“BYTEDANCE”签名后的结果,可使用openssl计算,详见附录
	Signature string `json:"signature,omitepty"`
}

AddPublicKeyRequest 新增公钥 API Request

func NewAddPublicKeyRequest

func NewAddPublicKeyRequest(advertiserID uint64, credential enum.Credential) (*AddPublicKeyRequest, error)

NewAddPublicKeyRequest 生成新增公钥请求

func NewAddPublicKeyRequestWithPrivateKey added in v1.16.2

func NewAddPublicKeyRequestWithPrivateKey(advertiserID uint64, credential enum.Credential, privateKey *rsa.PrivateKey) (*AddPublicKeyRequest, error)

NewAddPublicKeyRequestWithPrivateKey 根据私钥生成新增公钥请求

func (AddPublicKeyRequest) Encode

func (r AddPublicKeyRequest) Encode() []byte

Encode implement PostRequest interface

type AddPublicKeyResponse

type AddPublicKeyResponse struct {
	model.BaseResponse
	// Data json返回值
	Data struct {
		// PubKey 公钥
		PubKey *PublicKey `json:"pubkey,omitempty"`
	} `json:"data,omitempty"`
}

AddPublicKeyResponse 新增公钥 API Response

type DelPublicKeyRequest

type DelPublicKeyRequest struct {
	// AdvertiserID 广告主ID
	AdvertiserID uint64 `json:"advertiser_id,omitempty"`
	// Credential 密钥对label,枚举值:“primary”或“backup”
	Credential enum.Credential `json:"credential,omitempty"`
}

DelPublicKeyRequest 删除公钥 API Request

func (DelPublicKeyRequest) Encode

func (r DelPublicKeyRequest) Encode() []byte

Encode implement PostRequest interface

type DisableRequest

type DisableRequest struct {
	// AdvertiserID 广告主ID
	AdvertiserID uint64 `json:"advertiser_id,omitempty"`
}

DisableRequest 关闭鉴权 API Request

func (DisableRequest) Encode

func (r DisableRequest) Encode() []byte

Encode implement PostRequest interface

type EnableRequest

type EnableRequest struct {
	// AdvertiserID 广告主ID
	AdvertiserID uint64 `json:"advertiser_id,omitempty"`
}

EnableRequest 开启鉴权 API Request

func (EnableRequest) Encode

func (r EnableRequest) Encode() []byte

Encode implement PostRequest interface

type GetAllPublicKeyRequest

type GetAllPublicKeyRequest struct {
	// AdvertiserID 广告主ID
	AdvertiserID uint64 `json:"advertiser_id,omitempty"`
}

GetAllPublicKeyRequest 获取全部公钥 API Request

func (GetAllPublicKeyRequest) Encode

func (r GetAllPublicKeyRequest) Encode() string

Encode implement GetRequest interface

type GetAllPublicKeyResponse

type GetAllPublicKeyResponse struct {
	model.BaseResponse
	// Data json返回值
	Data struct {
		// PubKey 公钥
		PubKeys []PublicKey `json:"pubkeys,omitempty"`
	} `json:"data,omitempty"`
}

GetAllPublicKeyResponse 获取全部公钥 API Response

type GetAuthStatusRequest

type GetAuthStatusRequest struct {
	// AdvertiserID 广告主ID
	AdvertiserID uint64 `json:"advertiser_id,omitempty"`
}

GetAuthStatusRequest 查询鉴权开启状态 API Request

func (GetAuthStatusRequest) Encode

func (r GetAuthStatusRequest) Encode() string

Encode implement GetRequest interface

type GetAuthStatusResponse

type GetAuthStatusResponse struct {
	model.BaseResponse
	Data struct {
		// Enabled 鉴权是否开启
		Enabled bool `json:"enabled,omitempty"`
	} `json:"data,omitempty"`
}

GetAuthStatusResponse 查询鉴权开启状态

type GetPublicKeyRequest

type GetPublicKeyRequest struct {
	// AdvertiserID 广告主ID
	AdvertiserID uint64 `json:"advertiser_id,omitempty"`
	// Credential 密钥对label,枚举值:“primary”或“backup”
	Credential enum.Credential `json:"credential,omitempty"`
}

GetPublicKeyRequest 获取公钥 API Request

func (GetPublicKeyRequest) Encode

func (r GetPublicKeyRequest) Encode() string

Encode implement GetRequest interface

type GetPublicKeyResponse

type GetPublicKeyResponse struct {
	model.BaseResponse
	// Data json返回值
	Data struct {
		// PubKey 公钥
		PubKey *PublicKey `json:"pubkey,omitempty"`
	} `json:"data,omitempty"`
}

GetPublicKeyResponse 获取公钥 API Response

type PublicKey

type PublicKey struct {
	// AdvertiserID 广告主ID
	AdvertiserID uint64 `json:"advertiser_id,omitempty"`
	// Credential 密钥对label,枚举值:“primary”或“backup”
	Credential enum.Credential `json:"credential,omitempty"`
	// KeyID
	KeyID uint64 `json:"key_id,omitempty"`
	// PubKey RSA公钥(1024位)文本内容,格式为X.509 Certificate Subject Public Key Info,可使用openssl生成,详见附录。注意:使用openssl生成的公钥是多行文本,需要使用换行符“\n”将多行文本转为单行。
	PubKey string `json:"pubkey,omitempty"`
}

PublicKey 公钥

Jump to

Keyboard shortcuts

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