Skip to content
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 act-as powers #23549

Merged
merged 1 commit into from
Apr 14, 2016
Merged

add act-as powers #23549

merged 1 commit into from
Apr 14, 2016

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Mar 28, 2016

This adds the ability for a user to Act-As another user if he has the ability to verb="impersonate", resource="users", resourceName=<value of Act-As Header>.

@erictune @kubernetes/kube-iam @liggitt @smarterclayton

I'll need to update the authorizer to handle resource names through the interface, but I don't plan to update the abac policy file.

@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 28, 2016
@k8s-bot
Copy link

k8s-bot commented Mar 28, 2016

GCE e2e build/test failed for commit dc718777fad2ea724d839eee85899485a06b46ed.

Please reference the list of currently known flakes when examining this failure. If you request a re-test, you must reference the issue describing the flake.

@k8s-bot
Copy link

k8s-bot commented Mar 28, 2016

GCE e2e build/test passed for commit 85844c419933c4a507225d52bfa542f8922685e1.

newCtx, _ := requestContextMapper.Get(req)
oldUser, _ := api.UserFrom(ctx)
newUser, _ := api.UserFrom(newCtx)
glog.V(3).Infof("%v is acting as %v on %v", oldUser, newUser, req.URL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this request going to go into the HTTP log as the original or the impersonated user? I think the original user is more useful from a debugging and audit logging perspective, so we should try to preserve that. If it is possible to decorate the logs lines with the impersonated user name, that would be nice, but not as important as logging the original user.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it logging both the original and new user?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from this point on, anything that pulls the user out of the context will get the impersonated user

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was talking about the logs that the go http server emits to stdout and go into /var/log/kube-apiserver.log on a typical kubernetes cluster. That doesn't use glog.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that was logging the username here but it is just logging the User-Agent header. So, never mind.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do httplog.LogOf(req, w).Addf("%v is acting as %v", oldUser, newUser) to actually associate this message with the request in addition to logging directly here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's nifty… didn't know about that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erictune
Copy link
Member

looks good to me, but let lavalamp review too.

func TestActAsIsForbidden(t *testing.T) {
framework.DeleteAllEtcdKeys()

// This file has alice and bob in it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What file?

@deads2k
Copy link
Contributor Author

deads2k commented Mar 29, 2016

Two things:

  1. We never settled on the header name: Act-As, X-Authentication-Acting-As, Impersonate-User? I like Act-As best, but that might just be because that's how the original proposal was titled.
  2. The authorization check for service accounts (https://github.com/kubernetes/kubernetes/pull/23549/files#diff-6073dcd8ae44859aa2bee1af7531dfe0R437). It's a synthetic check, so we can make it check whatever we want. I chose the simple implementation for this pull ("users"), but I'd like to expand it allow a check for act-as against the exact serviceaccounts resource when an SA user is specified. I think that more accurately expresses what they're trying to do. If this is non-contentious I'll do it here. If we need to talk about it an issue, we can do that so we don't block the utility in this pull.

@deads2k deads2k force-pushed the acting-as branch 2 times, most recently from 7469b3a to 4a98512 Compare March 29, 2016 12:33
@k8s-bot
Copy link

k8s-bot commented Mar 29, 2016

GCE e2e build/test passed for commit 7469b3ad8cc156021c05b9b3a7954d5ad2dfc6cf.

@k8s-bot
Copy link

k8s-bot commented Mar 29, 2016

GCE e2e build/test passed for commit 4a985123d8c39b79ef31a8588091828e72349eb0.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 30, 2016
@erictune
Copy link
Member

Apparently "X-" is deprecated for headers. "Act-As" is so terse that I think it is unlikely to ever become a standard for this sort of thing, and doesn't document itself if someone is trying to understand our protocol by looking at the headers. "Impersonation" is sort of a term-of-art, and it is suggestive that the header relates to auth. So, I vote for David's third option, Impersonate-User.

@liggitt
Copy link
Member

liggitt commented Mar 30, 2016

Agree. I would change the verb check to "impersonate" as well

@erictune
Copy link
Member

Fine with impersonate verb as well.

For your item 2, David, are you suggesting something like this for a service account:

    actingAsAttributes := &authorizer.AttributesRecord{
            User:     requestor,
            Verb:     "act-as",
            APIGroup: api.GroupName,
            Resource: "serviceAccounts",
            ResourceName:    serviceAccountName,
            ResourceRequest: true,
        }

And possibly code to verify existence of the service account object in question in the namespace?

Verb: "act-as",
APIGroup: api.GroupName,
Resource: "users",
// ResourceName: requestedSubject,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I approve the "GetExtra" PR the would you put requestor user.Info.GetExtras["full-username"] or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I approve the "GetExtra" PR the would you put requestor user.Info.GetExtras["full-username"] or something like that?

I think I'd like to namespace the key, but I'm ok with that. Would you prefer that to filling in something more structured on the context itself?

@deads2k
Copy link
Contributor Author

deads2k commented Mar 30, 2016

For your item 2, David, are you suggesting something like this for a service account:

Yes.

And possibly code to verify existence of the service account object in question in the namespace?

I don't know that I'd force existence. I could imagine it being useful to impersonate someone who can't actually log in themselves.

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 5, 2016
@k8s-bot
Copy link

k8s-bot commented Apr 5, 2016

GCE e2e build/test failed for commit a40dff392f38e3428ae37a3fd57282b0083aeb4c.

Please reference the list of currently known flakes when examining this failure. If you request a re-test, you must reference the issue describing the flake.

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 5, 2016
@deads2k deads2k added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 5, 2016
@deads2k deads2k added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Apr 6, 2016
@k8s-bot
Copy link

k8s-bot commented Apr 6, 2016

GCE e2e build/test passed for commit 11a328b48ecedb70a5d57cdde8b8b8553e041532.

@roberthbailey
Copy link
Contributor

/cc @cjcullen

@k8s-github-robot
Copy link

@k8s-bot test this

Tests are more than 48 hours old. Re-running tests.

@k8s-bot
Copy link

k8s-bot commented Apr 8, 2016

GCE e2e build/test passed for commit 11a328b48ecedb70a5d57cdde8b8b8553e041532.

@k8s-github-robot
Copy link

@k8s-bot test this

Tests are more than 48 hours old. Re-running tests.

@k8s-bot
Copy link

k8s-bot commented Apr 10, 2016

GCE e2e build/test passed for commit 11a328b48ecedb70a5d57cdde8b8b8553e041532.

@k8s-github-robot
Copy link

@k8s-bot test this

Tests are more than 48 hours old. Re-running tests.

@k8s-bot
Copy link

k8s-bot commented Apr 12, 2016

GCE e2e build/test passed for commit 11a328b48ecedb70a5d57cdde8b8b8553e041532.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Apr 14, 2016

GCE e2e build/test passed for commit 11a328b48ecedb70a5d57cdde8b8b8553e041532.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Apr 14, 2016

GCE e2e build/test passed for commit 11a328b48ecedb70a5d57cdde8b8b8553e041532.

@deads2k deads2k added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Apr 14, 2016
@k8s-bot
Copy link

k8s-bot commented Apr 14, 2016

GCE e2e build/test passed for commit ac4c545.

@lavalamp lavalamp merged commit 1d96b4c into kubernetes:master Apr 14, 2016
@deads2k deads2k deleted the acting-as branch September 6, 2016 17:22
@k8s-reviewable
Copy link

This change is Reviewable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.