Class: Mountapi::Adapters::UserInfoAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/mountapi/adapters/user_info_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(header_name, options) ⇒ UserInfoAdapter

Returns a new instance of UserInfoAdapter.



7
8
9
10
# File 'lib/mountapi/adapters/user_info_adapter.rb', line 7

def initialize(header_name, options)
  @header_name = header_name
  @options = options
end

Instance Method Details

#call(params, roles) ⇒ Object



12
13
14
15
16
17
# File 'lib/mountapi/adapters/user_info_adapter.rb', line 12

def call(params, roles)
  roles_key = options[:roles]
   = JSON.parse(Base64.decode64(params[header_name]))

  [roles_key].any? { |role| roles.include?(role) }
end