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 annotations to roles #11328

Merged
merged 1 commit into from
Jan 19, 2017

Conversation

enj
Copy link
Contributor

@enj enj commented Oct 11, 2016

Fixes #11268

Added just the basic bits; now someone tell me what they want to call the annotation... (along with display names and descriptions)

Signed-off-by: Monis Khan [email protected]

cc @benjaminapetersen @jwforres @openshift/api-review

@@ -221,6 +237,10 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: AdminRoleName,
Annotations: map[string]string{
RoleDescription: "A project manager. If used in a local binding, an admin user will have rights to view any resource in the project and modify any resource in the project except for role creation and quota. If the cluster-admin wants to allow an admin to modify roles, the cluster-admin must create a project-scoped Policy object using JSON.",
RoleSomething: RoleSomethingVal,
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems backwards. Since most people will be adding roles that they want users to use, why wouldn't we have an explicit opt-in for exclusion.

RoleDisplayName = "openshift.io/display-name"

// RoleDescription is an annotation that holds the description of the role
RoleDescription = "openshift.io/description"
Copy link
Contributor

Choose a reason for hiding this comment

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

promote the description and display name to a shared package. These cross all api groups.

@@ -494,6 +540,10 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: DeployerRoleName,
Annotations: map[string]string{
RoleDisplayName: "deployer",
RoleSomething: RoleSomethingVal,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you expose this?

@@ -458,6 +500,10 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: ImageBuilderRoleName,
Annotations: map[string]string{
RoleDisplayName: "image-builder",
RoleSomething: RoleSomethingVal,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you expose this?

@enj
Copy link
Contributor Author

enj commented Oct 11, 2016

@deads2k I exposed those SA-ish roles because there was some talk about making SAs (which may then need these roles to do something). Based on info from @benjaminapetersen and some pruning I have narrowed the data to 8 roles:

$ oc get clusterrole -o jsonpath="{range .items[*]}{.metadata.name}{\" => \"}{.metadata.annotations}{\"\\n\"}{end}" | grep -v 'system-only:true'

system:image-puller => map[openshift.io/display-name:image-puller]
edit => map[openshift.io/description:A user that can modify most objects in a project, but does not have the power to view or modify roles or bindings.]
system:image-builder => map[openshift.io/display-name:image-builder]
basic-user => map[openshift.io/description:A user that can get basic information about projects and users.]
system:image-pusher => map[openshift.io/display-name:image-pusher]
view => map[openshift.io/description:A user who cannot make any modifications, but can see most objects in a project. They cannot view or modify roles or bindings.]
system:deployer => map[openshift.io/display-name:deployer]
admin => map[openshift.io/description:A project manager. If used in a local binding, an admin user will have rights to view any resource in the project and modify any resource in the project except for role creation and quota. If the cluster-admin wants to allow an admin to modify roles, the cluster-admin must create a project-scoped Policy object using JSON.]

display-name usage on 4 SA-ish roles:

$ oc get clusterrole -o jsonpath="{range .items[*]}{.metadata.name}{\" => \"}{.metadata.annotations}{\"\\n\"}{end}" | grep 'display-name'

system:deployer => map[openshift.io/display-name:deployer]
system:image-pusher => map[openshift.io/display-name:image-pusher]
system:image-puller => map[openshift.io/display-name:image-puller]
system:image-builder => map[openshift.io/display-name:image-builder]

The 7 roles with description:

$ oc get clusterrole -o jsonpath="{range .items[*]}{.metadata.name}{\" => \"}{.metadata.annotations}{\"\\n\"}{end}" | grep 'description'

view => map[openshift.io/description:A user who cannot make any modifications, but can see most objects in a project. They cannot view or modify roles or bindings.]
cluster-status => map[authorization.openshift.io/system-only:true openshift.io/description:A user that can get basic cluster status information.]
edit => map[openshift.io/description:A user that can modify most objects in a project, but does not have the power to view or modify roles or bindings.]
cluster-admin => map[authorization.openshift.io/system-only:true openshift.io/description:A super-user that can perform any action in any project. When granted to a user within a local policy, they have full control over quota and roles and every action on every resource in the project.]
basic-user => map[openshift.io/description:A user that can get basic information about projects and users.]
admin => map[openshift.io/description:A project manager. If used in a local binding, an admin user will have rights to view any resource in the project and modify any resource in the project except for role creation and quota. If the cluster-admin wants to allow an admin to modify roles, the cluster-admin must create a project-scoped Policy object using JSON.]
self-provisioner => map[authorization.openshift.io/system-only:true openshift.io/description:A user that can create their own projects.]

@enj
Copy link
Contributor Author

enj commented Oct 11, 2016

[test]

@smarterclayton
Copy link
Contributor

We already have annotations for these and they are in the k8s.io namespace.

On Oct 11, 2016, at 3:28 PM, David Eads [email protected] wrote:

@deads2k commented on this pull request.

In pkg/cmd/server/bootstrappolicy/policy.go
#11328 (review):

@@ -28,6 +28,19 @@ import (
userapi "github.com/openshift/origin/pkg/user/api"
)

+const (

  • // RoleSomething is an annotation that ???
  • RoleSomething = "authorization.openshift.io/user-friendly"
  • // Do something ???
  • RoleSomethingVal = "true"
  • // RoleDisplayName is an annotation that stores the name displayed
    when querying for roles
  • RoleDisplayName = "openshift.io/display-name"
  • // RoleDescription is an annotation that holds the description of the role
  • RoleDescription = "openshift.io/description"

promote the description and display name to a shared package. These cross
all api groups.


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub
#11328 (review),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_pzHU9EOd5UobN-wk_3MbUg8f56zkks5qy-NegaJpZM4KUAkv
.

@enj
Copy link
Contributor Author

enj commented Oct 12, 2016

We want to use k8s.io/display-name and k8s.io/description instead of the openshift equivalents (which we already use in various places)? What about authorization.openshift.io/system-only?

@deads2k
Copy link
Contributor

deads2k commented Oct 12, 2016

We want to use k8s.io/display-name and k8s.io/description instead of the openshift equivalents (which we already use in various places)? What about authorization.openshift.io/system-only?

I haven't actually seen these annotations upstream and my grep-fu can't find them. @smarterclayton can I get a pointer to them?

@liggitt
Copy link
Contributor

liggitt commented Oct 19, 2016

why do we we want display names on roles? I don't think it's worth the confusion (and possible accidental granting of unintentional powers when a UI is involved) around whether you are dealing with a display name or the actual role name

@benjaminapetersen
Copy link
Contributor

I was messing around with supporting these edge cases via:

ClusterRole: view
Role: view // copied view, but slightly different

Both can exist, but it is confusing. Hopefully the descriptions are clear, but if no descriptions we have a problem. My personal preference would be that roles cannot have the same name as another role, whatever the scope, and don't both with display names. Is there a good reason to allow?

@liggitt
Copy link
Contributor

liggitt commented Oct 19, 2016

it's impossible to enforce unique names in different scopes

@liggitt
Copy link
Contributor

liggitt commented Oct 19, 2016

I would probably represent local roles as <projectname>/<rolename>. Roles cannot contain / characters, and <projectname>/<rolename> is how the CLI describer prints rolerefs in rolebindings

@benjaminapetersen
Copy link
Contributor

Ok great, I'll run with that.

@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 30, 2016
@benjaminapetersen
Copy link
Contributor

@openshift/api-review @enj

So it's been requested we aim for getting these in for 3.5. It looks like we have a few outstanding questions that need answering at this point:

  • We need to confirm the name for this annotation. Is authorization.openshift.io/system-only : true sufficient? @smarterclayton mentioned something may exist in k8s.io, and it isn't exactly clear (may not truly be system-only).
  • Confirm the direction of the above annotation. @deads2k suggested adding the annotation to all built-in roles as an exclude, so that any user defined role would be "shown" by default (even if the user does not add the annotation).
  • Which annotation to use for descriptions openshift.io/description vs k8s.io/description. We probably need descriptions all roles a user will see by default (not just the 7-8).
  • We should verify the default visible roles.
  • Get rid of display name.

@benjaminapetersen
Copy link
Contributor

@jwforres fyi above comment

@liggitt
Copy link
Contributor

liggitt commented Jan 10, 2017

@deads2k suggested adding the annotation to all built-in roles as an exclude, so that any user defined role would be "shown" by default (even if the user does not add the annotation).

seems like a good idea. if we add annotations to the default roles (for descriptions or a "hide-by-default" flag), we need to make role reconciliation annotation-aware. currently, it preserves all annotations from an existing role object... merging them will require thought.

Which annotation to use for descriptions openshift.io/description vs k8s.io/description

For openshift objects, I would use the openshift annotation

Get rid of display name.

agree

@benjaminapetersen
Copy link
Contributor

I don't think I have a dog in the fight re: role reconciliation, care to comment @enj @deads2k ?

@deads2k
Copy link
Contributor

deads2k commented Jan 11, 2017

@enj is this waiting on me for something?

@enj enj force-pushed the enj/f/role_annotations/11268 branch from f65c297 to 1cecfd4 Compare January 16, 2017 16:35
@benjaminapetersen
Copy link
Contributor

@enj / any who are interested, how about openshift.io/internal for the show/hide flag? It seems "system-only" is not exactly truthful. "Internal" is a rather ambiguous word, but that might be good here. The point is simply not to show it, not to describe the reason not to show it (which there could be many).

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 16, 2017
@enj enj requested a review from liggitt January 17, 2017 03:18
@enj
Copy link
Contributor Author

enj commented Jan 17, 2017

@liggitt so oadm policy reconcile-cluster-roles does not handle roles in pkg/cmd/server/bootstrappolicy/infra_sa_policy.go. Not sure how to deal with that.

Edit: NVM those get force updated.

@@ -0,0 +1,10 @@
package constants
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure we want a package for constants... annotation keys typically go in the API package directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe I did that to resolve a circular dependency (but that was a while ago).

@@ -131,6 +131,9 @@ func init() {
authorizationapi.ClusterRole{
ObjectMeta: kapi.ObjectMeta{
Name: BuildControllerRoleName,
Copy link
Contributor

Choose a reason for hiding this comment

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

add these annotations in addServiceAccount? aren't all service account roles infra only?

@@ -91,6 +99,10 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: ClusterAdminRoleName,
Annotations: map[string]string{
constants.OpenShiftDescription: "A super-user that can perform any action in any project. When granted to a user within a local policy, they have full control over quota and roles and every action on every resource in the project.",
Copy link
Contributor

@liggitt liggitt Jan 17, 2017

Choose a reason for hiding this comment

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

"...can perform any action in the cluster."?

@@ -231,6 +261,8 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: AdminRoleName,
Annotations: map[string]string{
constants.OpenShiftDescription: "A project manager. If used in a local binding, an admin user will have rights to view any resource in the project and modify any resource in the project except for role creation and quota. If the cluster-admin wants to allow an admin to modify roles, the cluster-admin must create a project-scoped Policy object using JSON."},
Copy link
Contributor

Choose a reason for hiding this comment

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

remove "using JSON"

@@ -344,6 +378,8 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: ViewRoleName,
Annotations: map[string]string{
constants.OpenShiftDescription: "A user who cannot make any modifications, but can see most objects in a project. They cannot view or modify roles or bindings."},
Copy link
Contributor

Choose a reason for hiding this comment

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

call out that they can't see secrets

@@ -393,6 +429,8 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: BasicUserRoleName,
Annotations: map[string]string{
constants.OpenShiftDescription: "A user that can get basic information about projects and users."},
Copy link
Contributor

Choose a reason for hiding this comment

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

this allows listing projects and getting information about yourself, not users in general

@@ -416,6 +457,10 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: SelfProvisionerRoleName,
Annotations: map[string]string{
constants.OpenShiftDescription: "A user that can create their own projects.",
Copy link
Contributor

Choose a reason for hiding this comment

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

they can't create their own, they can request projects

@enj
Copy link
Contributor Author

enj commented Jan 17, 2017

@liggitt FYI I copied the descriptions verbatim from here so those probably need fixing as well.

@enj
Copy link
Contributor Author

enj commented Jan 17, 2017

@liggitt All requested changes have been addressed. @jwforres / @benjaminapetersen Let me know if you guys have any comments on the system-only / description annotations since we do not get to change those later.

Copy link
Member

@jwforres jwforres left a comment

Choose a reason for hiding this comment

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

I'm not seeing the roles like system:deployer system:image-puller, system:image-pusher, and system:image-builder. Is there a reason we don't have descriptions on those?

@@ -231,6 +261,8 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: AdminRoleName,
Annotations: map[string]string{
oapi.OpenShiftDescription: "A project manager. If used in a local binding, an admin user will have rights to view any resource in the project and modify any resource in the project except for role creation and quota. If the cluster-admin wants to allow an admin to modify roles, the cluster-admin must create a project-scoped Policy object."},
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want these getting too technical, these descriptions are for end users deciding why they want to choose one role vs another. What if we simplify this whole thing down to:

"A user that has edit rights within the project and can change the project's membership."

Maybe contentious since membership is a console term?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eh I have heard of membership but I assume it means roles + bindings => policy?

@@ -292,6 +324,8 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: EditRoleName,
Annotations: map[string]string{
oapi.OpenShiftDescription: "A user that can modify most objects in a project, but does not have the power to view or modify roles or bindings."},
Copy link
Member

Choose a reason for hiding this comment

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

A user that can create and edit most objects in a project, but can not update the project's membership.

@@ -344,6 +378,8 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: ViewRoleName,
Annotations: map[string]string{
oapi.OpenShiftDescription: "A user who cannot make any modifications, but can see most objects in a project. They cannot view or modify roles or bindings or secrets."},
Copy link
Member

Choose a reason for hiding this comment

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

A user who can view but not edit any resources within the project. They can not view secrets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't the role part important?

@@ -393,6 +429,8 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: BasicUserRoleName,
Annotations: map[string]string{
oapi.OpenShiftDescription: "A user that can get basic information about projects."},
Copy link
Member

Choose a reason for hiding this comment

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

what does this even mean? they can Get/List the project but not get any objects within the project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So we have to be vague enough that the description doesn't get too far out of sync since the specifics of rules will almost certainly change over time. Right now it means:

  1. Get info about yourself
  2. List projectrequests
  3. Get/List clusterroles
  4. List storageclasses
  5. List/Watch projects

@@ -91,6 +99,10 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
{
ObjectMeta: kapi.ObjectMeta{
Name: ClusterAdminRoleName,
Annotations: map[string]string{
Copy link
Member

Choose a reason for hiding this comment

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

instead of saying "granted to a user within a local policy" can you say "granted to a user on a project"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe "within a project"?

@enj
Copy link
Contributor Author

enj commented Jan 17, 2017

I'm not seeing the roles like system:deployer system:image-puller, system:image-pusher, and system:image-builder. Is there a reason we don't have descriptions on those?

@jwforres I copied the descriptions verbatim from here and those were not listed (nor did I have any idea what to describe them as). Maybe @liggitt can provide some?

@liggitt I need your input on @jwforres' suggestions so I can finalize the descriptions.

Signed-off-by: Monis Khan <[email protected]>
@enj enj force-pushed the enj/f/role_annotations/11268 branch from 6583b22 to d89c5cd Compare January 18, 2017 20:45
@enj enj changed the title WIP: Add annotations to roles Add annotations to roles Jan 18, 2017
@enj
Copy link
Contributor Author

enj commented Jan 18, 2017

@liggitt This is ready for merge.

@liggitt
Copy link
Contributor

liggitt commented Jan 18, 2017

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to d89c5cd

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to d89c5cd

@enj
Copy link
Contributor Author

enj commented Jan 18, 2017

@liggitt sanity check confirmed - reconciliation works as expected.

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/13002/) (Base Commit: cf4e84e)

@enj
Copy link
Contributor Author

enj commented Jan 18, 2017

Flake on #12540 #8571

@openshift-bot
Copy link
Contributor

openshift-bot commented Jan 19, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/13013/) (Base Commit: e4b43ee) (Image: devenv-rhel7_5718)

@openshift-bot openshift-bot merged commit ba792d2 into openshift:master Jan 19, 2017
openshift-merge-robot added a commit to openshift/origin-web-console that referenced this pull request Oct 30, 2017
…le-whitelist

Automatic merge from submit-queue.

Update membership filter to use MEMBERSHIP_WHITELIST in Constants.js

Moving back to using a simple whitelist via [origin issue 16862](openshift/origin#16862)

fixes [origin issue 16862](openshift/origin#16862)

History:
- issue #14411 
- PR #14510, 
- PR #15241
- [PR 11328](openshift/origin#11328) (original)

At this point ignoring the annotation `systemOnly` entirely.

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

Successfully merging this pull request may close these issues.

7 participants