Class: Bosh::Director::Api::LocalIdentityProvider

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/bosh/director/api/local_identity_provider.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ LocalIdentityProvider

Returns a new instance of LocalIdentityProvider.



9
10
11
12
# File 'lib/bosh/director/api/local_identity_provider.rb', line 9

def initialize(options)
  users = options.fetch('users', [])
  @user_manager = Bosh::Director::Api::UserManagerProvider.new.user_manager(users)
end

Instance Method Details

#client_infoObject



17
18
19
# File 'lib/bosh/director/api/local_identity_provider.rb', line 17

def client_info
  {'type' => 'basic', 'options' => {}}
end

#get_user(request_env, _) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/bosh/director/api/local_identity_provider.rb', line 21

def get_user(request_env, _)
  auth ||= Rack::Auth::Basic::Request.new(request_env)
  raise AuthenticationError unless auth.provided? && auth.basic? && auth.credentials

  unless @user_manager.authenticate(*auth.credentials)
    raise AuthenticationError
  end

  LocalUser.new(*auth.credentials)
end