Class: Bosh::Director::Api::LocalIdentityProvider
- Extended by:
- Forwardable
- Defined in:
- lib/bosh/director/api/local_identity_provider.rb
Instance Method Summary collapse
- #client_info ⇒ Object
- #get_user(request_env) ⇒ Object
-
#initialize(options, _) ⇒ LocalIdentityProvider
constructor
A new instance of LocalIdentityProvider.
- #required_scopes(_) ⇒ Object
- #valid_access?(user, _) ⇒ Boolean
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(, _) users = .fetch('users', []) @user_manager = Bosh::Director::Api::UserManagerProvider.new.user_manager(users) end |
Instance Method Details
#client_info ⇒ Object
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
36 37 38 |
# File 'lib/bosh/director/api/local_identity_provider.rb', line 36 def required_scopes(_) raise NotImplemented end |
#valid_access?(user, _) ⇒ 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 |