ims-lti 1.1.13 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 349045d52db72ab3885b106c5874f5e6c217fed2
4
- data.tar.gz: 3dd49abc26a739d0c313f8bdb477317a79c2598d
3
+ metadata.gz: 3235b72aa7a7f01032b0e5a4e6f41291ef9fd8dc
4
+ data.tar.gz: 6fe9dd358c230756b798ede1317647fa0dfe5fe7
5
5
  SHA512:
6
- metadata.gz: 14f47290fd89679b75b5e5b4957b08c9431e50b69632a313f89a194454b61126c8ee801b5329b246b8c64d7458698629bb289de1c66450498f20051be803506c
7
- data.tar.gz: befc124ca8958e2912466f3a79dd8f20a9105cba6614a3bfe96d374d6dcffa2634493138a08727ef7ffc1d1a929624ee8d3b40e92cfe6f69b5d53f1f984172d0
6
+ metadata.gz: a533acf2b2051cc3ec55e9f2a1851ee008a64d2e595661f839d8e7528231d91d3e88aa4f313a1719adf9660c6a65df5515be1834cff1e2730dd0e48815f15dac
7
+ data.tar.gz: b6baa3a683f85d810bee49ccc79b07c9a535390e56eeec4fad4865fd35ca0f2c6c32283b159058e11c012b6f65681f359ed0cc351601850fa7ac336caed8f783
data/Changelog CHANGED
@@ -1,3 +1,6 @@
1
+ 2017-03-08 Version 1.2.0
2
+ * Don't downcase roles
3
+
1
4
  2016-10-05 Version 1.1.13
2
5
  * Fix Oauth::Unauthorized initialization bug
3
6
  * Relax oauth dependency
data/README.md CHANGED
@@ -52,7 +52,7 @@ and it will be signed with OAuth using a key/secret that both the TP and TC shar
52
52
  This is covered in the [LTI security model](http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560466)
53
53
 
54
54
  Here is an example of a simple TP Sinatra app using this gem:
55
- [LTI Tool Provider](https://github.com/instructure/lti_tool_provider_example)
55
+ [LTI Tool Provider](https://github.com/instructure/lti1_tool_provider_example)
56
56
 
57
57
  Once you find the `oauth_consumer_secret` based on the `oauth_consumer_key` in
58
58
  the request, you can initialize a `ToolProvider` object with them and the post parameters:
data/lib/ims/lti.rb CHANGED
@@ -2,6 +2,7 @@ require 'oauth'
2
2
  require 'builder'
3
3
  require "rexml/document"
4
4
  require 'cgi'
5
+ require 'securerandom'
5
6
 
6
7
  module IMS # :nodoc:
7
8
 
@@ -25,13 +26,16 @@ module IMS # :nodoc:
25
26
  #
26
27
  # require 'ims/lti'
27
28
  module LTI
28
-
29
+
29
30
  # The versions of LTI this library supports
30
31
  VERSIONS = %w{1.0 1.1}
31
-
32
+
32
33
  class InvalidLTIConfigError < StandardError
33
34
  end
34
35
 
36
+ class XMLParseError < StandardError
37
+ end
38
+
35
39
  # POST a signed oauth request with the given key/secret/data
36
40
  def self.post_service_request(key, secret, url, content_type, body)
37
41
  raise IMS::LTI::InvalidLTIConfigError, "" unless key && secret
@@ -6,7 +6,7 @@ module DeprecatedRoleChecks
6
6
  # Check whether the Launch Parameters have a role
7
7
  def has_role?(role)
8
8
  role = role.downcase
9
- @roles && @roles.any?{|r| r.index(role)}
9
+ @roles && @roles.any?{|r| r.downcase.index(role)}
10
10
  end
11
11
 
12
12
  # Convenience method for checking if the user has 'learner' or 'student' role
@@ -96,7 +96,7 @@ module IMS::LTI
96
96
  if roles_list.is_a?(Array)
97
97
  @roles = roles_list
98
98
  else
99
- @roles = roles_list.split(",").map(&:downcase)
99
+ @roles = roles_list.split(",")
100
100
  end
101
101
  else
102
102
  @roles = nil
@@ -46,7 +46,7 @@ module IMS::LTI
46
46
  #
47
47
  class OutcomeResponse
48
48
  include IMS::LTI::Extensions::Base
49
-
49
+
50
50
  attr_accessor :request_type, :score, :message_identifier, :response_code,
51
51
  :post_response, :code_major, :severity, :description, :operation,
52
52
  :message_ref_identifier
@@ -70,7 +70,7 @@ module IMS::LTI
70
70
  response = OutcomeResponse.new
71
71
  response.process_post_response(post_response)
72
72
  end
73
-
73
+
74
74
  def process_post_response(post_response)
75
75
  self.post_response = post_response
76
76
  self.response_code = post_response.code
@@ -105,7 +105,11 @@ module IMS::LTI
105
105
 
106
106
  # Parse Outcome Response data from XML
107
107
  def process_xml(xml)
108
- doc = REXML::Document.new xml
108
+ begin
109
+ doc = REXML::Document.new xml
110
+ rescue => e
111
+ raise IMS::LTI::XMLParseError, "#{e}\nOriginal xml: '#{xml}'"
112
+ end
109
113
  @message_identifier = doc.text("//imsx_statusInfo/imsx_messageIdentifier").to_s
110
114
  @code_major = doc.text("//imsx_statusInfo/imsx_codeMajor")
111
115
  @code_major.downcase! if @code_major
@@ -16,7 +16,7 @@ module IMS::LTI
16
16
  # Check whether the Launch Parameters have a given role
17
17
  def has_exact_role?(role)
18
18
  role = role.downcase
19
- @roles && @roles.any? { |r| r == role }
19
+ @roles && @roles.any? { |r| r.downcase == role }
20
20
  end
21
21
 
22
22
  # Check whether the Launch Parameters have a given role ignoring
@@ -25,7 +25,7 @@ module IMS::LTI
25
25
  # will return true if the role is `urn:lti:role:ims/lis/Instructor/GuestInstructor`
26
26
  def has_base_role?(role)
27
27
  role = role.downcase
28
- @roles && @roles.any? { |r| r.start_with?(role) }
28
+ @roles && @roles.any? { |r| r.downcase.start_with?(role) }
29
29
  end
30
30
 
31
31
  # Convenience method for checking if the user is the system administrator of the TC
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ims-lti
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.13
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure
@@ -28,22 +28,16 @@ dependencies:
28
28
  name: oauth
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.4.5
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '0.6'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ">="
38
+ - - '='
42
39
  - !ruby/object:Gem::Version
43
40
  version: 0.4.5
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '0.6'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: rspec
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -104,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
98
  version: '0'
105
99
  requirements: []
106
100
  rubyforge_project:
107
- rubygems_version: 2.5.1
101
+ rubygems_version: 2.5.2
108
102
  signing_key:
109
103
  specification_version: 4
110
104
  summary: Ruby library for creating IMS LTI tool providers and consumers