Module: TuwienLogon::Authentication

Defined in:
lib/tuwien_logon/authentication.rb

Defined Under Namespace

Classes: Authentication

Instance Method Summary collapse

Instance Method Details

#authenticated?(params) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
13
# File 'lib/tuwien_logon/authentication.rb', line 3

def authenticated?(params)
  raise 'You must provide at least a user_id, a host and an skey' unless params[:user_id] && params[:host] && params[:skey]
  
  secret = params[:secret] || TuwienLogon.config.secret
  tolerance = params[:time_tolerance] || TuwienLogon.config.time_tolerance
  offset = params[:server_time_offset] || TuwienLogon.config.server_time_offset
  time = params[:time] || Time.now
  
  auth = Authentication.new params[:user_id], params[:host], secret, tolerance, time + offset
  auth.valid? params[:skey]
end