Skip to content

Commit b048537

Browse files
authored
Merge pull request #25 from Infisical/ssh-cert
Update ssh issue/sign to be based on certificate template id
2 parents 318b41b + 709c3ad commit b048537

File tree

2 files changed

+33
-38
lines changed

2 files changed

+33
-38
lines changed

packages/api/ssh/models.go

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ import (
55
)
66

77
type SignSshPublicKeyV1Request struct {
8-
ProjectID string `json:"projectId"`
9-
TemplateName string `json:"templateName"`
10-
PublicKey string `json:"publicKey"`
11-
KeyAlgorithm util.CertKeyAlgorithm `json:"keyAlgorithm,omitempty"`
12-
CertType util.SshCertType `json:"certType,omitempty"`
13-
Principals []string `json:"principals"`
14-
TTL string `json:"ttl,omitempty"`
15-
KeyID string `json:"keyId,omitempty"`
8+
CertificateTemplateID string `json:"certificateTemplateId"`
9+
PublicKey string `json:"publicKey"`
10+
CertType util.SshCertType `json:"certType,omitempty"`
11+
Principals []string `json:"principals"`
12+
TTL string `json:"ttl,omitempty"`
13+
KeyID string `json:"keyId,omitempty"`
1614
}
1715

1816
type SignSshPublicKeyV1Response struct {
@@ -21,19 +19,18 @@ type SignSshPublicKeyV1Response struct {
2119
}
2220

2321
type IssueSshCredsV1Request struct {
24-
ProjectID string `json:"projectId"`
25-
TemplateName string `json:"templateName"`
26-
KeyAlgorithm util.CertKeyAlgorithm `json:"keyAlgorithm,omitempty"`
27-
CertType util.SshCertType `json:"certType,omitempty"`
28-
Principals []string `json:"principals"`
29-
TTL string `json:"ttl,omitempty"`
30-
KeyID string `json:"keyId,omitempty"`
22+
CertificateTemplateID string `json:"certificateTemplateId"`
23+
KeyAlgorithm util.CertKeyAlgorithm `json:"keyAlgorithm,omitempty"`
24+
CertType util.SshCertType `json:"certType,omitempty"`
25+
Principals []string `json:"principals"`
26+
TTL string `json:"ttl,omitempty"`
27+
KeyID string `json:"keyId,omitempty"`
3128
}
3229

3330
type IssueSshCredsV1Response struct {
34-
SerialNumber string `json:"serialNumber"`
35-
SignedKey string `json:"signedKey"`
36-
PrivateKey string `json:"privateKey"`
37-
PublicKey string `json:"publicKey"`
31+
SerialNumber string `json:"serialNumber"`
32+
SignedKey string `json:"signedKey"`
33+
PrivateKey string `json:"privateKey"`
34+
PublicKey string `json:"publicKey"`
3835
KeyAlgorithm util.CertKeyAlgorithm `json:"keyAlgorithm"`
3936
}

test/ssh_test.go

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,37 @@ package test
1111

1212
// func TestSshIssueCreds(t *testing.T) {
1313
// client := infisical.NewInfisicalClient(context.Background(), infisical.Config{
14-
// SiteUrl: "http://localhost:8080",
15-
// AutoTokenRefresh: true,
16-
// })
14+
// SiteUrl: "http://localhost:8080",
15+
// AutoTokenRefresh: true,
16+
// })
1717

1818
// // Authenticate using Universal Auth
19-
// _, err := client.Auth().UniversalAuthLogin(os.Getenv("GO_SDK_TEST_UNIVERSAL_AUTH_CLIENT_ID"), os.Getenv("GO_SDK_TEST_UNIVERSAL_AUTH_CLIENT_SECRET"))
20-
// if err != nil {
21-
// fmt.Printf("Authentication failed: %v\n", err)
22-
// os.Exit(1)
23-
// }
19+
// _, err := client.Auth().UniversalAuthLogin("", "")
20+
// if err != nil {
21+
// fmt.Printf("Authentication failed: %v\n", err)
22+
// os.Exit(1)
23+
// }
2424

2525
// // Test issuing SSH credentials
2626
// creds, err := client.Ssh().IssueCredentials(infisical.IssueSshCredsOptions{
27-
// ProjectID: os.Getenv("GO_SDK_TEST_PROJECT_ID"),
28-
// TemplateName: "template-name",
29-
// Principals: []string{"ec2-user"},
27+
// CertificateTemplateID: "",
28+
// Principals: []string{"ec2-user"},
3029
// })
3130

32-
// if err != nil {
31+
// if err != nil {
3332
// t.Fatalf("Failed to issue SSH credentials: %v", err)
34-
// }
33+
// }
3534

3635
// // Test signing SSH public key
3736
// creds2, err := client.Ssh().SignKey(infisical.SignSshPublicKeyOptions{
38-
// ProjectID: os.Getenv("GO_SDK_TEST_PROJECT_ID"),
39-
// TemplateName: "template-name",
40-
// Principals: []string{"ec2-user"},
41-
// PublicKey: "ssh-rsa ...",
37+
// CertificateTemplateID: "",
38+
// Principals: []string{"ec2-user"},
39+
// PublicKey: "ssh-rsa ...",
4240
// })
4341

44-
// if err != nil {
42+
// if err != nil {
4543
// t.Fatalf("Failed to sign SSH public key: %v", err)
46-
// }
44+
// }
4745

4846
// fmt.Print("Newly-issued SSH credentials: ", creds)
4947
// fmt.Print("Signed SSH credential: ", creds2)

0 commit comments

Comments
 (0)