Skip to content

Commit

Permalink
feat: support other ssh keys other than ed25519 for git (#1032) (#1033)
Browse files Browse the repository at this point in the history
(cherry picked from commit 78779f5)

Co-authored-by: Tanmoy Sarkar <[email protected]>
  • Loading branch information
mergify[bot] and tanmoysrt authored Sep 26, 2024
1 parent 2e2f32d commit 0096b36
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions swiftwave_service/graphql/graphql_object_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func gitCredentialInputToDatabaseObject(record *model.GitCredentialInput, create
sshPrivateKey = string(privateKeyPem) + "\n"
publicKey, err := ssh.NewPublicKey(pub)
if err == nil {
sshPublicKey = "ssh-ed25519" + " " + base64.StdEncoding.EncodeToString(publicKey.Marshal()) + " swiftwave"
sshPublicKey = "ssh-ed25519 " + base64.StdEncoding.EncodeToString(publicKey.Marshal()) + " swiftwave"
}
}
}
Expand All @@ -68,8 +68,13 @@ func gitCredentialInputToDatabaseObject(record *model.GitCredentialInput, create
}
p, err := ssh.ParsePrivateKey([]byte(sshPrivateKey))
if err == nil {
if p.PublicKey().Type() == ssh.KeyAlgoED25519 {
sshPublicKey = "ssh-ed25519" + " " + base64.StdEncoding.EncodeToString(p.PublicKey().Marshal()) + " swiftwave"
if p.PublicKey().Type() == ssh.KeyAlgoRSA ||
p.PublicKey().Type() == ssh.KeyAlgoDSA ||
p.PublicKey().Type() == ssh.KeyAlgoECDSA256 || p.PublicKey().Type() == ssh.KeyAlgoECDSA384 || p.PublicKey().Type() == ssh.KeyAlgoECDSA521 ||
p.PublicKey().Type() == ssh.KeyAlgoSKECDSA256 ||
p.PublicKey().Type() == ssh.KeyAlgoED25519 ||
p.PublicKey().Type() == ssh.KeyAlgoSKED25519 {
sshPublicKey = p.PublicKey().Type() + " " + base64.StdEncoding.EncodeToString(p.PublicKey().Marshal()) + " swiftwave"
}
}
}
Expand Down

0 comments on commit 0096b36

Please sign in to comment.