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

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

Constant Summary collapse

MAX_TOKEN_EXTENSION_TIME_IN_SECONDS =
3600

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ UAAIdentityProvider

Returns a new instance of UAAIdentityProvider.



9
10
11
12
13
14
15
16
17
18
# File 'lib/bosh/director/api/uaa_identity_provider.rb', line 9

def initialize(options)
  raise ValidationExtraField if options.has_key?('url') && options.has_key?('urls')
  if options.has_key?('url')
    @urls = [options.fetch('url')]
  else
    @urls = options.fetch('urls')
  end
  Config.logger.debug "Initializing UAA Identity provider with urls #{@urls}"
  @token_coder = CF::UAA::TokenCoder.new(skey: options.fetch('symmetric_key', nil), pkey: options.fetch('public_key', nil), scope: [])
end

Instance Method Details

#client_infoObject



24
25
26
27
28
29
30
31
32
# File 'lib/bosh/director/api/uaa_identity_provider.rb', line 24

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

#get_user(request_env, options) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/bosh/director/api/uaa_identity_provider.rb', line 34

def get_user(request_env, options)
  auth_header = request_env['HTTP_AUTHORIZATION']

  if options[:extended_token_timeout]
    request_time_in_seconds = request_env.fetch('HTTP_X_BOSH_UPLOAD_REQUEST_TIME').to_i
    request_time_in_seconds = MAX_TOKEN_EXTENSION_TIME_IN_SECONDS if request_time_in_seconds > MAX_TOKEN_EXTENSION_TIME_IN_SECONDS

    Config.logger.debug("Using extended token timeout, request took #{request_time_in_seconds} seconds")

    token = @token_coder.decode_at_reference_time(auth_header, Time.now.to_i - request_time_in_seconds)
  else
    token = @token_coder.decode(auth_header)
  end

  UaaUser.new(token)
rescue CF::UAA::DecodeError, CF::UAA::AuthError => e
  raise AuthenticationError, e.message
end

#supports_api_update?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/bosh/director/api/uaa_identity_provider.rb', line 20

def supports_api_update?
  false
end