记录SSH私钥安全整改中间状态
提交密码认证收敛、历史字段清理迁移及相关测试调整,后续继续修复测试并完成复审。
This commit is contained in:
1 parent
d78e8e679e
commit
5af752b25a
16 files changed
+64
-120
No files matched your search
@@ -886,9 +886,6 @@ func (s *Server) updateServer(c *gin.Context) {
|
||||
func (s *Server) prepareServerCredential(ctx context.Context, item deployment.Server, password string, existing *deployment.Server) (deployment.Server, func(), error) {
|
||||
item = item.Normalize()
|
||||
cleanup := func() {}
|
||||
if item.PrivateKeyRef != "" {
|
||||
return deployment.Server{}, cleanup, errors.New("服务器仅支持 SSH 密码认证,不能使用 SSH 私钥")
|
||||
}
|
||||
item.AuthMethod = deployment.SSHAuthPassword
|
||||
if s.secrets == nil {
|
||||
return deployment.Server{}, cleanup, errors.New("SSH \u5bc6\u7801\u5b58\u50a8\u672a\u521d\u59cb\u5316")
|
||||
|
||||
@@ -16,17 +16,16 @@ func (f reloadTestFactory) Connect(ctx context.Context, item deployment.Server)
|
||||
return f.connect(ctx, item)
|
||||
}
|
||||
|
||||
func TestSSHAfterReloadRejectsPrivateKeyAuthentication(t *testing.T) {
|
||||
func TestSSHAfterReloadRejectsUnsupportedAuthentication(t *testing.T) {
|
||||
server := &Server{deploymentFactory: reloadTestFactory{connect: func(context.Context, deployment.Server) (deployment.Client, error) {
|
||||
t.Fatal("private key authentication must not reach the deployment factory")
|
||||
t.Fatal("unsupported authentication must not reach the deployment factory")
|
||||
return nil, nil
|
||||
}}}
|
||||
client, err := server.connectSSHAfterReload(t.Context(), deployment.Server{
|
||||
AuthMethod: deployment.SSHAuthPrivateKey,
|
||||
PrivateKeyRef: "secret://ssh/private-key",
|
||||
AuthMethod: deployment.SSHAuthMethod("unsupported"),
|
||||
HostKeyFingerprint: "SHA256:registered",
|
||||
})
|
||||
if client != nil || err == nil || !strings.Contains(err.Error(), "SSH") {
|
||||
t.Fatalf("private key authentication should be rejected: client=%v err=%v", client, err)
|
||||
t.Fatalf("unsupported authentication should be rejected: client=%v err=%v", client, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user