lib/uaa/scim.rb in cf-uaa-lib-3.0.0 vs lib/uaa/scim.rb in cf-uaa-lib-3.1.0
- old
+ new
@@ -1,8 +1,8 @@
#--
-# Cloud Foundry 2012.02.03 Beta
-# Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
+# Cloud Foundry
+# Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a number of subcomponents with
@@ -68,11 +68,11 @@
end
# an attempt to hide some scim and uaa oddities
def type_info(type, elem)
scimfo = {:user => ["/Users", "userName"], :group => ["/Groups", "displayName"],
- :client => ["/oauth/clients", 'client_id'], :user_id => ["/ids/Users", 'userName']}
+ :client => ["/oauth/clients", 'client_id'], :user_id => ["/ids/Users", 'userName'], :group_mapping => ["/Groups/External", "externalGroup"]}
unless elem == :path || elem == :name_attr
raise ArgumentError, "scim schema element must be :path or :name_attr"
end
unless ary = scimfo[type]
raise ArgumentError, "scim resource type must be one of #{scimfo.keys.inspect}"
@@ -305,9 +305,26 @@
json_parse_reply(@key_style, *json_put(@target,
"#{type_info(:client, :path)}/#{URI.encode(client_id)}/secret", req,
'authorization' => @auth_header))
end
+ def map_group(group, is_id, external_group)
+ key_name = is_id ? :groupId : :displayName
+ request = {key_name => group, :externalGroup => external_group, :schemas => ["urn:scim:schemas:core:1.0"] }
+ result = json_parse_reply(@key_style, *json_post(@target,
+ "#{type_info(:group_mapping, :path)}", request,
+ 'authorization' => @auth_header))
+ result
+ end
+
+ def unmap_group(group_id, external_group)
+ http_delete(@target, "#{type_info(:group_mapping, :path)}/id/#{group_id}/#{external_group}",
+ @auth_header)
+ end
+
+ def list_group_mappings(start = nil, count = nil)
+ json_get(@target, "#{type_info(:group_mapping, :path)}/list?startIndex=#{start}&count=#{count}", @key_style, 'authorization' => @auth_header)
+ end
end
end