Skip to content

add what-can-i-do endpoint #8675

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

Merged
merged 1 commit into from
May 3, 2016
Merged

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Apr 28, 2016

Let's argue about names. This as a REST endpoint and a command (oc policy can-i --list) that gives back a list of all the policy rules that a given user has in namespace. I need a good name for the resource and kind.

I want one endpoint for determining it about yourself (with scopes properly applied) and one for determining it about someone else. Having two endpoints makes it easier to write policy rules without introspection.

Things that are missing:

  • the "someone else" endpoint - willl make issue.
  • normalization of the rules to neatly bundle by resource tuples, collapsing for identical verbs and names - turns out our rules don't look too bad as-is.
  • tests
  • respect for scopes (scopes haven't merged yet) - can't reasonably do without scopes having merged

@jwforres @spadgett you both asked for this. I don't intend to associate the list in any particular way.
@openshift/api-review PertinentPermissions and PersonalPertinentPermissions?

@smarterclayton
Copy link
Contributor

The call returns policy rules. So PolicyRulesReview or SubjectRulesReview
is at least consistent with our existing resources.

On Thu, Apr 28, 2016 at 4:40 PM, David Eads [email protected]
wrote:

Let's argue about names. This as a REST endpoint and a command (oc policy
what-can-i-do) that gives back a list of all the policy rules that a
given user has in namespace. I need a good name for the resource and kind.

I want one endpoint for determining it about yourself (with scopes
properly applied) and one for determining it about someone else. Having two
endpoints makes it easier to write policy rules without introspection.

Things that are missing:

  • the "someone else" endpoint
  • normalization of the rules to neatly bundle by resource tuples,
    collapsing for identical verbs and names
  • tests
  • respect for scopes (scopes haven't merged yet)

@jwforres https://github.com/jwforres @spadgett
https://github.com/spadgett you both asked for this. I don't intend to
associate the list in any particular way.
@openshift/api-review https://github.com/orgs/openshift/teams/api-review

PertinentPermissions and PersonalPertinentPermissions?

You can view, comment on, or merge this pull request online at:

#8675
Commit Summary

  • add what-can-i-do endpoint

File Changes

Patch Links:


You are receiving this because you are on a team that was mentioned.
Reply to this email directly or view it on GitHub
#8675

@deads2k
Copy link
Contributor Author

deads2k commented Apr 28, 2016

The call returns policy rules. So PolicyRulesReview or SubjectRulesReview
is at least consistent with our existing resources.

SubjectRulesReview and SelfSubjectRulesReview? That would match SubjectAccessReview and SelfSubjectAccessReview upstream.

@smarterclayton
Copy link
Contributor

Yeah those make sense.

On Thu, Apr 28, 2016 at 5:13 PM, David Eads [email protected]
wrote:

The call returns policy rules. So PolicyRulesReview or SubjectRulesReview
is at least consistent with our existing resources.

SubjectRulesReview and SelfSubjectRulesReview? That would match
SubjectAccessReview and SelfSubjectAccessReview upstream.


You are receiving this because you are on a team that was mentioned.
Reply to this email directly or view it on GitHub
#8675 (comment)

@deads2k deads2k force-pushed the what-can-i-do branch 3 times, most recently from 58e13c2 to 3a03dfd Compare April 29, 2016 17:36
@deads2k
Copy link
Contributor Author

deads2k commented Apr 29, 2016

@smarterclayton updated to SelfSubjectRulesReview.

@pweil- got a reviewer in mind?

@deads2k
Copy link
Contributor Author

deads2k commented Apr 29, 2016

@sgallagher you're interested in RESTStorage, clients, and cli commands, right? :)

@deads2k deads2k changed the title [WIP] add what-can-i-do endpoint add what-can-i-do endpoint Apr 29, 2016
@deads2k
Copy link
Contributor Author

deads2k commented Apr 29, 2016

[test]

@pweil-
Copy link

pweil- commented Apr 29, 2016

got a reviewer in mind

@sgallagher loves this kind of stuff 😄

@sdminonne if you have some time since this is probably similar to the SCC checks you're looking at.

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 257ecaa

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/3521/)

@deads2k
Copy link
Contributor Author

deads2k commented May 2, 2016

Request:

{"kind":"SelfSubjectRulesReview","apiVersion":"v1","status":{"rules":null}}

Response

{
    "kind": "SelfSubjectRulesReview",
    "apiVersion": "v1",
    "status": {
        "rules": [{
            "verbs": ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"],
            "attributeRestrictions": null,
            "apiGroups": [""],
            "resources": ["configmaps", "endpoints", "persistentvolumeclaims", "pods", "pods/attach", "pods/exec", "pods/log", "pods/portforward", "pods/proxy", "replicationcontrollers", "replicationcontrollers/scale", "secrets", "serviceaccounts", "services", "services/proxy"]
        }, {
            "verbs": ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"],
            "attributeRestrictions": null,
            "apiGroups": [""],
            "resources": ["buildconfigs", "buildconfigs/instantiate", "buildconfigs/instantiatebinary", "buildconfigs/webhooks", "buildlogs", "builds", "builds/clone", "builds/log", "deploymentconfigrollbacks", "deploymentconfigs", "deploymentconfigs/log", "deploymentconfigs/scale", "deployments", "generatedeploymentconfigs", "imagestreamimages", "imagestreamimports", "imagestreammappings", "imagestreams", "imagestreams/secrets", "imagestreamtags", "localresourceaccessreviews", "localsubjectaccessreviews", "processedtemplates", "projects", "resourceaccessreviews", "rolebindings", "roles", "routes", "subjectaccessreviews", "templateconfigs", "templates"]
        }, {
            "verbs": ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"],
            "attributeRestrictions": null,
            "apiGroups": ["autoscaling"],
            "resources": ["horizontalpodautoscalers"]
        }, {
            "verbs": ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"],
            "attributeRestrictions": null,
            "apiGroups": ["batch"],
            "resources": ["jobs"]
        }, {
            "verbs": ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"],
            "attributeRestrictions": null,
            "apiGroups": ["extensions"],
            "resources": ["horizontalpodautoscalers", "jobs", "replicationcontrollers/scale"]
        }, {
            "verbs": ["get", "list", "watch"],
            "attributeRestrictions": null,
            "apiGroups": ["extensions"],
            "resources": ["daemonsets"]
        }, {
            "verbs": ["get", "list", "watch"],
            "attributeRestrictions": null,
            "apiGroups": null,
            "resources": ["bindings", "configmaps", "endpoints", "events", "imagestreams/status", "limitranges", "minions", "namespaces", "namespaces/status", "nodes", "persistentvolumeclaims", "persistentvolumes", "pods", "pods/log", "pods/status", "policies", "policybindings", "replicationcontrollers", "replicationcontrollers/status", "resourcequotas", "resourcequotas/status", "resourcequotausages", "routes/status", "securitycontextconstraints", "serviceaccounts", "services"]
        }, {
            "verbs": ["get", "update"],
            "attributeRestrictions": null,
            "apiGroups": null,
            "resources": ["imagestreams/layers"]
        }, {
            "verbs": ["update"],
            "attributeRestrictions": null,
            "apiGroups": null,
            "resources": ["routes/status"]
        }]
    }
}

@jwforres
Copy link
Member

jwforres commented May 2, 2016

sample response LGTM, this is what the UI needs

On Mon, May 2, 2016 at 9:45 AM, David Eads [email protected] wrote:

Request:

{"kind":"SelfSubjectRulesReview","apiVersion":"v1","status":{"rules":null}}

Response

{
"kind": "SelfSubjectRulesReview",
"apiVersion": "v1",
"status": {
"rules": [{
"verbs": ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"],
"attributeRestrictions": null,
"apiGroups": [""],
"resources": ["configmaps", "endpoints", "persistentvolumeclaims", "pods", "pods/attach", "pods/exec", "pods/log", "pods/portforward", "pods/proxy", "replicationcontrollers", "replicationcontrollers/scale", "secrets", "serviceaccounts", "services", "services/proxy"]
}, {
"verbs": ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"],
"attributeRestrictions": null,
"apiGroups": [""],
"resources": ["buildconfigs", "buildconfigs/instantiate", "buildconfigs/instantiatebinary", "buildconfigs/webhooks", "buildlogs", "builds", "builds/clone", "builds/log", "deploymentconfigrollb!
acks", "deploymentconfigs", "deploymentconfigs/log", "deploymentconfigs/scale", "deployments", "generatedeploymentconfigs", "imagestreamimages", "imagestreamimports", "imagestreammappings", "imagestreams", "imagestreams/secrets", "imagestreamtags", "localresourceaccessreviews", "localsubjectaccessreviews", "processedtemplates", "projects", "resourceaccessreviews", "rolebindings", "roles", "routes",!
"subjectaccessreviews", "templateconfigs", "templates"]
}, {
"verbs": ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"],
"attributeRestrictions": null,
"apiGroups": ["autoscaling"],
"resources": ["horizontalpodautoscalers"]
}, {
"verbs": ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"],
"attributeRestrictions": null,
"apiGroups": ["batch"],
"resources": ["jobs"]
}, {
"verbs": ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"],
"attributeRestrictions": null,
"apiGroups": ["extensions"],
"resources": ["horizontalpodautoscalers", "jobs", "replicationcontrollers/scale"]
}, {
"verbs": ["get", "list", "watch"],
"attributeRestrictions": null,
"apiGroups": ["extensions"],
"resources": ["daemonsets"]
}, {
"verbs": ["get", "list", "watch"],
"attributeRestrictions": null,
"apiGroups": null,
"resources": ["bindings", "configmaps", "endpoints", "events", "imagestreams/status", "limitranges", "minions", "namespaces", "namespaces/status",
"nodes", "persistentvolumeclaims", "persistentvolumes", "pods", "pods/log", "pods/status", "policies", "policybindings", "replicationcontrollers", "replicationcontrollers/status", "resourcequotas", "resourcequotas/status", "resourcequotausages", "routes/status", "securitycontextconstraints", "serviceaccounts", "services"]
}, {
"verbs": ["get", "update"],
"attributeRestrictions": null,
"apiGroups": null,
"resources": ["imagestreams/layers"]
}, {
"verbs": ["update"],
"attributeRestrictions": null,
"apiGroups": null,
"resources": ["routes/status"]
}]
}
}


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#8675 (comment)

@smarterclayton
Copy link
Contributor

Not sure whether I like "what-can-I-do" as a command name but it's fine for
now.

On Mon, May 2, 2016 at 10:07 AM, Jessica Forrester <[email protected]

wrote:

sample response LGTM, this is what the UI needs

On Mon, May 2, 2016 at 9:45 AM, David Eads [email protected]
wrote:

Request:

{"kind":"SelfSubjectRulesReview","apiVersion":"v1","status":{"rules":null}}

Response

{
"kind": "SelfSubjectRulesReview",
"apiVersion": "v1",
"status": {
"rules": [{
"verbs": ["create", "delete", "deletecollection", "get", "list",
"patch", "update", "watch"],
"attributeRestrictions": null,
"apiGroups": [""],
"resources": ["configmaps", "endpoints", "persistentvolumeclaims",
"pods", "pods/attach", "pods/exec", "pods/log", "pods/portforward",
"pods/proxy", "replicationcontrollers", "replicationcontrollers/scale",
"secrets", "serviceaccounts", "services", "services/proxy"]
}, {
"verbs": ["create", "delete", "deletecollection", "get", "list",
"patch", "update", "watch"],
"attributeRestrictions": null,
"apiGroups": [""],
"resources": ["buildconfigs", "buildconfigs/instantiate",
"buildconfigs/instantiatebinary", "buildconfigs/webhooks", "buildlogs",
"builds", "builds/clone", "builds/log", "deploymentconfigrollb!
acks", "deploymentconfigs", "deploymentconfigs/log",
"deploymentconfigs/scale", "deployments", "generatedeploymentconfigs",
"imagestreamimages", "imagestreamimports", "imagestreammappings",
"imagestreams", "imagestreams/secrets", "imagestreamtags",
"localresourceaccessreviews", "localsubjectaccessreviews",
"processedtemplates", "projects", "resourceaccessreviews", "rolebindings",
"roles", "routes",!
"subjectaccessreviews", "templateconfigs", "templates"]
}, {
"verbs": ["create", "delete", "deletecollection", "get", "list",
"patch", "update", "watch"],
"attributeRestrictions": null,
"apiGroups": ["autoscaling"],
"resources": ["horizontalpodautoscalers"]
}, {
"verbs": ["create", "delete", "deletecollection", "get", "list",
"patch", "update", "watch"],
"attributeRestrictions": null,
"apiGroups": ["batch"],
"resources": ["jobs"]
}, {
"verbs": ["create", "delete", "deletecollection", "get", "list",
"patch", "update", "watch"],
"attributeRestrictions": null,
"apiGroups": ["extensions"],
"resources": ["horizontalpodautoscalers", "jobs",
"replicationcontrollers/scale"]
}, {
"verbs": ["get", "list", "watch"],
"attributeRestrictions": null,
"apiGroups": ["extensions"],
"resources": ["daemonsets"]
}, {
"verbs": ["get", "list", "watch"],
"attributeRestrictions": null,
"apiGroups": null,
"resources": ["bindings", "configmaps", "endpoints", "events",
"imagestreams/status", "limitranges", "minions", "namespaces",
"namespaces/status",
"nodes", "persistentvolumeclaims", "persistentvolumes", "pods",
"pods/log", "pods/status", "policies", "policybindings",
"replicationcontrollers", "replicationcontrollers/status",
"resourcequotas", "resourcequotas/status", "resourcequotausages",
"routes/status", "securitycontextconstraints", "serviceaccounts",
"services"]
}, {
"verbs": ["get", "update"],
"attributeRestrictions": null,
"apiGroups": null,
"resources": ["imagestreams/layers"]
}, {
"verbs": ["update"],
"attributeRestrictions": null,
"apiGroups": null,
"resources": ["routes/status"]
}]
}
}


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#8675 (comment)


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#8675 (comment)

@deads2k
Copy link
Contributor Author

deads2k commented May 2, 2016

Not sure whether I like "what-can-I-do" as a command name but it's fine for
now.

And the API object names?

@sgallagher
Copy link
Contributor

"list-authorized-actions"?

@smarterclayton
Copy link
Contributor

API was approved

On May 2, 2016, at 1:05 PM, David Eads [email protected] wrote:

Not sure whether I like "what-can-I-do" as a command name but it's fine for
now.

And the API object names?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#8675 (comment)

@deads2k
Copy link
Contributor Author

deads2k commented May 3, 2016

"list-authorized-actions"?

We get until the next tag to pin the command down. I was leaning towards oc policy can-i <verb> <resource> and oc policy can-i --list.

@sgallagher any other comments?

@sgallagher
Copy link
Contributor

LGTM

I built it and played around with setting some policy roles on a user and can verify that they appear to work properly.

@deads2k
Copy link
Contributor Author

deads2k commented May 3, 2016

[merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented May 3, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/5795/) (Image: devenv-rhel7_4088)

@deads2k
Copy link
Contributor Author

deads2k commented May 3, 2016

@jwforres I don't think I touched bindata, but I'm getting this:

--- _output/test/assets/bindata.go  2016-05-03 15:51:07.213436061 -0400
+++ pkg/assets/bindata.go   2016-05-03 15:00:33.666020369 -0400
@@ -48373,12 +48373,9 @@
 }
 function p() {
 try {
-var a = Intl.DateTimeFormat().resolvedOptions().timeZone;
-if (a) {
-var b = H[r(a)];
+var a = Intl.DateTimeFormat().resolvedOptions().timeZone, b = H[r(a)];
make[1]: *** [test-assets] Error 141

@liggitt
Copy link
Contributor

liggitt commented May 3, 2016

known issue, fixed in #8725

@deads2k
Copy link
Contributor Author

deads2k commented May 3, 2016

re[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 257ecaa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants