lib/uaa/scim.rb in cf-uaa-lib-3.14.3 vs lib/uaa/scim.rb in cf-uaa-lib-3.14.4

- old
+ new

@@ -10,11 +10,11 @@ # subcomponents is subject to the terms and conditions of the # subcomponent's license, as noted in the LICENSE file. #++ require 'uaa/http' -require 'uri' +require 'addressable/uri' module CF::UAA # This class is for apps that need to manage User Accounts, Groups, or OAuth # Client Registrations. It provides access to the SCIM endpoints on the UAA. @@ -175,11 +175,11 @@ # Deletes a SCIM resource # @param type (see #add) # @param [String] id the id attribute of the SCIM object # @return [nil] def delete(type, id) - http_delete @target, "#{type_info(type, :path)}/#{URI.encode(id)}", @auth_header, @zone + http_delete @target, "#{type_info(type, :path)}/#{Addressable::URI.encode(id)}", @auth_header, @zone end # Replaces the contents of a SCIM object. # @param (see #add) # @return (see #add) @@ -190,11 +190,11 @@ hdrs = headers if info && info['meta'] && (etag = info['meta']['version']) hdrs.merge!('if-match' => etag) end reply = json_parse_reply(@key_style, - *json_put(@target, "#{path}/#{URI.encode(id)}", info, hdrs)) + *json_put(@target, "#{path}/#{Addressable::URI.encode(id)}", info, hdrs)) # hide client endpoints that are not quite scim compatible type == :client && !reply ? get(type, info['client_id']): reply end @@ -208,11 +208,11 @@ hdrs = headers if info && info['meta'] && (etag = info['meta']['version']) hdrs.merge!('if-match' => etag) end reply = json_parse_reply(@key_style, - *json_patch(@target, "#{path}/#{URI.encode(id)}", info, hdrs)) + *json_patch(@target, "#{path}/#{Addressable::URI.encode(id)}", info, hdrs)) # hide client endpoints that are not quite scim compatible type == :client && !reply ? get(type, info['client_id']): reply end @@ -256,11 +256,11 @@ # Get information about a specific object. # @param (see #delete) # @return (see #add) def get(type, id) - info = json_get(@target, "#{type_info(type, :path)}/#{URI.encode(id)}", + info = json_get(@target, "#{type_info(type, :path)}/#{Addressable::URI.encode(id)}", @key_style, headers) fake_client_id(info) if type == :client # hide client reply, not quite scim info end @@ -268,11 +268,11 @@ # Get meta information about client # @param client_id # @return (client meta) def get_client_meta(client_id) path = type_info(:client, :path) - json_get(@target, "#{path}/#{URI.encode(client_id)}/meta", @key_style, headers) + json_get(@target, "#{path}/#{Addressable::URI.encode(client_id)}/meta", @key_style, headers) end # Collects all pages of entries from a query # @param type (see #query) # @param [Hash] query may contain the following keys: @@ -348,11 +348,11 @@ # @return [Hash] success message from server def change_password(user_id, new_password, old_password = nil) req = {"password" => new_password} req["oldPassword"] = old_password if old_password json_parse_reply(@key_style, *json_put(@target, - "#{type_info(:user, :path)}/#{URI.encode(user_id)}/password", req, headers)) + "#{type_info(:user, :path)}/#{Addressable::URI.encode(user_id)}/password", req, headers)) end # Change client secret. # * For a client to change its own secret, the token in @auth_header must contain # "client.secret" scope and the correct +old_secret+ must be given. @@ -364,29 +364,29 @@ # @return [Hash] success message from server def change_secret(client_id, new_secret, old_secret = nil) req = {"secret" => new_secret } req["oldSecret"] = old_secret if old_secret json_parse_reply(@key_style, *json_put(@target, - "#{type_info(:client, :path)}/#{URI.encode(client_id)}/secret", req, headers)) + "#{type_info(:client, :path)}/#{Addressable::URI.encode(client_id)}/secret", req, headers)) end def unlock_user(user_id) req = {"locked" => false} json_parse_reply(@key_style, *json_patch(@target, - "#{type_info(:user, :path)}/#{URI.encode(user_id)}/status", req, headers)) + "#{type_info(:user, :path)}/#{Addressable::URI.encode(user_id)}/status", req, headers)) end def map_group(group, is_id, external_group, origin = "ldap") key_name = is_id ? :groupId : :displayName - request = {key_name => group, :externalGroup => external_group, :schemas => ["urn:scim:schemas:core:1.0"], :origin => origin } + request = {key_name => group, externalGroup: external_group, schemas: ["urn:scim:schemas:core:1.0"], origin: origin } result = json_parse_reply(@key_style, *json_post(@target, "#{type_info(:group_mapping, :path)}", request, headers)) result end def unmap_group(group_id, external_group, origin = "ldap") - http_delete(@target, "#{type_info(:group_mapping, :path)}/groupId/#{group_id}/externalGroup/#{URI.encode(external_group)}/origin/#{origin}", + http_delete(@target, "#{type_info(:group_mapping, :path)}/groupId/#{group_id}/externalGroup/#{Addressable::URI.encode(external_group)}/origin/#{origin}", @auth_header, @zone) end def list_group_mappings(start = nil, count = nil) json_get(@target, "#{type_info(:group_mapping, :path)}/list?startIndex=#{start}&count=#{count}", @key_style, headers)