Class: CF::UAA::Misc
- Inherits:
-
Object
show all
- Extended by:
- Http
- Defined in:
- lib/uaa/misc.rb
Overview
everything is miscellaneous
this class provides interfaces to UAA endpoints that are not in the context of an overall class of operations, like “user accounts” or “tokens”. It’s also for some apis like “change user password” or “change client secret” that use different forms of authentication than other operations on those types of resources.
Class Method Summary
collapse
-
.decode_token(target, client_id, client_secret, token, token_type = "bearer", audience_ids = nil) ⇒ Object
Returns hash of values from the Authorization Server that are associated with the opaque token.
-
.password_strength(target, password) ⇒ Object
-
.server(target) ⇒ Object
-
.validation_key(target, client_id = nil, client_secret = nil) ⇒ Object
-
.varz(target, name, pwd) ⇒ Object
-
.whoami(target, auth_header) ⇒ Object
Methods included from Http
add_auth_json, basic_auth, http_delete, http_get, http_patch, http_post, http_put, json_get, json_parse_reply, json_patch, json_post, json_put, logger, logger=, set_request_handler, trace?
Class Method Details
.decode_token(target, client_id, client_secret, token, token_type = "bearer", audience_ids = nil) ⇒ Object
Returns hash of values from the Authorization Server that are associated with the opaque token.
50
51
52
53
54
55
56
57
58
|
# File 'lib/uaa/misc.rb', line 50
def self.decode_token(target, client_id, client_secret, token, token_type = "bearer", audience_ids = nil)
reply = json_get(target, "/check_token?token_type=#{token_type}&token=#{token}",
Http.basic_auth(client_id, client_secret))
auds = Util.arglist(reply["aud"])
if audience_ids && (!auds || (auds & audience_ids).empty?)
raise AuthError, "invalid audience: #{auds.join(' ')}"
end
reply
end
|
.password_strength(target, password) ⇒ Object
60
61
62
63
|
# File 'lib/uaa/misc.rb', line 60
def self.password_strength(target, password)
json_parse_reply(*request(target, :post, '/password/score', URI.encode_www_form("password" => password),
"content-type" => "application/x-www-form-urlencoded", "accept" => "application/json"))
end
|
.server(target) ⇒ Object
38
39
40
41
42
|
# File 'lib/uaa/misc.rb', line 38
def self.server(target)
reply = json_get(target, '/login')
return reply if reply && reply["prompts"]
raise BadResponse, "Invalid response from target #{target}"
end
|
.validation_key(target, client_id = nil, client_secret = nil) ⇒ Object
44
45
46
|
# File 'lib/uaa/misc.rb', line 44
def self.validation_key(target, client_id = nil, client_secret = nil)
json_get(target, "/token_key", (client_id && client_secret ? Http.basic_auth(client_id, client_secret) : nil))
end
|
.varz(target, name, pwd) ⇒ Object
36
|
# File 'lib/uaa/misc.rb', line 36
def self.varz(target, name, pwd) json_get(target, "/varz", Http.basic_auth(name, pwd)) end
|
.whoami(target, auth_header) ⇒ Object
35
|
# File 'lib/uaa/misc.rb', line 35
def self.whoami(target, ) json_get(target, "/userinfo?schema=openid", ) end
|