Class: Plasticine::Authentication
- Inherits:
-
Object
- Object
- Plasticine::Authentication
- Defined in:
- lib/plasticine/authentication.rb
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(request_url, params = {}) ⇒ Authentication
constructor
A new instance of Authentication.
- #tokenize ⇒ Object
- #valid_token? ⇒ Boolean
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
11 12 13 |
# File 'lib/plasticine/authentication.rb', line 11 def expired? @params[:timestamp] and Time.parse(@params[:timestamp]) + 12.hours < Time.now end |
#tokenize ⇒ Object
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
15 16 17 |
# File 'lib/plasticine/authentication.rb', line 15 def valid_token? @params[:token] == tokenize end |