feat: let administrators view and copy encrypted integration credentials
This commit is contained in:
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