summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2016-04-14 15:57:01 -0700
committerJohn Keiser <john@johnkeiser.com>2016-04-14 15:57:01 -0700
commitf2f208e7ecdabf38de1c2296d22ff1bfeaa9887c (patch)
tree36e11c57dccfa66c52e6da6e9bd40b6775519ddc
parent37e5d5a868181bc21e7234f704a1a89131036850 (diff)
parenta8ac977e45320ef8e24d680d454886d8e8d26f97 (diff)
downloadchef-zero-f2f208e7ecdabf38de1c2296d22ff1bfeaa9887c.tar.gz
Merge pull request #213 from chef/jk/userkeys
Fix users endpoint in OSC compat mode to use a data store URL
-rw-r--r--lib/chef_zero/endpoints/actor_endpoint.rb23
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