Class: Bosh::Director::Api::UAAIdentityProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/api/uaa_identity_provider.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ UAAIdentityProvider

Returns a new instance of UAAIdentityProvider.



7
8
9
10
11
# File 'lib/bosh/director/api/uaa_identity_provider.rb', line 7

def initialize(options)
  @url = options.fetch('url')
  Config.logger.debug "Initializing UAA Identity provider with url #{@url}"
  @token_coder = CF::UAA::TokenCoder.new(skey: options.fetch('key'), audience_ids: ['bosh_cli'])
end

Instance Method Details

#client_infoObject



13
14
15
16
17
18
19
20
# File 'lib/bosh/director/api/uaa_identity_provider.rb', line 13

def client_info
  {
    'type' => 'uaa',
    'options' => {
      'url' => @url
    }
  }
end

#corroborate_user(request_env) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/bosh/director/api/uaa_identity_provider.rb', line 22

def corroborate_user(request_env)
  auth_header = request_env['HTTP_AUTHORIZATION']
  token = @token_coder.decode(auth_header)
  token['user_name']
rescue CF::UAA::DecodeError, CF::UAA::AuthError => e
  raise AuthenticationError, e.message
end