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

rules review API: what can I do? #887

Merged
merged 1 commit into from
Nov 1, 2017

Conversation

ericchiang
Copy link
Contributor

xref kubernetes/enhancements#380

cc @kubernetes/sig-auth-proposals @kubernetes/api-reviewers @xilabao

@k8s-ci-robot k8s-ci-robot added sig/auth Categorizes an issue or PR as relevant to SIG Auth. kind/design Categorizes issue or PR as related to design. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 9, 2017

This could hopefully be solved by introducing a `SubjectRulesReview` API to query the rules for any user. An aggregated API server could use the `SubjectRulesReview` to back an API resource that let a user provide restrictive user extras, such as scopes.

## Webhook authorizers
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cjcullen @dims for proposed webhook integration.


All of these fields can include the string `*` to indicate all values are allowed.

### Differences from OpenShift: user extras vs. scopes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deads2k tired to articulate my concerns about making user extras configurable. ptal


In core kube, scopes are replaced by "user extras" field, a map of opaque strings that can be used for implementation specific user data. Unlike OpenShift, where scopes are always used to restrict credential powers, user extras are commonly used to expand powers. For example, the proposed [Keystone authentiator][keystone-authn] used them to include additional roles and project fields.

Since user extras can be used to expand the power of users, instead of only restricting, this proposal argues that `SelfSubjectRulesReview` shouldn't let a client specify them like `Scopes`. It wouldn't be within the spirit of a `SelfSubject` resource to let a user determine information about other projects or roles.
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless there's an authorizer that actually conditionally allows access to particularly named resources based one their actual, I don't think this allows you to go fishing in other namespaces. I don't care enough to try to stop the good bits of the API, but is there any other way?

Copy link
Contributor Author

@ericchiang ericchiang Aug 9, 2017

Choose a reason for hiding this comment

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

Unless there's an authorizer that actually conditionally allows access to particularly named resources based one their actual

From what I can see @dims' keystone authorizer does that https://github.com/dims/k8s-keystone-auth

@cjcullen any other insight into how/if GKE uses user extra?

Maybe we could re-word user-extra to try to emphasis its usage as part of this change?

Extra fields should NOT be used to grant access to new namespaces. Only to modify the
access of a user within a namespace.

Copy link
Contributor

Choose a reason for hiding this comment

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

Extra fields should NOT be used to grant access to new namespaces. Only to modify the
access of a user within a namespace.

Granting access to other namespaces does not leak information, since if I lie about my extra and see "yes you have access to namespace X", I'd get that result regardless of whether the namespace exists.

Copy link
Contributor Author

@ericchiang ericchiang Aug 10, 2017

Choose a reason for hiding this comment

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

Granting access to other namespaces does not leak information, since if I lie about my extra and see "yes you have access to namespace X", I'd get that result regardless of whether the namespace exists.

You're still leaking information about what users have been given access to what though, which could correlate to what exists. I could find out that project team-foo doesn't have any powers in namespace secret-project-bar but does have powers in namespace secret-project-spam.

It's probably not the biggest concern, but it feels weird to allow a user to control any fields that extend their access.

Can we let clients provide something like an additive "Impersonate-Extra-*" header that would only add extras to the authenticated user info? That way an admin could declare what extras are okay to freely add to a user:

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  # Any user bound to this role can add a "scopes" user extra field to their user info
  # through an HTTP header.
  name: scopes-adder
- apiGroups: ["authentication.k8s.io"]
  resources: ["userextras/scopes"]
  verbs: ["impersonate:additive"] # this is a bad name for the verb

This would let them use both SelfSubjectRulesReview with whatever extras an admin deemed okay, and would extend those capabilities to other commands.

@erictune
Copy link
Member

erictune commented Aug 9, 2017

There is not enough discussion, for my taste, of how a client (e.g. dashboard) would use the results of this API. Is it just so that it can hide/inactivate UI options that are not possible, or would it actually make its own authorization decisions and then act as a more powerful user? What client libraries will be provided to help the client make correct decisions from the cached results of the rules review? How long should clients cache the rules review? Is this just a glorified form of caching, and why not just add more pure caching of AccessReview decisions?

@bryk
Copy link
Contributor

bryk commented Aug 9, 2017

CC @kubernetes/dashboard-maintainers

@liggitt
Copy link
Member

liggitt commented Aug 9, 2017

In Openshift, we use it to show/hide actions in a UI based on the user's permissions:

Example "can I" function:
https://github.com/openshift/origin-web-common/blob/master/src/services/authorizationService.js#L102-L131

Example use:
https://github.com/openshift/origin-web-console/blob/2fb62238b922bebd311ccb43bc00c39500452828/app/scripts/directives/overview/serviceInstanceRow.js#L59-L73

In a dashboard with many different actions, some of which involve multiple API calls, determing those permissions via individual SAR checks was far more expensive (both in terms of API requests and in terms of server-side work)

cc @spadgett @jwforres

@erictune
Copy link
Member

erictune commented Aug 9, 2017 via email

@liggitt
Copy link
Member

liggitt commented Aug 9, 2017

When you say "server side" do you mean the UI server?

No, the apiserver that would have evaluated those dozens of subjectaccessreview requests.

Are you saying that the rules get loaded into javascript in the users browser to show, and cause actions to show/hide in the browser.

Yes

Then, when the user takes an action, is the final decision still made by the UI-server or by the apiserver?

The final decision is the API server's. This lets the UI avoid showing the user actions and wizards and pages that would just result in 403 errors from the API

Also, we don't really have a UI server... the openshift web console is a javascript-only application that speaks directly to the apiserver.

@erictune
Copy link
Member

erictune commented Aug 9, 2017 via email

@ericchiang
Copy link
Contributor Author

Thanks @erictune. Expanded the bit about how UIs might use this and tried to make it clear that this API shouldn't be used to drive external authz.

@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 15, 2017

type SelfSubjectRulesReviewSpec struct {
// Namespace to evaluate rules for. Required.
Namespace string
Copy link
Contributor

Choose a reason for hiding this comment

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

Having this all be dependent on the user knowing which Namespaces they have some form of access to might be quite inconvenient for a UI.
e.g. the kubernetes/dashboard currently (1) queries for the available namespaces and then (2) allows viewing the resources in each of those namespaces. If I understand the proposal correctly this would support the (2) part of this flow, but no way to support for the (1) part of this flow.
Is there room for a non namespaced version of this Spec, or a "Which namespaces have I more than zero access to" api? This would be a helpful part of this API for the dashboard

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rf232 for some background querying resources across all namespaces was deemed too expensive.

I know the actual namespace object is a bit special. I think users can "GET" the namespace object resource by name if they have any access in it already (couldn't find the code path that allows this). CoreOS has internally built apps that do something like:

  • privileged service account lists all namespace
  • looks up if a user can get each specific namespace
  • builds list to display user from that

Agree that probably doesn't work at scale, but a "what namespaces can I see" might be a different API. I think openshift just implemented namespace filtering, so there's no prior art there.

Copy link
Member

Choose a reason for hiding this comment

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

Is there room for a non namespaced version of this Spec

Yes, but it wouldn't do what you describe, it would tell you the things you could do across all namespaces (e.g. kubectl get pods --all-namespaces)

or a "Which namespaces have I more than zero access to" api? This would be a helpful part of this API for the dashboard

Agree it is useful (we built something close to that API in openshift), but it's a different API than this one and requires more capabilities from the authorization interface to implement performantly

I think users can "GET" the namespace object resource by name if they have any access in it already

Not quite, the admin/edit/view roles simply grant "get" "namespace", so when those roles are bound in a particular namespace, the ability to get that namespace is granted.

Copy link
Contributor

@rf232 rf232 Aug 17, 2017

Choose a reason for hiding this comment

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

  • privileged service account lists all namespace
  • looks up if a user can get each specific namespace
  • builds list to display user from that

This is a possibility, but recently at the dashboard we were looking at reducing the privileges the dashboard itself needs to lower the risk of privilege escalations with the dashboard.

@lpabon
Copy link

lpabon commented Aug 29, 2017

LGTM. Suggestion: Is it possible to add a client-server workflow example?


## Overview

Currently, to determine if a user is authorized to perform a set of actions, that user has to query each action individually thorough a `SelfSubjectAccessReview`.
Copy link
Member

Choose a reason for hiding this comment

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

typo: through


## Webhook authorizers

Some authorizers are live external to Kubernetes through an API server webhook and wouldn't immediately support a rules review query.
Copy link
Member

Choose a reason for hiding this comment

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

"Some authorizers live external"

@idvoretskyi idvoretskyi removed their assignment Oct 24, 2017
@ericchiang
Copy link
Contributor Author

@kubernetes/sig-auth-proposals I'd like to merge this. SelfSubjectRulesReview was introduced in 1.8 and the webhook support has been reviewed kubernetes/kubernetes#53922 :)

@deads2k
Copy link
Contributor

deads2k commented Nov 1, 2017

This represents the current state. I think updates may be required in light of kubernetes/kubernetes#53922, but we can start here.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 1, 2017
@deads2k
Copy link
Contributor

deads2k commented Nov 1, 2017

/test all

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue.

@k8s-github-robot k8s-github-robot merged commit 987e686 into kubernetes:master Nov 1, 2017
@ericchiang ericchiang deleted the rules-review-api branch November 1, 2017 17:28
MadhavJivrajani pushed a commit to MadhavJivrajani/community that referenced this pull request Nov 30, 2021
Automatic merge from submit-queue.

rules review API: what can I do?

xref kubernetes/enhancements#380

cc @kubernetes/sig-auth-proposals @kubernetes/api-reviewers @xilabao
danehans pushed a commit to danehans/community that referenced this pull request Jul 18, 2023
Signed-off-by: aimuz <mr.imuz@gmail.com>

Signed-off-by: aimuz <mr.imuz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/design Categorizes issue or PR as related to design. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/auth Categorizes an issue or PR as relevant to SIG Auth. 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.