Documentation
¶
Index ¶
Constants ¶
const ( GatewayKeyringType = "gateway_keyring" GatewayKeyringIDPrefix = "moox:gateway-keyring:" )
Gateway keyrings belong to the control plane, not the generic SecretMgr API.
const ( SSHHostIDPrefix = "moox:ssh-host:" SSHCategory = "ssh" )
主机的 SSH 登录凭据(密码或私钥)由 SSH 服务按主机维护,同样不经过通用的 SecretMgr API。 秘钥 ID 为 SSHHostIDPrefix + 主机 ID,c_key_id 存登录用户名。
const ( EventBusCategory = "eventbus" EventBusProvider = "moox_eventbus" )
EventBus 内部凭据(TLS 证书与各角色令牌)的分类与提供方,由 eventbus-credentials ensure 生成,按 key_id 读取。
const ( SSHSecretTypePassword = "password" SSHSecretTypeKey = "ssh_key" )
主机 SSH 凭据的秘钥类型:password 存密码,ssh_key 存私钥(可带口令)。
const ConfigBackupID = "moox-config-backup"
ConfigBackupID 是配置备份(moox-cli 用管理员密码加密的 moox.toml)在 t_secrets 里的固定标识;整个系统只有一份, 属于本环境,秘钥迁移不导出也不导入它。
const SystemSpacePrefix = systemspace.ID
SystemSpacePrefix 是系统内部空间的前缀:网关密钥环、EventBus 内部凭据等由部署工具在系统空间(systemspace.ID)下生成,属于本环境。
Variables ¶
This section is empty.
Functions ¶
func ExchangeSecretID ¶
ExchangeSecretID 返回交易所密钥的固定秘钥 ID:exchange-<交易所>-<环境>-<名称>,三段一律小写。 setup apply 按 moox.toml 的 [[exchange_keys]] 写入时用它;Collector 读只读 Key 用的 exchange-binance-production-readonly 也是它。
func SSHHostSecretID ¶
SSHHostSecretID 返回主机 SSH 凭据的秘钥 ID。
Types ¶
type SSHCredential ¶
type SSHCredential struct {
Password string `json:"password,omitempty"`
PrivateKey string `json:"private_key,omitempty"`
Passphrase string `json:"passphrase,omitempty"`
}
SSHCredential 是主机 SSH 凭据的明文内容,整体序列化成 JSON 后加密存入 Secret.SecretValue。
func DecodeSSHCredential ¶
func DecodeSSHCredential(plain string) (SSHCredential, error)
DecodeSSHCredential 解析 Encode 产生的 JSON 文本。
func (SSHCredential) Encode ¶
func (c SSHCredential) Encode() (string, error)
Encode 序列化为待加密的 JSON 文本。
func (SSHCredential) Validate ¶
func (c SSHCredential) Validate() error
Validate 要求密码与私钥恰好给一个,口令只能配合私钥。
type Secret ¶
type Secret struct {
ID int `gorm:"primaryKey;column:c_id;autoIncrement" json:"id"`
// SpaceID 预留多租户隔离字段,当前为全局共享模式,默认空字符串。
// 未来如需空间隔离,在 DAO 层的 Create/List/Get/Update/Delete 中读写并过滤此字段。
SpaceID string `gorm:"column:c_space_id;not null;default:''" json:"space_id"`
SecretID string `gorm:"column:c_secret_id;not null" json:"secret_id"`
Name string `gorm:"column:c_name;not null" json:"name"`
Description string `gorm:"column:c_description;not null;default:''" json:"description"`
Category string `gorm:"column:c_category;not null" json:"category"`
Provider string `gorm:"column:c_provider;not null;default:''" json:"provider"`
SecretType string `gorm:"column:c_secret_type;not null;default:'api_key'" json:"secret_type"`
KeyID string `gorm:"column:c_key_id;not null;default:''" json:"key_id"`
SecretValue string `gorm:"column:c_secret_value;not null" json:"secret_value"`
ExtraConfig string `gorm:"column:c_extra_config;not null;default:'{}'" json:"extra_config"`
Status string `gorm:"column:c_status;not null;default:'active'" json:"status"`
Creator string `gorm:"column:c_creator;not null;default:''" json:"creator"`
IsDeleted bool `gorm:"column:c_is_deleted;not null;default:false" json:"is_deleted"`
CreateTime time.Time `gorm:"column:c_ctime;type:datetime;default:CURRENT_TIMESTAMP" json:"create_time"`
ModifyTime time.Time `gorm:"column:c_mtime;type:datetime;default:CURRENT_TIMESTAMP" json:"modify_time"`
}
Secret 秘钥管理表
func (*Secret) EnvironmentBound ¶
EnvironmentBound 判断秘钥是否属于本环境(系统空间里的、网关密钥环、主机 SSH 凭据、EventBus 内部凭据、配置备份): 这些秘钥由部署工具生成并按固定标识读取,迁移到另一套环境会和那里自己的同名凭据冲突,所以不导出也不导入。