Class: CASinoCore::Authenticator::Static

Inherits:
CASinoCore::Authenticator show all
Defined in:
lib/casino_core/authenticator/static.rb

Overview

The static authenticator is just a simple example. Never ever us this authenticator in a productive environment!

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Static

Returns a new instance of Static.

Parameters:

  • options (Hash)


8
9
10
# File 'lib/casino_core/authenticator/static.rb', line 8

def initialize(options)
  @users = options[:users] || {}
end

Instance Method Details

#validate(username, password) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/casino_core/authenticator/static.rb', line 12

def validate(username, password)
  username = :"#{username}"
  if @users.include?(username) && @users[username][:password] == password
    {
      username: "#{username}",
      extra_attributes: @users[username].except(:password)
    }
  else
    false
  end
end