Class: AtomicLti1v1::Lti1v1
- Inherits:
-
Object
- Object
- AtomicLti1v1::Lti1v1
- Defined in:
- lib/atomic_lti_1v1/lti_1v1.rb
Class Method Summary collapse
- .is_lti_1v1?(request) ⇒ Boolean
- .valid_lti_request?(request, lti_secret) ⇒ Boolean
- .valid_timestamp?(request) ⇒ Boolean
Class Method Details
.is_lti_1v1?(request) ⇒ Boolean
3 4 5 6 7 |
# File 'lib/atomic_lti_1v1/lti_1v1.rb', line 3 def self.is_lti_1v1?(request) request.params['oauth_consumer_key'].present? && request.params['oauth_signature'].present? && request.params['lti_version'] == 'LTI-1p0' end |
.valid_lti_request?(request, lti_secret) ⇒ Boolean
14 15 16 17 18 19 20 21 |
# File 'lib/atomic_lti_1v1/lti_1v1.rb', line 14 def self.valid_lti_request?(request, lti_secret) authenticator = IMS::LTI::Services::MessageAuthenticator.new(request.url, request.params, lti_secret) authenticator.valid_signature? && AtomicLti1v1::Nonce.valid?(request.params['oauth_nonce']) && (request) end |
.valid_timestamp?(request) ⇒ Boolean
9 10 11 12 |
# File 'lib/atomic_lti_1v1/lti_1v1.rb', line 9 def self.(request) # If timestamp is older than 5 minutes it's invalid !(DateTime.strptime(request.params['oauth_timestamp'], '%s') < 5.minutes.ago) end |