diff options
author | John Keiser <john@johnkeiser.com> | 2016-04-14 15:39:49 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-04-14 15:39:49 -0700 |
commit | a8ac977e45320ef8e24d680d454886d8e8d26f97 (patch) | |
tree | 36e11c57dccfa66c52e6da6e9bd40b6775519ddc /lib/chef_zero | |
parent | 37e5d5a868181bc21e7234f704a1a89131036850 (diff) | |
download | chef-zero-a8ac977e45320ef8e24d680d454886d8e8d26f97.tar.gz |
Fix users endpoint in OSC compat mode to use a data store URL
under /organizations (otherwise ChefFS will not understand it)
Diffstat (limited to 'lib/chef_zero')
-rw-r--r-- | lib/chef_zero/endpoints/actor_endpoint.rb | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/chef_zero/endpoints/actor_endpoint.rb b/lib/chef_zero/endpoints/actor_endpoint.rb index 28d8131..dd2caf2 100644 --- a/lib/chef_zero/endpoints/actor_endpoint.rb +++ b/lib/chef_zero/endpoints/actor_endpoint.rb @@ -161,22 +161,23 @@ module ChefZero # Return the data store keys path for the request client or user, e.g. # - # [ "organizations", <org>, "client_keys", <client>, "keys" ] - # - # Or: - # - # [ "user_keys", <user>, "keys" ] + # /organizations/ORG/clients/CLIENT -> /organizations/ORG/client_keys/CLIENT/keys + # /organizations/ORG/users/USER -> /organizations/ORG/user_keys/USER/keys + # /users/USER -> /user_keys/USER # def keys_path_base(request, client_or_user_name=nil) rest_path = (rest_path || request.rest_path).dup - rest_path[-1] = client_or_user_name if client_or_user_name - - if client?(request, rest_path) - [ *rest_path[0..1], "client_keys" ] + rest_path = rest_path.dup + case rest_path[-2] + when "users" + rest_path[-2] = "user_keys" + when "clients" + rest_path[-2] = "client_keys" else - [ "user_keys" ] + raise "Unexpected URL #{rest_path.join("/")}: cannot determine key path" end - .push(rest_path.last, "keys") + rest_path << "keys" + rest_path end end end |