-
Notifications
You must be signed in to change notification settings - Fork 456
Add the ability to auth via certs without storing them in etcd secret #5200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
asoconfig "github.com/Azure/azure-service-operator/v2/pkg/common/config" | ||
"github.com/pkg/errors" | ||
|
@@ -287,23 +288,33 @@ | |
return newASOSecret, nil | ||
} | ||
|
||
// Fetch identity secret, if it exists | ||
key = types.NamespacedName{ | ||
Namespace: identity.Spec.ClientSecret.Namespace, | ||
Name: identity.Spec.ClientSecret.Name, | ||
} | ||
identitySecret := &corev1.Secret{} | ||
err := asos.Get(ctx, key, identitySecret) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to fetch AzureClusterIdentity secret") | ||
} | ||
if identity.Spec.CertPath != "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you able to add a test case or two to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call. I added a test which found a minor error. Service Principal with Certificate was expected to have a client secret here. That's been fixed in this PR. Client Secret isn't needed with using Certificate (see this in the Azure SDK as an example). |
||
certsContent, err := os.ReadFile(identity.Spec.CertPath) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to read certificate file") | ||
} | ||
|
||
switch identity.Spec.Type { | ||
case infrav1.ServicePrincipal, infrav1.ManualServicePrincipal: | ||
newASOSecret.Data[asoconfig.AzureClientSecret] = identitySecret.Data[scope.AzureSecretKey] | ||
case infrav1.ServicePrincipalCertificate: | ||
newASOSecret.Data[asoconfig.AzureClientCertificate] = identitySecret.Data["certificate"] | ||
newASOSecret.Data[asoconfig.AzureClientCertificatePassword] = identitySecret.Data["password"] | ||
newASOSecret.Data[asoconfig.AzureClientCertificate] = certsContent | ||
newASOSecret.Data[asoconfig.AzureClientCertificatePassword] = []byte{} | ||
} else { | ||
// Fetch identity secret, if it exists | ||
key = types.NamespacedName{ | ||
Namespace: identity.Spec.ClientSecret.Namespace, | ||
Name: identity.Spec.ClientSecret.Name, | ||
} | ||
identitySecret := &corev1.Secret{} | ||
err := asos.Get(ctx, key, identitySecret) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to fetch AzureClusterIdentity secret") | ||
} | ||
|
||
switch identity.Spec.Type { | ||
case infrav1.ServicePrincipal, infrav1.ManualServicePrincipal: | ||
newASOSecret.Data[asoconfig.AzureClientSecret] = identitySecret.Data[scope.AzureSecretKey] | ||
case infrav1.ServicePrincipalCertificate: | ||
newASOSecret.Data[asoconfig.AzureClientCertificate] = identitySecret.Data["certificate"] | ||
newASOSecret.Data[asoconfig.AzureClientCertificatePassword] = identitySecret.Data["password"] | ||
} | ||
} | ||
return newASOSecret, nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDjrdEr9P0TaUES | ||
dspE6cyo22NU8yhRrbYlV9VH2vWvnPsThXcxhnd+cUqdNEBswhwgFlUQcg/eSVxw | ||
rr+3nh+bFTZWPcY+1LQYxfpKGsrCXQfB82LDJIZDX4gHYrWf3Z272jXN1XeFAKti | ||
wDKgDXXuPH7r5lH7vC3RXeAffqLwQJhZf+NoHNtv9MH9IdUkQfmDFZtI/CQzCrb6 | ||
+vOS6EmUD/Q2FNHBzgxCguGqgNyBcQbxJ9Qng+ZjIFuhGYXJlsyRUtexyzTR5/v0 | ||
VNK8UsZgRBFhXqrBv/RoCCG+xVJYtmd0QsrvNzDqG6QnjUB21zVXqzKEkW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Wc4XG6WnYphUdyZLMoIlq0syZ1aj6YbqoK9NMHAYEnCvSov6zIZOa | ||
trhuUcf9GFz5e0iJ2zIlDc312Iwsv41xiC/bs16kEn8Yf/SujEXasj7vmA3HrFWf | ||
wZTH/yFL5azo/f+lA1Q28YwqFpHmle0y0O53Uth4p0tmwlnu+CrO9fHp3kTlb7fD | ||
6mqfk9Nrt8tOC4aHYDoqtYUgZhx58xsHMOTetKeRlp8HMF9oROtriz4nYm6IhTwo | ||
5k1A13S3BjaxkZCyPXCgXssuXagNLasrr5Qq+Vgdb/nDhVehV8+Z4J0Ynzy9MZsE | ||
H1N1NfMtsA+PEqtPXA== | ||
-----END CERTIFICATE----- |
Uh oh!
There was an error while loading. Please reload this page.