Class: CFoundry::UAAClient

Inherits:
BaseClient show all
Defined in:
lib/cfoundry/uaaclient.rb

Constant Summary

Constants inherited from BaseClient

BaseClient::LOG_LENGTH

Instance Attribute Summary collapse

Attributes inherited from BaseClient

#backtrace, #log

Instance Method Summary collapse

Methods inherited from BaseClient

#request_path, #token_data

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 = @target + "/redirect/vmc"
end

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



5
6
7
# File 'lib/cfoundry/uaaclient.rb', line 5

def client_id
  @client_id
end

#redirect_uriObject

Returns the value of attribute redirect_uri.



5
6
7
# File 'lib/cfoundry/uaaclient.rb', line 5

def redirect_uri
  @redirect_uri
end

#targetObject

Returns the value of attribute target.



5
6
7
# File 'lib/cfoundry/uaaclient.rb', line 5

def target
  @target
end

#tokenObject

Returns the value of attribute token.



5
6
7
# File 'lib/cfoundry/uaaclient.rb', line 5

def token
  @token
end

#traceObject

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
# File 'lib/cfoundry/uaaclient.rb', line 19

def authorize(credentials)
  query = {
    :client_id => @client_id,
    :response_type => "token",
    :redirect_uri => @redirect_uri
  }

  extract_token(
    post(
      { :credentials => credentials },
      "oauth", "authorize",
      :form => :headers,
      :params => query)[:location])
end

#change_password(guid, new, old) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/cfoundry/uaaclient.rb', line 38

def change_password(guid, new, old)
  put(
    { :schemas => ["urn:scim:schemas:core:1.0"],
      :password => new,
      :oldPassword => old
    },
    "User", guid, "password",
    :json => nil)
end

#promptsObject



15
16
17
# File 'lib/cfoundry/uaaclient.rb', line 15

def prompts
  get("login", nil => :json)[:prompts]
end

#usersObject



34
35
36
# File 'lib/cfoundry/uaaclient.rb', line 34

def users
  get("Users", nil => :json)
end