-
Notifications
You must be signed in to change notification settings - Fork 234
Add manual opt-in for legacy service account tokens #357
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
base: sig-auth-acceptance
Are you sure you want to change the base?
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 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -110,7 +110,7 @@ func testBasics(client kubernetes.Interface) kubetest.TestSuite { | |||||||||||||||||||
|
||||||||||||||||||||
func testTokenAudience(client kubernetes.Interface) kubetest.TestSuite { | ||||||||||||||||||||
return func(t *testing.T) { | ||||||||||||||||||||
command := `curl --connect-timeout 5 -v -s -k --fail -H "Authorization: Bearer $(cat /var/run/secrets/tokens/requestedtoken)" https://kube-rbac-proxy.default.svc.cluster.local:8443/metrics` | ||||||||||||||||||||
command := `curl --connect-timeout 5 -v -s -k --fail -H "Authorization: Bearer $(cat /var/run/projected/tokens/requestedtoken)" https://kube-rbac-proxy.default.svc.cluster.local:8443/metrics` | ||||||||||||||||||||
|
||||||||||||||||||||
kubetest.Scenario{ | ||||||||||||||||||||
Name: "IncorrectAudience", | ||||||||||||||||||||
|
@@ -519,3 +519,129 @@ func testIgnorePaths(client kubernetes.Interface) kubetest.TestSuite { | |||||||||||||||||||
}.Run(t) | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
func testLegacyTokenFlag(client kubernetes.Interface) kubetest.TestSuite { | ||||||||||||||||||||
return func(t *testing.T) { | ||||||||||||||||||||
legacyCommand := `curl --connect-timeout 5 -v -s -k --fail -H "Authorization: Bearer $(cat /var/run/legacy/tokens/token)" https://kube-rbac-proxy.default.svc.cluster.local:8443/metrics` | ||||||||||||||||||||
command := `curl --connect-timeout 5 -v -s -k --fail -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" https://kube-rbac-proxy.default.svc.cluster.local:8443/metrics` | ||||||||||||||||||||
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. I think this command should actually have 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. The LegacyAllowedNoAudience test checks a scenario with no audience set. But kube-rbac-proxy/test/kubetest/kubernetes.go Lines 524 to 532 in 670377f
That's why I use the default token /var/run/secrets/kubernetes.io/serviceaccount/token instead.
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. The |
||||||||||||||||||||
|
||||||||||||||||||||
kubetest.Scenario{ | ||||||||||||||||||||
Name: "LegacyAllowedAudienceSet", | ||||||||||||||||||||
Description: ` | ||||||||||||||||||||
As a client with --allow-legacy-serviceaccount-tokens=true and a valid audience, | ||||||||||||||||||||
I succeed with my request | ||||||||||||||||||||
`, | ||||||||||||||||||||
|
||||||||||||||||||||
Given: kubetest.Actions( | ||||||||||||||||||||
kubetest.CreatedManifests( | ||||||||||||||||||||
client, | ||||||||||||||||||||
"legacy/audience/serviceAccount.yaml", | ||||||||||||||||||||
"legacy/audience/secret-legacy.yaml", | ||||||||||||||||||||
"legacy/audience/clusterRole.yaml", | ||||||||||||||||||||
"legacy/audience/clusterRoleBinding.yaml", | ||||||||||||||||||||
"legacy/audience/deployment-allowed.yaml", | ||||||||||||||||||||
"legacy/audience/service.yaml", | ||||||||||||||||||||
"legacy/audience/clusterRole-client.yaml", | ||||||||||||||||||||
"legacy/audience/clusterRoleBinding-client.yaml", | ||||||||||||||||||||
), | ||||||||||||||||||||
), | ||||||||||||||||||||
When: kubetest.Actions( | ||||||||||||||||||||
kubetest.PodsAreReady( | ||||||||||||||||||||
client, | ||||||||||||||||||||
1, | ||||||||||||||||||||
"app=kube-rbac-proxy", | ||||||||||||||||||||
), | ||||||||||||||||||||
kubetest.ServiceIsReady( | ||||||||||||||||||||
client, | ||||||||||||||||||||
"kube-rbac-proxy", | ||||||||||||||||||||
), | ||||||||||||||||||||
), | ||||||||||||||||||||
Then: kubetest.Actions( | ||||||||||||||||||||
kubetest.ClientSucceeds( | ||||||||||||||||||||
client, | ||||||||||||||||||||
legacyCommand, | ||||||||||||||||||||
&kubetest.RunOptions{LegacyToken: true}, | ||||||||||||||||||||
), | ||||||||||||||||||||
), | ||||||||||||||||||||
}.Run(t) | ||||||||||||||||||||
|
||||||||||||||||||||
kubetest.Scenario{ | ||||||||||||||||||||
Name: "LegacyDisallowedAudienceSet", | ||||||||||||||||||||
Description: ` | ||||||||||||||||||||
As a client with --allow-legacy-serviceaccount-tokens=false and a valid audience, | ||||||||||||||||||||
I fail with my request | ||||||||||||||||||||
`, | ||||||||||||||||||||
|
||||||||||||||||||||
Given: kubetest.Actions( | ||||||||||||||||||||
kubetest.CreatedManifests( | ||||||||||||||||||||
client, | ||||||||||||||||||||
"legacy/audience/serviceAccount.yaml", | ||||||||||||||||||||
"legacy/audience/secret-legacy.yaml", | ||||||||||||||||||||
"legacy/audience/clusterRole.yaml", | ||||||||||||||||||||
"legacy/audience/clusterRoleBinding.yaml", | ||||||||||||||||||||
"legacy/audience/deployment-disallowed.yaml", | ||||||||||||||||||||
"legacy/audience/service.yaml", | ||||||||||||||||||||
"legacy/audience/clusterRole-client.yaml", | ||||||||||||||||||||
"legacy/audience/clusterRoleBinding-client.yaml", | ||||||||||||||||||||
), | ||||||||||||||||||||
), | ||||||||||||||||||||
When: kubetest.Actions( | ||||||||||||||||||||
kubetest.PodsAreReady( | ||||||||||||||||||||
client, | ||||||||||||||||||||
1, | ||||||||||||||||||||
"app=kube-rbac-proxy", | ||||||||||||||||||||
), | ||||||||||||||||||||
kubetest.ServiceIsReady( | ||||||||||||||||||||
client, | ||||||||||||||||||||
"kube-rbac-proxy", | ||||||||||||||||||||
), | ||||||||||||||||||||
), | ||||||||||||||||||||
Then: kubetest.Actions( | ||||||||||||||||||||
kubetest.ClientFails( | ||||||||||||||||||||
client, | ||||||||||||||||||||
legacyCommand, | ||||||||||||||||||||
&kubetest.RunOptions{LegacyToken: true}, | ||||||||||||||||||||
), | ||||||||||||||||||||
), | ||||||||||||||||||||
}.Run(t) | ||||||||||||||||||||
|
||||||||||||||||||||
kubetest.Scenario{ | ||||||||||||||||||||
Name: "LegacyAllowedNoAudience", | ||||||||||||||||||||
Description: ` | ||||||||||||||||||||
As a client with --allow-legacy-serviceaccount-tokens=true and no audience set, | ||||||||||||||||||||
I succeed with my request | ||||||||||||||||||||
`, | ||||||||||||||||||||
|
||||||||||||||||||||
Given: kubetest.Actions( | ||||||||||||||||||||
kubetest.CreatedManifests( | ||||||||||||||||||||
client, | ||||||||||||||||||||
"legacy/noaud/clusterRole.yaml", | ||||||||||||||||||||
"legacy/noaud/clusterRoleBinding.yaml", | ||||||||||||||||||||
"legacy/noaud/deployment.yaml", | ||||||||||||||||||||
"legacy/noaud/service.yaml", | ||||||||||||||||||||
"legacy/noaud/serviceAccount.yaml", | ||||||||||||||||||||
"legacy/noaud/clusterRole-client.yaml", | ||||||||||||||||||||
"legacy/noaud/clusterRoleBinding-client.yaml", | ||||||||||||||||||||
), | ||||||||||||||||||||
), | ||||||||||||||||||||
When: kubetest.Actions( | ||||||||||||||||||||
kubetest.PodsAreReady( | ||||||||||||||||||||
client, | ||||||||||||||||||||
1, | ||||||||||||||||||||
"app=kube-rbac-proxy", | ||||||||||||||||||||
), | ||||||||||||||||||||
kubetest.ServiceIsReady( | ||||||||||||||||||||
client, | ||||||||||||||||||||
"kube-rbac-proxy", | ||||||||||||||||||||
), | ||||||||||||||||||||
), | ||||||||||||||||||||
Then: kubetest.Actions( | ||||||||||||||||||||
kubetest.ClientSucceeds( | ||||||||||||||||||||
client, | ||||||||||||||||||||
command, | ||||||||||||||||||||
nil, | ||||||||||||||||||||
), | ||||||||||||||||||||
), | ||||||||||||||||||||
}.Run(t) | ||||||||||||||||||||
} | ||||||||||||||||||||
} |
Uh oh!
There was an error while loading. Please reload this page.