summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-08-20 12:45:42 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-08-22 09:20:50 -0700
commitfb4f17f271fd68edb05617ba9725dee6cdb58027 (patch)
treee147fb2522ac13164deb20dd77574ce79e501498
parent1d24016c8033d4839b3ff07a324672f434868538 (diff)
downloadchef-zero-fb4f17f271fd68edb05617ba9725dee6cdb58027.tar.gz
Report authz id and whether principal is a member of the org
-rw-r--r--lib/chef_zero/endpoints/principal_endpoint.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/chef_zero/endpoints/principal_endpoint.rb b/lib/chef_zero/endpoints/principal_endpoint.rb
index 2398334..896fc8c 100644
--- a/lib/chef_zero/endpoints/principal_endpoint.rb
+++ b/lib/chef_zero/endpoints/principal_endpoint.rb
@@ -11,15 +11,25 @@ module ChefZero
json = get_data(request, request.rest_path[0..1] + [ 'users', name ], :nil)
if json
type = 'user'
+ org_member = true
else
json = get_data(request, request.rest_path[0..1] + [ 'clients', name ], :nil)
- type = 'client'
+ if json
+ type = 'client'
+ org_member = true
+ else
+ json = get_data(request, [ 'users', name ], :nil)
+ type = 'user'
+ org_member = false
+ end
end
if json
json_response(200, {
'name' => name,
'type' => type,
- 'public_key' => JSON.parse(json)['public_key'] || PUBLIC_KEY
+ 'public_key' => JSON.parse(json)['public_key'] || PUBLIC_KEY,
+ 'authz_id' => '0'*32,
+ 'org_member' => org_member
})
else
error(404, 'Principal not found')