Class: CFoundry::UAAClient
- Inherits:
-
BaseClient
- Object
- BaseClient
- CFoundry::UAAClient
- Defined in:
- lib/cfoundry/uaaclient.rb
Constant Summary
Constants inherited from BaseClient
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
-
#target ⇒ Object
Returns the value of attribute target.
-
#token ⇒ Object
Returns the value of attribute token.
-
#trace ⇒ Object
Returns the value of attribute trace.
Attributes inherited from BaseClient
Instance Method Summary collapse
- #authorize(credentials) ⇒ Object
- #change_password(guid, new, old) ⇒ Object
-
#initialize(target = "https://uaa.cloudfoundry.com", client_id = "vmc") ⇒ UAAClient
constructor
A new instance of UAAClient.
- #prompts ⇒ Object
- #users ⇒ Object
Methods inherited from BaseClient
Constructor Details
#initialize(target = "https://uaa.cloudfoundry.com", client_id = "vmc") ⇒ UAAClient
Returns a new instance of UAAClient.
7 8 9 10 11 12 13 |
# File 'lib/cfoundry/uaaclient.rb', line 7 def initialize( target = "https://uaa.cloudfoundry.com", client_id = "vmc") @target = target @client_id = client_id @redirect_uri = "https://uaa.cloudfoundry.com/redirect/vmc" end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
5 6 7 |
# File 'lib/cfoundry/uaaclient.rb', line 5 def client_id @client_id end |
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
5 6 7 |
# File 'lib/cfoundry/uaaclient.rb', line 5 def redirect_uri @redirect_uri end |
#target ⇒ Object
Returns the value of attribute target.
5 6 7 |
# File 'lib/cfoundry/uaaclient.rb', line 5 def target @target end |
#token ⇒ Object
Returns the value of attribute token.
5 6 7 |
# File 'lib/cfoundry/uaaclient.rb', line 5 def token @token end |
#trace ⇒ Object
Returns the value of attribute trace.
5 6 7 |
# File 'lib/cfoundry/uaaclient.rb', line 5 def trace @trace end |
Instance Method Details
#authorize(credentials) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cfoundry/uaaclient.rb', line 19 def (credentials) query = { :client_id => @client_id, :response_type => "token", :redirect_uri => @redirect_uri } auth = post( { :credentials => credentials }, "oauth", "authorize", :return_response => true, :content => :form, :accept => :json, :params => query) case auth when Net::HTTPRedirection extract_token(auth["location"]) else json = parse_json(auth.body) raise CFoundry::Denied.new( auth.code.to_i, json[:error_description]) end end |
#change_password(guid, new, old) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/cfoundry/uaaclient.rb', line 50 def change_password(guid, new, old) put( { :schemas => ["urn:scim:schemas:core:1.0"], :password => new, :oldPassword => old }, "User", guid, "password", :content => :json) end |
#prompts ⇒ Object
15 16 17 |
# File 'lib/cfoundry/uaaclient.rb', line 15 def prompts get("login", :accept => :json)[:prompts] end |
#users ⇒ Object
46 47 48 |
# File 'lib/cfoundry/uaaclient.rb', line 46 def users get("Users", :accept => :json) end |