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

Added /orgs/org/users/user/keys(/key) endpoints and changed default perms on org scoped key GETs. #769

Merged
merged 4 commits into from
Mar 17, 2016

Conversation

tylercloke
Copy link
Contributor

Merge chef/chef-zero#205 and re-run Travis once two 👍 acquired.

Now, all org-scoped key GETs will allow access to any requestor within the same org (and the superuser).
The endpoints affected are

+ /orgs/org/clients/client/keys
+ /orgs/org/clients/client/keys/key
+ /orgs/org/users/user/keys
+ /orgs/org/users/user/keys/key

of which the latter two are new endpoints.

The new permissions where implemented by overriding default permissions for those GETs and checking if the requestor of actor_keys_access_group instead (which is a global group that exists per org that contains the users and clients groups, similar to the existing read_access_group).

The existing user key endpoints

+ /users/user/keys
+ /users/user/keys/key

were not modified and contain the same permissions as beforehand.

A large part of the diff is just tests being reorganized.

Passing Build

@tylercloke tylercloke force-pushed the SPOOL-71/read-on-org-scoped-keys branch from 3d741dc to fad01e9 Compare March 8, 2016 02:55
@tylercloke tylercloke changed the title WIP: Read on keys Added /orgs/org/users/user/keys(/key) endpoints and changed default perms on org scoped key GETs. Mar 8, 2016
@tylercloke tylercloke force-pushed the SPOOL-71/read-on-org-scoped-keys branch from fad01e9 to b50073e Compare March 8, 2016 03:03
{object_name, ParentName} = lists:keyfind(object_name, 1, Args),
{name, Name} = lists:keyfind(name, 1, Args),
{BaseURI, Org} = extract_from_req(Req),
Template = template_for_type(client_key),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be template_for_type(org_user_key)?

@tylercloke tylercloke force-pushed the SPOOL-71/read-on-org-scoped-keys branch from d7bfb0f to 93cde1b Compare March 8, 2016 22:42
@stevendanna
Copy link
Contributor

I'm 👍 on the existing changes; however, per our chat discussion this needs a mover migration for existing orgs/users.

status: 200,
body_exact: [
list_client_keys(org_name, org_client_name, current_requestor).should look_like({
:status => 200,
Copy link
Member

Choose a reason for hiding this comment

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

Why : to =>?


-record(org, {name, id, authz_id}).
-record(group, {name, id, authz_id}).
-define(GLOBAL_PLACEHOLDER_ORG_ID, <<"00000000000000000000000000000000">>).
Copy link
Member

Choose a reason for hiding this comment

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

I am pretty sure we have this available in an hrl we can pull in from somewhere?

@marcparadise
Copy link
Member

On the whole 👍 with minor comments.

The only outstanding question (currently under discussion) is whether this would be better as an org-owned group instead of a global group, since the constraints that led us to creating global_read (global_admins) don't necessarily apply here. I don't think it would be a major change to the PR to switch it over, but we're in process of talking this through.

@marcparadise
Copy link
Member

After further discussion, we’ve decided to make the group a normal org group, with permissions to prevent deletion. This allows membership to be edited as needed in situations where the customer has concerns about exposing public key and expiration data to clients.

When passing a custom org, it was posting to the default org.
Added tests around desired behavior related to allowing clients and users to access the public keys of other clients and users within the same org.
@tylercloke tylercloke force-pushed the SPOOL-71/read-on-org-scoped-keys branch from 896b814 to 78f29b1 Compare March 16, 2016 21:35
@tylercloke tylercloke force-pushed the SPOOL-71/read-on-org-scoped-keys branch from 78f29b1 to e32cda0 Compare March 16, 2016 22:18
…erms on org scoped key GETs.

Now, all org scoped key GETs will allow access to any requestor within the same org (and the superuser).
The endpoints affected are
+ /orgs/org/clients/client/keys
+ /orgs/org/clients/client/keys/key
+ /orgs/org/users/user/keys
+ /orgs/org/users/user/keys/key
of which the latter two are new endpoints.

The new permissions where implemented by overriding default permissions for those GETs and checking if
the requestor is a memeber of the public_key_read_access group instead. This is a new group that, by default,
contains the users and clients group. Org admins can edit who is in this group, which changes who is allowed
to view the org scoped user public keys.

The existing user key endpoints
+ /users/user/keys
+ /users/user/keys/key
were not modified and contain the same permissions as beforehand.

Changelog-Entry: Added /orgs/org/users/user/keys(/key) endpoint and changed default perms on org scoped key GETs.

The following endpoints' GET methods can now be accessed by any requestor that is a member of the same organization:
+ /organizations/:org/clients/:client/keys
+ /organizations/:org/clients/:client/keys/:key
+ /organizations/:org/users/:user/keys
+ /organizations/:org/users/:user/keys/:key

The above org-scoped user keys endpoints are new and access to them can be controlled by an admin by editing memebership
of the public_key_read_access group.
@tylercloke tylercloke force-pushed the SPOOL-71/read-on-org-scoped-keys branch from e32cda0 to 5ab02f8 Compare March 16, 2016 22:27
@@ -87,6 +88,7 @@
{add_acl,
[mk_tl(container, ?CONTAINERS), mk_tl(group, [admins, clients, users]), {organization}],
?ALL_PERMS, [{group, admins}]},
{add_acl, [{group, public_key_read_access}], [read, update], [{group, admins}]},
Copy link
Contributor

Choose a reason for hiding this comment

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

These changes look good to me. I prefer read, update over adding read, grant. There probably would be no harm in adding others to the read list, but I'm fine with where it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sweet, I think read, update is the right thing too.

@markan
Copy link
Contributor

markan commented Mar 17, 2016

👍 with changes to make it org owned.

tylercloke added a commit that referenced this pull request Mar 17, 2016
Added /orgs/org/users/user/keys(/key) endpoints and changed default perms on org scoped key GETs.
@tylercloke tylercloke merged commit 5364e0f into master Mar 17, 2016
@tylercloke tylercloke deleted the SPOOL-71/read-on-org-scoped-keys branch March 17, 2016 00:32
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.

None yet

7 participants