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

#required_scopes(_) ⇒ Object

Raises:

  • (NotImplemented)


36
37
38
# File 'lib/bosh/director/api/local_identity_provider.rb', line 36

def required_scopes(_)
  raise NotImplemented
end

#valid_access?(user, _) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/bosh/director/api/local_identity_provider.rb', line 32

def valid_access?(user, _)
  @user_manager.authenticate(user.username, user.password)
end