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 subjectaccessreviews resource #20573

Merged
merged 2 commits into from
Aug 5, 2016

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Feb 3, 2016

Adds a subjectaccessreviews endpoint that uses the API server's authorizer to determine if a subject is allowed to perform an action.

Part of kubernetes/enhancements#37

@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 3, 2016
@lavalamp
Copy link
Member

lavalamp commented Feb 3, 2016

Looks good so far.

@k8s-github-robot
Copy link

PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 18, 2016
@deads2k deads2k changed the title [WIP] add subjectaccessreviews resource add subjectaccessreviews resource Mar 23, 2016
@deads2k
Copy link
Contributor Author

deads2k commented Mar 23, 2016

spec and status made into pointers and a simple test added to verify the plumbing.

@lavalamp I can't get the client to generate properly. It seems to built around the idea that all types will have names. I was following directions here: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/generating-clientset.md .

@k8s-github-robot k8s-github-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 23, 2016
@lavalamp
Copy link
Member

@caesarxuchao can you take a look at why the client generation is unhappy?

@caesarxuchao
Copy link
Member

I can't get the client to generate properly. It seems to built around the idea that all types will have names.

@deads2k not sure what you mean by "all types will have names". I don't see anything special in your types.go. How can I reproduce the problem you encountered?

@erictune
Copy link
Member

this is cool. 👍

@deads2k
Copy link
Contributor Author

deads2k commented Mar 28, 2016

@caesarxuchao I updated this branch with the failing code. You can't get these objects, so there's no list and no name. I end up with failures like this:

# k8s.io/kubernetes/pkg/client/typed/generated/authorization/unversioned
_output/local/go/src/k8s.io/kubernetes/pkg/client/typed/generated/authorization/unversioned/subjectaccessreview.go:40: undefined: authorization.SubjectAccessReviewList
_output/local/go/src/k8s.io/kubernetes/pkg/client/typed/generated/authorization/unversioned/subjectaccessreview.go:73: subjectAccessReview.Name undefined (type *authorization.SubjectAccessReview has no field or method Name)
_output/local/go/src/k8s.io/kubernetes/pkg/client/typed/generated/authorization/unversioned/subjectaccessreview.go:112: undefined: authorization.SubjectAccessReviewList
_output/local/go/src/k8s.io/kubernetes/pkg/client/typed/generated/authorization/unversioned/subjectaccessreview.go:113: undefined: authorization.SubjectAccessReviewList

@k8s-github-robot k8s-github-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 28, 2016
@caesarxuchao
Copy link
Member

@deads2k I see how the client-gen fails.

What client methods to you need? It seems you can only have Create(), DeleteCollection(), and Watch(), because the object doesn't have ObjectMeta and doesn't have a list. Are they the methods you need? Or Do you need to some special methods to operate on SubjectAccessReview?

@deads2k
Copy link
Contributor Author

deads2k commented Mar 28, 2016

What client methods to you need? It seems you can only have Create(), DeleteCollection(), and Watch(), because the object doesn't have ObjectMeta and doesn't have a list. Are they the methods you need? Or Do you need to some special methods to operate on SubjectAccessReview?

I only need Create.

@caesarxuchao
Copy link
Member

I'll fix client-gen to allow user express what client methods to generate. Opened issue #23547.

In the meantime, if you don't want to get blocked by the client, you can use the "noMethods=true" tag (https://github.com/kubernetes/kubernetes/pull/19499/files#diff-e1c628c34c42840b0392c48481d41320R52), and manually write your create method as an expansion, you can take the pod_expansion.go as an example: https://github.com/kubernetes/kubernetes/blob/master/pkg/client/typed/generated/core/unversioned/pod_expansion.go. How does this sound?

@deads2k
Copy link
Contributor Author

deads2k commented Mar 28, 2016

@caesarxuchao
Copy link
Member

@deads2k Could you explain why the authorization API only needs a Create() method? Is there a design doc that I should read? I'm trying to understand if this is a general problem for other API as well. Thanks.

@deads2k
Copy link
Contributor Author

deads2k commented Mar 28, 2016

@deads2k Could you explain why the authorization API only needs a Create() method? Is there a design doc that I should read? I'm trying to understand if this is a general problem for other API as well. Thanks.

Yes, I'm filling in the implementation for this: https://github.com/kubernetes/kubernetes/blob/master/docs/design/enhance-pluggable-policy.md#subjectaccessreviews .

@deads2k
Copy link
Contributor Author

deads2k commented Mar 28, 2016

@deads2k Could you explain why the authorization API only needs a Create() method?

The short version is that we need to provide a request body to hold an API object and we want to return the system's view of the world back to the caller. We don't care about storing these, so we haven't built any infrastructure to actually persist them.

@caesarxuchao
Copy link
Member

we want to return the system's view of the world back to the caller

IIUC, the return value of the Create() method isn't a SubjectAccessReview?

@deads2k deads2k added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Aug 5, 2016
@deads2k deads2k added this to the v1.4 milestone Aug 5, 2016
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 5, 2016
@deads2k
Copy link
Contributor Author

deads2k commented Aug 5, 2016

restricted validation and updated generators for versioned clients

@deads2k
Copy link
Contributor Author

deads2k commented Aug 5, 2016

@k8s-bot test this: issue #26760

@deads2k
Copy link
Contributor Author

deads2k commented Aug 5, 2016

@k8s-bot test this: issue #IGNORE

"Unable to load build details from gs://kubernetes-jenkins/pr-logs/pull/20573/node-pull-build-e2e-test/17411"

@erictune
Copy link
Member

erictune commented Aug 5, 2016

What did he say that persuaded you that something which is not persisted
has a name?

On Fri, Aug 5, 2016 at 9:24 AM, Kubernetes Bot notifications@github.com
wrote:

GCE e2e build/test passed for commit d9a2034
d9a2034
.


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#20573 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHuudu2duOmKiMEw7IeelxlSVn0GuI4uks5qc2O_gaJpZM4HSwZB
.

@deads2k
Copy link
Contributor Author

deads2k commented Aug 5, 2016

What did he say that persuaded you that something which is not persisted
has a name?

We have generic cachers that key based on name and resourceVersion. An access review check has a logical resource version that corresponds to the current state used to make the authorization decision. Some authorizers (rbac for instance), can tie that to an etcd resource version.

If we were to careful control the shape of the name (we do this for some resources in validation based on field value), we'd be able to create a combination of name and resourceVersion that could effectively cache a policy decision.

Not saying I'd go forth an do it now, but it doesn't seem like an entirely unreasonable step.

@deads2k
Copy link
Contributor Author

deads2k commented Aug 5, 2016

@k8s-bot test this: issue #IGNORE

@deads2k
Copy link
Contributor Author

deads2k commented Aug 5, 2016

man, node e2e is angry "Unable to load build details from" again: https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/20573/node-pull-build-e2e-test/17412/

@erictune
Copy link
Member

erictune commented Aug 5, 2016

Caching is great. But that is stretching my concept of resourceVersion.

On Fri, Aug 5, 2016 at 10:06 AM, David Eads notifications@github.com
wrote:

@k8s-bot https://github.com/k8s-bot test this: issue #IGNORE


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#20573 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHuudpTj2G3nE5Reoj4GmriOL0zHDP-Aks5qc22wgaJpZM4HSwZB
.

@deads2k
Copy link
Contributor Author

deads2k commented Aug 5, 2016

Caching is great. But that is stretching my concept of resourceVersion.

If object1 is a virtual view into object2, object1 can be modeled as having a resourceVersion== object2.resourceVersion. An accessreview check follows the same model, but viewing the entire list of resources as its resourceVersion, like ListMeta.

@erictune Given the tight validation (must be empty) on objectmeta, you're still comfortable with this, right?

@erictune
Copy link
Member

erictune commented Aug 5, 2016

fine.

On Fri, Aug 5, 2016 at 10:49 AM, David Eads notifications@github.com
wrote:

Caching is great. But that is stretching my concept of resourceVersion.

If object1 is a virtual view into object2, object1 can be modeled as
having a resourceVersion== object2.resourceVersion. An accessreview check
follows the same model, but viewing the entire list of resources as its
resourceVersion, like ListMeta.

@erictune https://github.com/erictune Given the tight validation (must
be empty) on objectmeta, you're still comfortable with this, right?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#20573 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHuudodhv0RPum2KFkTe3PSHJMK1fnQKks5qc3eagaJpZM4HSwZB
.

@deads2k deads2k added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 5, 2016
@smarterclayton
Copy link
Contributor

smarterclayton commented Aug 5, 2016 via email

@deads2k
Copy link
Contributor Author

deads2k commented Aug 5, 2016

@k8s-bot test this: issue #30132

@k8s-bot
Copy link

k8s-bot commented Aug 5, 2016

GCE e2e build/test passed for commit d9a2034.

@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 Aug 5, 2016

GCE e2e build/test passed for commit d9a2034.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 5f9447a into kubernetes:master Aug 5, 2016
dims pushed a commit to dims/go2idl that referenced this pull request Aug 29, 2016
Automatic merge from submit-queue

Client-gen: Add fake clients to testoutput; fix the imports in fake clients

Start generating fake client in the testoutput, so that we can check the fake client is generated correctly under extreme conditions.

Fix the problem reported kubernetes/kubernetes#20573 (comment), where the import names contain dots when the group name contains dots.

cc @deads2k
dims pushed a commit to dims/go2idl that referenced this pull request Aug 29, 2016
Automatic merge from submit-queue

Remove dot in generated deepcopy package name

ref kubernetes/kubernetes#20573 (comment)

cc @wojtek-t 

I tested with #20573 to verify hack/codegen.sh worked and the generated code compiled.
@deads2k deads2k deleted the plumb-in-SAR branch September 6, 2016 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.