Class: CFoundry::UAAClient
- Inherits:
-
Object
- Object
- CFoundry::UAAClient
- Defined in:
- lib/cfoundry/uaaclient.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#target ⇒ Object
Returns the value of attribute target.
-
#token ⇒ Object
Returns the value of attribute token.
-
#trace ⇒ Object
Returns the value of attribute trace.
Instance Method Summary collapse
- #add_user(email, password, options = {}) ⇒ Object
- #authorize(credentials) ⇒ Object
- #change_password(guid, new, old) ⇒ Object
- #delete_user(guid) ⇒ Object
-
#initialize(target, client_id = "cf", options = {}) ⇒ UAAClient
constructor
A new instance of UAAClient.
- #password_score(password) ⇒ Object
- #prompts ⇒ Object
- #try_to_refresh_token! ⇒ Object
- #user(guid) ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(target, client_id = "cf", options = {}) ⇒ UAAClient
Returns a new instance of UAAClient.
8 9 10 11 12 13 14 |
# File 'lib/cfoundry/uaaclient.rb', line 8 def initialize(target, client_id = "cf", = {}) @target = target @client_id = client_id @client_secret = [:client_secret] @skip_ssl_validation = [:skip_ssl_validation] @uaa_info_client = uaa_info_client_for(target) end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
6 7 8 |
# File 'lib/cfoundry/uaaclient.rb', line 6 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
6 7 8 |
# File 'lib/cfoundry/uaaclient.rb', line 6 def client_secret @client_secret end |
#target ⇒ Object
Returns the value of attribute target.
6 7 8 |
# File 'lib/cfoundry/uaaclient.rb', line 6 def target @target end |
#token ⇒ Object
Returns the value of attribute token.
6 7 8 |
# File 'lib/cfoundry/uaaclient.rb', line 6 def token @token end |
#trace ⇒ Object
Returns the value of attribute trace.
6 7 8 |
# File 'lib/cfoundry/uaaclient.rb', line 6 def trace @trace end |
Instance Method Details
#add_user(email, password, options = {}) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cfoundry/uaaclient.rb', line 63 def add_user(email, password, = {}) wrap_uaa_errors do scim.add( :user, {:userName => email, :emails => [{:value => email}], :password => password, :name => {:givenName => [:givenName] || email, :familyName => [:familyName] || email} } ) end end |
#authorize(credentials) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/cfoundry/uaaclient.rb', line 22 def (credentials) wrap_uaa_errors do authenticate_with_password_grant(credentials) || authenticate_with_implicit_grant(credentials) end end |
#change_password(guid, new, old) ⇒ Object
41 42 43 44 45 |
# File 'lib/cfoundry/uaaclient.rb', line 41 def change_password(guid, new, old) wrap_uaa_errors do scim.change_password(guid, new, old) end end |
#delete_user(guid) ⇒ Object
77 78 79 80 81 |
# File 'lib/cfoundry/uaaclient.rb', line 77 def delete_user(guid) wrap_uaa_errors do scim.delete(:user, guid) end end |
#password_score(password) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cfoundry/uaaclient.rb', line 47 def password_score(password) wrap_uaa_errors do response = uaa_info_client_for(uaa_url).password_strength(password) required_score = response[:requiredScore] || 0 case (response[:score] || 0) when 10 then :strong when required_score..9 then :good else :weak end end end |
#prompts ⇒ Object
16 17 18 19 20 |
# File 'lib/cfoundry/uaaclient.rb', line 16 def prompts wrap_uaa_errors do @uaa_info_client.server[:prompts] end end |
#try_to_refresh_token! ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/cfoundry/uaaclient.rb', line 83 def try_to_refresh_token! wrap_uaa_errors do begin token_info = token_issuer.refresh_token_grant(token.refresh_token) self.token = AuthToken.from_uaa_token_info(token_info) rescue CF::UAA::TargetError self.token end end end |
#user(guid) ⇒ Object
29 30 31 32 33 |
# File 'lib/cfoundry/uaaclient.rb', line 29 def user(guid) wrap_uaa_errors do scim.get(:user, guid) end end |
#users ⇒ Object
35 36 37 38 39 |
# File 'lib/cfoundry/uaaclient.rb', line 35 def users wrap_uaa_errors do scim.query(:user) end end |