lms_rest

package
v0.0.0-...-3a41573 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(ctx context.Context, pkg PackageVerify) bool

func Verify

func Verify(alg encrypt.EncryptAlg, pkg PackageVerify) error

Types

type ApplyRequest

type ApplyRequest struct {
	// 组件ID
	ComponentId string `json:"component_id,omitempty" yaml:"component_id,omitempty"`

	// 组件ip
	ComponentIp string `json:"component_ip,omitempty" yaml:"component_ip,omitempty"`

	// 组件Mac地址
	ComponentMac string `json:"component_mac,omitempty" yaml:"component_mac,omitempty"`

	// 组件名称
	ComponentName string `json:"component_name,omitempty" yaml:"component_name,omitempty"`

	// 组件类型,Firewall,Waf,DBAudit,...
	ComponentType string `json:"component_type,omitempty" yaml:"component_type,omitempty"`

	// 申请的时长,以月为单位, 例如如果申请一年, duration就是12m
	Duration string `json:"duration,omitempty" yaml:"duration,omitempty"`

	// 规格
	Spec string `json:"spec,omitempty" yaml:"spec,omitempty"`
}

type ComponentLicense

type ComponentLicense struct {
	// Code corresponds to the JSON schema field "code".
	Code int `json:"code,omitempty" yaml:"code,omitempty"`

	// Data corresponds to the JSON schema field "data".
	Data ComponentLicenseData `json:"data,omitempty" yaml:"data,omitempty"`

	// Msg corresponds to the JSON schema field "msg".
	Msg string `json:"msg,omitempty" yaml:"msg,omitempty"`
}

组件授权信息

type ComponentLicenseData

type ComponentLicenseData struct {
	// LicenseInfo corresponds to the JSON schema field "license_info".
	LicenseInfo License `json:"license_info,omitempty" yaml:"license_info,omitempty"`
}

type DummyPackage

type DummyPackage struct {
	gorm.Model
	PackageID string `json:"package_id"`
}

func (DummyPackage) TableName

func (d DummyPackage) TableName() string

type ExportLicense

type ExportLicense struct {
	// ExpiredSign corresponds to the JSON schema field "expired_sign".
	ExpiredSign SignCount `json:"expired_sign,omitempty" yaml:"expired_sign,omitempty"`

	// RevertedSign corresponds to the JSON schema field "reverted_sign".
	RevertedSign SignCount `json:"reverted_sign,omitempty" yaml:"reverted_sign,omitempty"`

	// SignedChains corresponds to the JSON schema field "signed_chains".
	SignedChains []SignChainNode `json:"signed_chains,omitempty" yaml:"signed_chains,omitempty"`

	// 授权签发者
	Signer string `json:"signer,omitempty" yaml:"signer,omitempty"`

	// TotalSign corresponds to the JSON schema field "total_sign".
	TotalSign SignCount `json:"total_sign,omitempty" yaml:"total_sign,omitempty"`

	// UsingSign corresponds to the JSON schema field "using_sign".
	UsingSign SignCount `json:"using_sign,omitempty" yaml:"using_sign,omitempty"`
}

导出授权内容

type ExportLicenseResp

type ExportLicenseResp struct {
	// Code corresponds to the JSON schema field "code".
	Code int `json:"code,omitempty" yaml:"code,omitempty"`

	// Data corresponds to the JSON schema field "data".
	Data ExportLicenseRespData `json:"data,omitempty" yaml:"data,omitempty"`

	// Msg corresponds to the JSON schema field "msg".
	Msg string `json:"msg,omitempty" yaml:"msg,omitempty"`
}

导出授权信息

type ExportLicenseRespData

type ExportLicenseRespData struct {
	// ExportedLicense corresponds to the JSON schema field "exported_license".
	ExportedLicense ExportLicense `json:"exported_license,omitempty" yaml:"exported_license,omitempty"`
}

type LMSPackage

type LMSPackage struct {
	// 授权包创建的时间
	CreatedAt string `json:"created_at,omitempty" yaml:"created_at,omitempty"`

	// 此次导入的概要信息,例如描述下意图等等
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// Detail corresponds to the JSON schema field "detail".
	Detail PackageDetail `json:"detail,omitempty" yaml:"detail,omitempty"`

	// 授权包导入截止时间
	ImportDeadline string `json:"import_deadline,omitempty" yaml:"import_deadline,omitempty"`

	// 签名加密后的数据,base64码方式存储
	PackageData string `json:"package_data,omitempty" yaml:"package_data,omitempty"`

	// PackageId corresponds to the JSON schema field "package_id".
	PackageId string `json:"package_id,omitempty" yaml:"package_id,omitempty"`

	// 总包的签名
	Signature string `json:"signature,omitempty" yaml:"signature,omitempty"`

	// SubPackages corresponds to the JSON schema field "sub_packages".
	SubPackages []SubPackage `json:"sub_packages,omitempty" yaml:"sub_packages,omitempty"`

	// Append(追加), Overwrite(重置)
	WriteMode string `json:"write_mode,omitempty" yaml:"write_mode,omitempty"`
}

func (*LMSPackage) GetPackageID

func (l *LMSPackage) GetPackageID() string

func (*LMSPackage) VerifiedData

func (l *LMSPackage) VerifiedData() []byte

func (*LMSPackage) VerifiedSignature

func (l *LMSPackage) VerifiedSignature() string

type License

type License struct {
	// 授权分配时间
	AssignedAt string `json:"assigned_at,omitempty" yaml:"assigned_at,omitempty"`

	// 组件id
	ComponentId string `json:"component_id,omitempty" yaml:"component_id,omitempty"`

	// 组件ip
	ComponentIp string `json:"component_ip,omitempty" yaml:"component_ip,omitempty"`

	// 组件名称
	ComponentName string `json:"component_name,omitempty" yaml:"component_name,omitempty"`

	// 组件类型,Firewall,Waf,DBAudit,...
	ComponentType string `json:"component_type,omitempty" yaml:"component_type,omitempty"`

	// 授权到期时间
	ExpiredAt string `json:"expired_at,omitempty" yaml:"expired_at,omitempty"`

	// 授权对应的唯一uuid
	LicenseId string `json:"license_id,omitempty" yaml:"license_id,omitempty"`

	// MonthSigns corresponds to the JSON schema field "month_signs".
	MonthSigns []MonthSign `json:"month_signs,omitempty" yaml:"month_signs,omitempty"`

	// 授权分配者
	Signer string `json:"signer,omitempty" yaml:"signer,omitempty"`

	// 规格
	Spec string `json:"spec,omitempty" yaml:"spec,omitempty"`
}

type LicenseCount

type LicenseCount struct {
	// Assigned corresponds to the JSON schema field "assigned".
	Assigned int `json:"assigned,omitempty" yaml:"assigned,omitempty"`

	// Available corresponds to the JSON schema field "available".
	Available int `json:"available,omitempty" yaml:"available,omitempty"`

	// Expired corresponds to the JSON schema field "expired".
	Expired int `json:"expired,omitempty" yaml:"expired,omitempty"`

	// ExpiredIn2Month corresponds to the JSON schema field "expired_in_2_month".
	ExpiredIn2Month int `json:"expired_in_2_month,omitempty" yaml:"expired_in_2_month,omitempty"`

	// Failed corresponds to the JSON schema field "failed".
	Failed int `json:"failed,omitempty" yaml:"failed,omitempty"`

	// Reverted corresponds to the JSON schema field "reverted".
	Reverted int    `json:"reverted,omitempty" yaml:"reverted,omitempty"` // Signer corresponds to the JSON schema field "signer".
	Signer   string `json:"signer,omitempty" yaml:"signer,omitempty"`

	// Total corresponds to the JSON schema field "total".
	Total int `json:"total,omitempty" yaml:"total,omitempty"`
}

type LicenseHeart

type LicenseHeart struct {
	// Code corresponds to the JSON schema field "code".
	Code int `json:"code,omitempty" yaml:"code,omitempty"`

	// Data corresponds to the JSON schema field "data".
	Data LicenseHeartData `json:"data,omitempty" yaml:"data,omitempty"`

	// Msg corresponds to the JSON schema field "msg".
	Msg string `json:"msg,omitempty" yaml:"msg,omitempty"`
}

授权心跳同步信息

type LicenseHeartData

type LicenseHeartData struct {
	// ExportedLicense corresponds to the JSON schema field "exported_license".
	ExportedLicense LicenseHeartResp `json:"exported_license,omitempty" yaml:"exported_license,omitempty"`
}

type LicenseHeartReq

type LicenseHeartReq struct {
	// 设备管理网IP
	DeviceIp string `json:"device_ip,omitempty" yaml:"device_ip,omitempty"`

	// 授权到期时间
	ExpiredAt string `json:"expired_at,omitempty" yaml:"expired_at,omitempty"`

	// 一些网元特定的内容, 在进行序列化后存在这个字段
	Extra string `json:"extra,omitempty" yaml:"extra,omitempty"`

	// 心跳时间
	HeartbeatAt string `json:"heartbeat_at,omitempty" yaml:"heartbeat_at,omitempty"`

	// 授权ID
	LicenseId string `json:"license_id,omitempty" yaml:"license_id,omitempty"`

	// 设备的序列号
	SerialNum string `json:"serial_num,omitempty" yaml:"serial_num,omitempty"`

	// Signature corresponds to the JSON schema field "signature".
	Signature string `json:"signature,omitempty" yaml:"signature,omitempty"`

	// 规格
	Spec string `json:"spec,omitempty" yaml:"spec,omitempty"`
}

授权心跳同步信息

type LicenseHeartResp

type LicenseHeartResp struct {
	// 对device的请求的响应,valid代表接受,invalid代表失效
	Action string `json:"action,omitempty" yaml:"action,omitempty"`

	// 设备管理网IP
	DeviceIp string `json:"device_ip,omitempty" yaml:"device_ip,omitempty"`

	// HeartbeatAt corresponds to the JSON schema field "heartbeat_at".
	HeartbeatAt string `json:"heartbeat_at,omitempty" yaml:"heartbeat_at,omitempty"`

	// 授权ID
	LicenseId string `json:"license_id,omitempty" yaml:"license_id,omitempty"`

	// 设备的序列号
	SerialNum string `json:"serial_num,omitempty" yaml:"serial_num,omitempty"`

	// Signature corresponds to the JSON schema field "signature".
	Signature string `json:"signature,omitempty" yaml:"signature,omitempty"`

	// Signer corresponds to the JSON schema field "signer".
	Signer string `json:"signer,omitempty" yaml:"signer,omitempty"`
}

授权服务器的响应

type LicenseRange

type LicenseRange struct {
	// ExpiredAt corresponds to the JSON schema field "expired_at".
	ExpiredAt string `json:"expired_at,omitempty" yaml:"expired_at,omitempty"`

	// ImportedAt corresponds to the JSON schema field "imported_at".
	ImportedAt string `json:"imported_at,omitempty" yaml:"imported_at,omitempty"`
}

type LicenseSummary

type LicenseSummary struct {
	// CountsBySigner corresponds to the JSON schema field "counts_by_signer".
	CountsBySigner []LicenseCount `json:"counts_by_signer,omitempty" yaml:"counts_by_signer,omitempty"`

	// CountsTotal corresponds to the JSON schema field "counts_total".
	CountsTotal LicenseCount `json:"counts_total,omitempty" yaml:"counts_total,omitempty"`

	// UpdatedAt corresponds to the JSON schema field "updated_at".
	UpdatedAt string `json:"updated_at,omitempty" yaml:"updated_at,omitempty"`
}

type LmsPackageJson

type LmsPackageJson map[string]interface{}

LMS的授权总包

type MonthSign

type MonthSign struct {
	// 签名内容
	Sign string `json:"sign,omitempty" yaml:"sign,omitempty"`

	// 签名时间
	SignedAt string `json:"signed_at,omitempty" yaml:"signed_at,omitempty"`
}

每月签名一次

type PackageDetail

type PackageDetail struct {
	// 增加可用组件数, 暂时不考虑将这部分的权限收归LMS
	AddCountLimit int `json:"add_count_limit,omitempty" yaml:"add_count_limit,omitempty"`

	// 一个授权代表一个月的使用期,最小单位是月
	AddLicense int `json:"add_license,omitempty" yaml:"add_license,omitempty"`

	// 授权最大申请时长,如果为空就代表不改变,示例如12m,36m等等
	MaxDuration string `json:"max_duration,omitempty" yaml:"max_duration,omitempty"`
}

记录这次主要操作的信息

type PackageVerify

type PackageVerify interface {
	VerifiedData() []byte
	VerifiedSignature() string
	GetPackageID() string
}

type SignChainNode

type SignChainNode struct {
	// 在链中的ID,连续递增的
	NodeId int `json:"node_id,omitempty" yaml:"node_id,omitempty"`

	// Operation corresponds to the JSON schema field "operation".
	Operation SignOperation `json:"operation,omitempty" yaml:"operation,omitempty"`

	// 每个月要签发一次
	SignedAt string `json:"signed_at,omitempty" yaml:"signed_at,omitempty"`

	// 签名内容
	SignedDigest string `json:"signed_digest,omitempty" yaml:"signed_digest,omitempty"`
}

type SignCount

type SignCount struct {
	// 授权数
	Count int `json:"count,omitempty" yaml:"count,omitempty"`

	// 授权月数
	MountCount int `json:"mount_count,omitempty" yaml:"mount_count,omitempty"`
}

type SignOperation

type SignOperation struct {
	// 操作发生时间
	ActionAt string `json:"action_at,omitempty" yaml:"action_at,omitempty"`

	// 授权应该到期时间
	ExpiredAt string `json:"expired_at,omitempty" yaml:"expired_at,omitempty"`

	// license uuid
	LicenseId string `json:"license_id,omitempty" yaml:"license_id,omitempty"`

	// assign,revert,expire
	Optype string `json:"optype,omitempty" yaml:"optype,omitempty"`

	// 规格
	Spec string `json:"spec,omitempty" yaml:"spec,omitempty"`
}

type SubPackage

type SubPackage struct {
	// 授权包创建的时间
	CreatedAt string `json:"created_at,omitempty" yaml:"created_at,omitempty"`

	// Description corresponds to the JSON schema field "description".
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// Detail corresponds to the JSON schema field "detail".
	Detail PackageDetail `json:"detail,omitempty" yaml:"detail,omitempty"`

	// 授权包导入截止时间
	ImportDeadline string `json:"import_deadline,omitempty" yaml:"import_deadline,omitempty"`

	// 签名加密后的数据,base64码方式存储
	PackageData string `json:"package_data,omitempty" yaml:"package_data,omitempty"`

	// 子包的UUID
	PackageId string `json:"package_id,omitempty" yaml:"package_id,omitempty"`

	// 包提供者的UUID
	PackageVendorId string `json:"package_vendor_id,omitempty" yaml:"package_vendor_id,omitempty"`

	// 防护类型, 例如firewall,waf,ips等等
	ProtectType string `json:"protect_type,omitempty" yaml:"protect_type,omitempty"`

	// 子包的签名
	Signature string `json:"signature,omitempty" yaml:"signature,omitempty"`
}

子包信息

func (*SubPackage) GetPackageID

func (l *SubPackage) GetPackageID() string

func (*SubPackage) VerifiedData

func (l *SubPackage) VerifiedData() []byte

func (*SubPackage) VerifiedSignature

func (l *SubPackage) VerifiedSignature() string

type SummaryResp

type SummaryResp struct {
	// Code corresponds to the JSON schema field "code".
	Code int `json:"code,omitempty" yaml:"code,omitempty"`

	// Data corresponds to the JSON schema field "data".
	Data SummaryRespData `json:"data,omitempty" yaml:"data,omitempty"`

	// Msg corresponds to the JSON schema field "msg".
	Msg string `json:"msg,omitempty" yaml:"msg,omitempty"`
}

授权汇总信息

type SummaryRespData

type SummaryRespData struct {
	// Summary corresponds to the JSON schema field "summary".
	Summary LicenseSummary `json:"summary,omitempty" yaml:"summary,omitempty"`
}

Jump to

Keyboard shortcuts

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