-
Notifications
You must be signed in to change notification settings - Fork 158
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
Add nsaccess package to determine if a user "has access" to a namespace #1857
Conversation
20f20c6
to
db074a1
Compare
db074a1
to
9e4c7b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a small nit, otherwise lgtm
(hasAllRules
is a bit chaotic)
core/server/kustomization_test.go
Outdated
func newNamespace(ctx context.Context, k client.Client, g *GomegaWithT) corev1.Namespace { | ||
ns := &corev1.Namespace{} | ||
ns.Name = "kube-test-" + rand.String(5) | ||
|
||
g.Expect(k.Create(ctx, ns)).To(Succeed()) | ||
|
||
return ns | ||
return *ns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be
func newNamespace(ctx context.Context, k client.Client, g *GomegaWithT) corev1.Namespace {
ns := corev1.Namespace{}
ns.Name = "kube-test-" + rand.String(5)
g.Expect(k.Create(ctx, &ns)).To(Succeed())
return ns
}
It's kind of the same, but looks less weird with return *ns
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment to help out clean up the tests
core/nsaccess/nsaccess_test.go
Outdated
} | ||
|
||
createRole(t, adminClient, roleName, rules) | ||
secretName := createKubeConfig(t, adminClient, testCfg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can simplify the user config creation by just:
userCfg := *testCfg
userCfg.Impersonate = rest.ImpersonationConfig{
UserName: userName,
}
TODO:
|
4107650
to
6940886
Compare
6940886
to
ad099e0
Compare
Closes #1725
The goal of this work was to be able to provide a list of Kubernetes namespaces that a user can access. "Access" in this context, is determined by a minimum set of actions a user can take. In the default case, those actions map directly to the things that the
wego-app
can do.Some thoughts:
k8s
machinery that can do this? I looked at lots of different source code, but could not find anything that does exactly this.hasAllRules
function is very un-go
like to me, but given how flexible the rules can be, I chose to model this as a string-matching problem. Any input on that section would be appreciated.CC @JamWils This is the brute force approach we had discussed, with an opening for a different (better?) implementation in the future.