Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveMasterKey ¶
func ResolveMasterKey(opts MasterKeyOptions) (string, error)
ResolveMasterKey 按优先级获取 master key:
- opts.Explicit(CLI --master-key / 环境变量)
- OS Keychain(opts.NoKeychain 为 true 时跳过)
- 文件回退 (<DataDir>/master.key)
如果所有来源都没有,自动生成并存储。
Types ¶
type CredentialSvc ¶
type CredentialSvc struct {
// contains filtered or unexported fields
}
CredentialSvc 凭证加解密服务(Argon2id + AES-256-GCM)
func New ¶
func New(masterKey string, salt []byte) *CredentialSvc
New 创建凭证服务,使用 Argon2id(masterKey, salt) 派生 AES-256 密钥
type MasterKeyOptions ¶ added in v1.11.0
type MasterKeyOptions struct {
// Explicit 来自 CLI --master-key 或 OPSKAT_MASTER_KEY,非空则直接采用。
Explicit string
// DataDir master key 文件所在目录。
DataDir string
// NoKeychain 便携模式下为 true:master key 只落 <DataDir>/master.key,
// 不读也不写 OS 凭据管理器。凭据管理器是机器本地的,便携目录换到另一台
// 机器后会读不到 key 而重新生成,导致库内已加密凭据永久解不开。
NoKeychain bool
}
MasterKeyOptions 是 ResolveMasterKey 的入参。
Click to show internal directories.
Click to hide internal directories.