Class: Plasticine::Authentication

Inherits:
Object
  • Object
show all
Defined in:
lib/plasticine/authentication.rb

Instance Method Summary collapse

Constructor Details

#initialize(request_url, params = {}) ⇒ Authentication

Returns a new instance of Authentication.



6
7
8
9
# File 'lib/plasticine/authentication.rb', line 6

def initialize(request_url, params={})
  @request_url = request_url
  @params = params
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/plasticine/authentication.rb', line 11

def expired?
  @params[:timestamp] and Time.parse(@params[:timestamp]) + 12.hours < Time.now
end

#tokenizeObject



19
20
21
# File 'lib/plasticine/authentication.rb', line 19

def tokenize
  OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, token_key, filtered_url)
end

#valid_token?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/plasticine/authentication.rb', line 15

def valid_token?
  @params[:token] == tokenize
end