lib/uaa/misc.rb in cf-uaa-lib-1.3.7 vs lib/uaa/misc.rb in cf-uaa-lib-1.3.8
- old
+ new
@@ -58,9 +58,24 @@
reply = json_get(target, '/login', @key_style)
return reply if reply && (reply[:prompts] || reply['prompts'])
raise BadResponse, "Invalid response from target #{target}"
end
+ # Gets a base url for the associated UAA from the target server by inspecting the
+ # links returned from its info endpoint.
+ # @param [String] target The base URL of the server. For example the target could
+ # be {https://login.cloudfoundry.com}, {https://uaa.cloudfoundry.com}, or
+ # {http://localhost:8080/uaa}.
+ # @return [String] url of UAA (or the target itself if it didn't provide a response)
+ def self.discover_uaa(target)
+ info = server(target)
+ if info['links'] && info['links']['uaa']
+ info['links']['uaa']
+ else
+ target
+ end
+ end
+
# Gets the key from the server that is used to validate token signatures. If
# the server is configured to use a symetric key, the caller must authenticate
# by providing a a +client_id+ and +client_secret+. If the server
# is configured to sign with a private key, this call will retrieve the
# public key and +client_id+ must be nil.