feat: let administrators view and copy encrypted integration credentials
This commit is contained in:
@@ -32,6 +32,7 @@ type AccessQueue struct {
|
||||
|
||||
// AccessCredential 是脱敏的凭据元数据,绝不返回秘密或秘密摘要。
|
||||
type AccessCredential struct {
|
||||
TokenStored bool `json:"token_stored"` // TokenStored 当前 Token 是否已加密保存;列表不会返回秘密。
|
||||
PreviousValidUntil *time.Time `json:"previous_valid_until,omitempty"` // PreviousValidUntil 上一代令牌实际截止,空表示无旧令牌。
|
||||
ID core.ID `json:"id"` // ID 凭据标识,重新生成 Token 时不改变。
|
||||
Name string `json:"name"` // Name 凭据名称。
|
||||
@@ -43,10 +44,11 @@ type AccessCredential struct {
|
||||
|
||||
// ApplicationDetail 展示一个命名空间的队列和凭据,读取量有界。
|
||||
type ApplicationDetail struct {
|
||||
Entry ApplicationEntry `json:"entry"` // Entry 当前应用与环境。
|
||||
Queues []AccessQueue `json:"queues"` // Queues 最多 100 个队列。
|
||||
Credentials []AccessCredential `json:"credentials"` // Credentials 最多 100 张凭据。
|
||||
Truncated bool `json:"truncated"` // Truncated 为真时不得把当前结果解释为完整清单。
|
||||
TokenVaultEnabled bool `json:"token_vault_enabled"` // TokenVaultEnabled 当前节点是否配置了凭据保管密钥。
|
||||
Entry ApplicationEntry `json:"entry"` // Entry 当前应用与环境。
|
||||
Queues []AccessQueue `json:"queues"` // Queues 最多 100 个队列。
|
||||
Credentials []AccessCredential `json:"credentials"` // Credentials 最多 100 张凭据。
|
||||
Truncated bool `json:"truncated"` // Truncated 为真时不得把当前结果解释为完整清单。
|
||||
}
|
||||
|
||||
// ApplicationInput 描述创建应用或变更凭据的管理员意图。
|
||||
@@ -65,7 +67,7 @@ type ApplicationInput struct {
|
||||
Reason string `json:"reason"` // Reason 写入审计的变更原因。
|
||||
}
|
||||
|
||||
// ApplicationOperation 是浏览器在提交前保存的固定操作;Token 不写入数据库。
|
||||
// ApplicationOperation 是浏览器在提交前保存的固定操作;启用保管时仅保存 Token 密文。
|
||||
// 网络结果未知时重放同一份内容,禁止重新生成操作身份或秘密。
|
||||
type ApplicationOperation struct {
|
||||
Version int `json:"version,omitempty"` // Version v2 支持长期令牌与过渡;旧固定操作未设置时沿用 v1。
|
||||
@@ -75,7 +77,7 @@ type ApplicationOperation struct {
|
||||
NamespaceID core.ID `json:"namespace_id"` // NamespaceID 固定命名空间标识。
|
||||
QueueID core.ID `json:"queue_id,omitempty"` // QueueID 新建应用的初始队列。
|
||||
CredentialID core.ID `json:"credential_id"` // CredentialID 固定凭据身份。
|
||||
Token string `json:"token,omitempty"` // Token 一次性交付的秘密,只留在调用方内存或私密下载文件。
|
||||
Token string `json:"token,omitempty"` // Token 当前秘密;服务端启用保管后加密保存,不能进入日志。
|
||||
ExpiresAt *time.Time `json:"expires_at,omitempty"` // ExpiresAt 固定到期时间,空表示长期或不适用。
|
||||
PreviousValidUntil *time.Time `json:"previous_valid_until,omitempty"` // PreviousValidUntil ROTATE 固定过渡截止。
|
||||
}
|
||||
|
||||
33
internal/consoleauth/credential_tokens.go
Normal file
33
internal/consoleauth/credential_tokens.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package consoleauth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
core "git.yuntuo.hk/k2safe/orbit/model"
|
||||
"git.yuntuo.hk/k2safe/orbit/platform/auth"
|
||||
)
|
||||
|
||||
// CredentialTokenInput 用于管理员查看或补存已有 Token,不改变业务认证身份。
|
||||
type CredentialTokenInput struct {
|
||||
ExpectedRevision uint64 `json:"expected_revision,string"` // ExpectedRevision 页面读取到的凭据版本;并发换证时拒绝返回混合版本。
|
||||
Token string `json:"token,omitempty"` // Token 仅导入时填写;必须与当前摘要一致,旧代令牌不可导入。
|
||||
}
|
||||
|
||||
func (CredentialTokenInput) String() string { return "CredentialTokenInput{REDACTED}" }
|
||||
func (v CredentialTokenInput) GoString() string { return v.String() }
|
||||
|
||||
// CredentialToken 只在已认证且已提交查看审计的管理员专用请求中返回。
|
||||
type CredentialToken struct {
|
||||
NamespaceID core.ID `json:"namespace_id"` // NamespaceID 当前凭据的命名空间。
|
||||
CredentialID core.ID `json:"credential_id"` // CredentialID 当前凭据标识。
|
||||
Revision uint64 `json:"revision,string"` // Revision 读取时的当前凭据版本。
|
||||
Token string `json:"token"` // Token 当前代次原文,禁止进入日志、列表或浏览器持久存储。
|
||||
}
|
||||
|
||||
func (CredentialToken) String() string { return "CredentialToken{REDACTED}" }
|
||||
func (v CredentialToken) GoString() string { return v.String() }
|
||||
|
||||
// CredentialTokens 的 importCurrent 为真时补存原文;为假时只读取,两个操作均留审计。
|
||||
type CredentialTokens interface {
|
||||
AccessCredentialToken(context.Context, auth.Token, core.ID, core.ID, CredentialTokenInput, bool) (CredentialToken, error)
|
||||
}
|
||||
Reference in New Issue
Block a user