ims-lti 1.2.4 → 2.0.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/Changelog.txt +0 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +15 -103
  5. data/lib/ims.rb +3 -1
  6. data/lib/ims/lti.rb +6 -64
  7. data/lib/ims/lti/converters.rb +5 -0
  8. data/lib/ims/lti/converters/time_json_converter.rb +13 -0
  9. data/lib/ims/lti/models.rb +29 -0
  10. data/lib/ims/lti/models/base_url_choice.rb +15 -0
  11. data/lib/ims/lti/models/base_url_selector.rb +5 -0
  12. data/lib/ims/lti/models/contact.rb +5 -0
  13. data/lib/ims/lti/models/icon_endpoint.rb +5 -0
  14. data/lib/ims/lti/models/icon_info.rb +6 -0
  15. data/lib/ims/lti/models/localized_name.rb +11 -0
  16. data/lib/ims/lti/models/localized_text.rb +11 -0
  17. data/lib/ims/lti/models/lti_model.rb +169 -0
  18. data/lib/ims/lti/models/message_handler.rb +6 -0
  19. data/lib/ims/lti/models/messages.rb +6 -0
  20. data/lib/ims/lti/models/messages/basic_lti_launch_request.rb +8 -0
  21. data/lib/ims/lti/models/messages/message.rb +43 -0
  22. data/lib/ims/lti/models/messages/registration_request.rb +17 -0
  23. data/lib/ims/lti/models/parameter.rb +5 -0
  24. data/lib/ims/lti/models/product_family.rb +8 -0
  25. data/lib/ims/lti/models/product_info.rb +19 -0
  26. data/lib/ims/lti/models/product_instance.rb +10 -0
  27. data/lib/ims/lti/models/resource_handler.rb +18 -0
  28. data/lib/ims/lti/models/resource_type.rb +6 -0
  29. data/lib/ims/lti/models/rest_service.rb +14 -0
  30. data/lib/ims/lti/models/rest_service_profile.rb +7 -0
  31. data/lib/ims/lti/models/security_contract.rb +9 -0
  32. data/lib/ims/lti/models/service_owner.rb +8 -0
  33. data/lib/ims/lti/models/service_provider.rb +11 -0
  34. data/lib/ims/lti/models/tool_consumer_profile.rb +20 -0
  35. data/lib/ims/lti/models/tool_profile.rb +22 -0
  36. data/lib/ims/lti/models/tool_proxy.rb +11 -0
  37. data/lib/ims/lti/models/vendor.rb +28 -0
  38. data/lib/ims/lti/services.rb +5 -0
  39. data/lib/ims/lti/services/message_service.rb +40 -0
  40. data/lib/ims/lti/version.rb +5 -0
  41. metadata +68 -52
  42. data/Changelog +0 -54
  43. data/LICENSE +0 -18
  44. data/lib/ims/lti/deprecated_role_checks.rb +0 -52
  45. data/lib/ims/lti/extensions.rb +0 -45
  46. data/lib/ims/lti/extensions/canvas.rb +0 -122
  47. data/lib/ims/lti/extensions/content.rb +0 -209
  48. data/lib/ims/lti/extensions/outcome_data.rb +0 -216
  49. data/lib/ims/lti/launch_params.rb +0 -166
  50. data/lib/ims/lti/outcome_request.rb +0 -225
  51. data/lib/ims/lti/outcome_response.rb +0 -166
  52. data/lib/ims/lti/request_validator.rb +0 -56
  53. data/lib/ims/lti/role_checks.rb +0 -101
  54. data/lib/ims/lti/tool_base.rb +0 -29
  55. data/lib/ims/lti/tool_config.rb +0 -231
  56. data/lib/ims/lti/tool_consumer.rb +0 -86
  57. data/lib/ims/lti/tool_provider.rb +0 -143
@@ -0,0 +1,6 @@
1
+ module IMS::LTI::Models
2
+ class MessageHandler < LTIModel
3
+ add_attributes :message_type, :path, :enabled_capability, :parameter
4
+ add_attribute :parameter, relation:'IMS::LTI::Models::Parameter'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module IMS::LTI::Models
2
+ module Messages
3
+ require_relative 'messages/message'
4
+ require_relative 'messages/registration_request'
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module IMS::LTI::Models::Messages
2
+ class BasicLTILaunchRequest < IMS::LTI::Models::LTIModel
3
+
4
+ add_attributes :context_id, :context_type, :launch_presentation_return_url, :resource_link_id, :role_scope_mentor,
5
+ :tool_consumer_instance_guid, :user_image
6
+
7
+ end
8
+ end
@@ -0,0 +1,43 @@
1
+ module IMS::LTI::Models::Messages
2
+ class Message < IMS::LTI::Models::LTIModel
3
+ LAUNCH_TARGET_IFRAME = 'iframe'
4
+ LAUNCH_TARGET_WINDOW = 'window'
5
+
6
+ add_attributes :lti_message_type, :lti_version, :user_id, :roles, :launch_presentation_local,
7
+ :launch_presentation_document_target, :launch_presentation_css_url, :launch_presentation_width,
8
+ :launch_presentation_height
9
+
10
+ def initialize(attrs = {})
11
+ super(attrs)
12
+ @custom_params = {}
13
+ @ext_params = {}
14
+ end
15
+
16
+ def post_params
17
+ get_custom_params.merge(get_ext_params).merge(attributes)
18
+ end
19
+
20
+ def get_ext_params
21
+ params = {}
22
+ @ext_params.each { |k, v| params["ext_#{k}"] = v }
23
+ params
24
+ end
25
+
26
+ def get_custom_params
27
+ params = {}
28
+ @custom_params.each { |k, v| params["custom_#{k}"] = v }
29
+ params
30
+ end
31
+
32
+ def method_missing(meth, *args, &block)
33
+ if match = /^(custom|ext)_([^=$]*)/.match(meth)
34
+ param_type, key = match.captures
35
+ param_hash = instance_variable_get("@#{param_type}_params".to_sym)
36
+ meth =~ /=$/ ? param_hash[key] = args[0] : param_hash[key]
37
+ else
38
+ super
39
+ end
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,17 @@
1
+ module IMS::LTI::Models::Messages
2
+ class RegistrationRequest < Message
3
+ add_attributes :reg_key, :reg_password, :tc_profile_url, :launch_presentation_return_url
4
+
5
+ REGISTRATION_REQUEST_MESSAGE_TYPE = 'ToolProxyRegistrationRequest'
6
+
7
+ def initialize(attributes = {})
8
+ super(attributes)
9
+ self.lti_message_type = REGISTRATION_REQUEST_MESSAGE_TYPE
10
+ end
11
+
12
+ def generate_key_and_password
13
+ self.reg_key, self.reg_password = 2.times.map { SecureRandom.uuid }
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module IMS::LTI::Models
2
+ class Parameter < LTIModel
3
+ add_attributes :name, :variable, :fixed
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ module IMS::LTI::Models
2
+ class ProductFamily < LTIModel
3
+ add_attributes :code
4
+ add_attribute :id, json_key: '@id'
5
+ add_attribute :vendor, relation: 'IMS::LTI::Models::Vendor'
6
+
7
+ end
8
+ end
@@ -0,0 +1,19 @@
1
+ module IMS::LTI::Models
2
+ class ProductInfo < LTIModel
3
+ add_attribute :product_version
4
+ add_attribute :product_family, relation: 'IMS::LTI::Models::ProductFamily'
5
+ add_attribute :description, relation: 'IMS::LTI::Models::LocalizedText'
6
+ add_attribute :product_name, relation: 'IMS::LTI::Models::LocalizedName'
7
+ add_attribute :technical_description, relation: 'IMS::LTI::Models::LocalizedText'
8
+
9
+ def create_product_name(name, key = 'product.name')
10
+ @product_name = LocalizedName.new(name, key)
11
+ end
12
+
13
+ def create_description(name, key = 'product.description')
14
+ @description = LocalizedText.new(name, key)
15
+ end
16
+
17
+
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ module IMS::LTI::Models
2
+ class ProductInstance < LTIModel
3
+ add_attributes :guid
4
+ add_attribute :product_info, relation:'IMS::LTI::Models::ProductInfo'
5
+ add_attribute :service_owner, relation:'IMS::LTI::Models::ServiceOwner'
6
+ add_attribute :support, relation:'IMS::LTI::Models::ServiceProvider'
7
+ add_attribute :service_provider, relation:'IMS::LTI::Models::Contact'
8
+
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ module IMS::LTI::Models
2
+ class ResourceHandler < LTIModel
3
+ add_attribute :resource_type, relation: 'IMS::LTI::Models::ResourceType'
4
+ add_attribute :resource_name, relation: 'IMS::LTI::Models::LocalizedName'
5
+ add_attribute :description, relation: 'IMS::LTI::Models::LocalizedText'
6
+ add_attribute :message, relation: 'IMS::LTI::Models::MessageHandler'
7
+ add_attribute :icon_info, relation: 'IMS::LTI::Models::IconInfo'
8
+
9
+ def default_name
10
+ resource_name && resource_name.default_value
11
+ end
12
+
13
+ def default_description
14
+ description && description.default_value
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,6 @@
1
+ module IMS::LTI::Models
2
+ class ResourceType < LTIModel
3
+ add_attribute :code
4
+
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ module IMS::LTI::Models
2
+ class RestService < LTIModel
3
+ TYPE = 'RestService'
4
+
5
+ add_attributes :endpoint, :format, :action
6
+ add_attribute :id, json_key:'@id'
7
+ add_attribute :type, json_key: '@type'
8
+
9
+ def initialize
10
+ @type = TYPE
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ module IMS::LTI::Models
2
+ class RestServiceProfile < LTIModel
3
+ add_attributes :service, :action
4
+ add_attribute :type, json_key: '@type'
5
+
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module IMS::LTI::Models
2
+ class SecurityContract < LTIModel
3
+
4
+ add_attribute :shared_secret
5
+ add_attribute :tool_service, relation: 'IMS::LTI::Models::RestServiceProfile'
6
+ add_attribute :end_user_service, relation: 'IMS::LTI::Models::RestServiceProfile'
7
+
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module IMS::LTI::Models
2
+ class ServiceOwner < LTIModel
3
+ add_attribute :description, relation: 'IMS::LTI::Models::LocalizedText'
4
+ add_attribute :timestamp, json_converter:'IMS::LTI::Converters::TimeJSONConverter'
5
+ add_attribute :service_owner_name, relation: 'IMS::LTI::Models::LocalizedName'
6
+
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ module IMS::LTI::Models
2
+ class ServiceProvider < LTIModel
3
+ add_attribute :guid
4
+ add_attribute :id, json_key:'@id'
5
+ add_attribute :service_provider_name, relation:'IMS::LTI::Models::LocalizedName'
6
+ add_attribute :description, relation:'IMS::LTI::Models::LocalizedText'
7
+ add_attribute :support, relation:'IMS::LTI::Models::Contact'
8
+ add_attribute :timestamp, json_converter: 'IMS::LTI::Converters::TimeJSONConverter'
9
+
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ module IMS::LTI::Models
2
+ class ToolConsumerProfile < LTIModel
3
+
4
+ CONTEXT = "http://purl.imsglobal.org/ctx/lti/v2/ToolConsumerProfile"
5
+ TYPE = "ToolConsumerProfile"
6
+
7
+ add_attributes :lti_version, :guid, :capability_offered
8
+ add_attribute :id, json_key:'@id'
9
+ add_attribute :type, json_key:'@type'
10
+ add_attribute :context, json_key:'@context'
11
+ add_attribute :product_instance, relation:'IMS::LTI::Models::ProductInstance'
12
+ add_attribute :service_offered, relation: 'IMS::LTI::Models::RestService'
13
+
14
+ def initialize
15
+ @context = [CONTEXT]
16
+ @type = TYPE
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ module IMS::LTI::Models
2
+ class ToolProfile < LTIModel
3
+ add_attributes :lti_version
4
+ add_attribute :id, json_key: '@id'
5
+ add_attribute :product_instance, relation:'IMS::LTI::Models::ProductInstance'
6
+ add_attribute :base_url_choice, relation: 'IMS::LTI::Models::BaseUrlChoice'
7
+ add_attribute :resource_handler, relation:'IMS::LTI::Models::ResourceHandler'
8
+ add_attribute :message, relation:'IMS::LTI::Models::MessageHandler'
9
+ add_attribute :service_offered, relation:'IMS::LTI::Models::RestService'
10
+
11
+
12
+ def base_message_url
13
+ if base_url_choice
14
+ choice = base_url_choice.find { |choice| choice.default_message_url != '' }
15
+ choice.default_message_url
16
+ else
17
+ ''
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ module IMS::LTI::Models
2
+ class ToolProxy < LTIModel
3
+ add_attributes :lti_version, :tool_proxy_guid, :custom, :custom_url, :enabled_capability
4
+ add_attribute :context, json_key:'@context'
5
+ add_attribute :type, json_key:'@type'
6
+ add_attribute :id, json_key:'@id'
7
+ add_attribute :tool_consumer_profile
8
+ add_attribute :tool_profile, relation:'IMS::LTI::Models::ToolProfile'
9
+ add_attribute :security_contract, relation:'IMS::LTI::Models::SecurityContract'
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ module IMS::LTI::Models
2
+ class Vendor < LTIModel
3
+
4
+ add_attributes :code, :website
5
+ add_attribute :id, json_key:'@id'
6
+ add_attribute :contact, relation:'IMS::LTI::Models::Contact'
7
+ add_attribute :vendor_name, relation:'IMS::LTI::Models::LocalizedName'
8
+ add_attribute :description, relation:'IMS::LTI::Models::LocalizedText'
9
+ add_attribute :timestamp, json_converter: 'IMS::LTI::Converters::TimeJSONConverter'
10
+
11
+ def create_vendor_name(name, key = 'vendor.name')
12
+ @vendor_name = LocalizedName.new(name, key)
13
+ end
14
+
15
+ def create_description(name, key = 'vendor.description')
16
+ @description = LocalizedText.new(name, key)
17
+ end
18
+
19
+ def default_name
20
+ vendor_name && vendor_name.default_value
21
+ end
22
+
23
+ def default_description
24
+ description && description.default_value
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ module IMS::LTI
2
+ module Services
3
+ require_relative 'services/message_service'
4
+ end
5
+ end
@@ -0,0 +1,40 @@
1
+ module IMS::LTI::Services
2
+ class MessageService
3
+
4
+ def initialize(key, secret)
5
+ @key = key
6
+ @secret = secret
7
+ end
8
+
9
+ def signed_request(url, message)
10
+ uri = URI.parse(url)
11
+ oauth_consumer = OAuth::Consumer.new(@key, @secret, {
12
+ :site => "#{uri.scheme}://#{uri.host}",
13
+ :scheme => :body
14
+ })
15
+ request = oauth_consumer.create_signed_request(:post, uri.request_uri, nil, {}, message.post_params)
16
+
17
+ request
18
+ end
19
+
20
+ def signed_params(url, message)
21
+ signed_request = signed_request(url, message)
22
+
23
+ params = {}
24
+ CGI.parse(signed_request.body).each do |key, value|
25
+ params[key] = value.first
26
+ end
27
+ params
28
+ end
29
+
30
+ def valid_signature?(url, params)
31
+ request = {
32
+ 'method' => 'POST',
33
+ 'uri' => url,
34
+ 'parameters' => params
35
+ }
36
+
37
+ OAuth::Signature.build(request, :consumer_secret => @secret).verify()
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,5 @@
1
+ module IMS
2
+ module LTI
3
+ VERSION = "2.0.0.beta.1"
4
+ end
5
+ end
metadata CHANGED
@@ -1,101 +1,116 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ims-lti
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 2.0.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-07 00:00:00.000000000 Z
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: builder
14
+ name: json-ld
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '4.0'
19
+ version: 1.1.4
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '1.0'
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '4.0'
26
+ version: 1.1.4
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: oauth
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 0.4.5
40
- - - "<"
31
+ - - "~>"
41
32
  - !ruby/object:Gem::Version
42
- version: '0.6'
33
+ version: 0.4.7
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.7
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
46
44
  requirements:
47
45
  - - ">="
48
46
  - !ruby/object:Gem::Version
49
- version: 0.4.5
50
- - - "<"
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
51
53
  - !ruby/object:Gem::Version
52
- version: '0.6'
54
+ version: '0'
53
55
  - !ruby/object:Gem::Dependency
54
56
  name: rspec
55
57
  requirement: !ruby/object:Gem::Requirement
56
58
  requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '3.0'
60
- - - ">"
59
+ - - ">="
61
60
  - !ruby/object:Gem::Version
62
- version: '3.0'
61
+ version: '0'
63
62
  type: :development
64
63
  prerelease: false
65
64
  version_requirements: !ruby/object:Gem::Requirement
66
65
  requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '3.0'
70
- - - ">"
66
+ - - ">="
71
67
  - !ruby/object:Gem::Version
72
- version: '3.0'
68
+ version: '0'
73
69
  description:
74
70
  email:
75
71
  executables: []
76
72
  extensions: []
77
- extra_rdoc_files:
78
- - LICENSE
73
+ extra_rdoc_files: []
79
74
  files:
80
- - Changelog
81
- - LICENSE
75
+ - Changelog.txt
76
+ - LICENSE.txt
82
77
  - README.md
83
78
  - lib/ims.rb
84
79
  - lib/ims/lti.rb
85
- - lib/ims/lti/deprecated_role_checks.rb
86
- - lib/ims/lti/extensions.rb
87
- - lib/ims/lti/extensions/canvas.rb
88
- - lib/ims/lti/extensions/content.rb
89
- - lib/ims/lti/extensions/outcome_data.rb
90
- - lib/ims/lti/launch_params.rb
91
- - lib/ims/lti/outcome_request.rb
92
- - lib/ims/lti/outcome_response.rb
93
- - lib/ims/lti/request_validator.rb
94
- - lib/ims/lti/role_checks.rb
95
- - lib/ims/lti/tool_base.rb
96
- - lib/ims/lti/tool_config.rb
97
- - lib/ims/lti/tool_consumer.rb
98
- - lib/ims/lti/tool_provider.rb
80
+ - lib/ims/lti/converters.rb
81
+ - lib/ims/lti/converters/time_json_converter.rb
82
+ - lib/ims/lti/models.rb
83
+ - lib/ims/lti/models/base_url_choice.rb
84
+ - lib/ims/lti/models/base_url_selector.rb
85
+ - lib/ims/lti/models/contact.rb
86
+ - lib/ims/lti/models/icon_endpoint.rb
87
+ - lib/ims/lti/models/icon_info.rb
88
+ - lib/ims/lti/models/localized_name.rb
89
+ - lib/ims/lti/models/localized_text.rb
90
+ - lib/ims/lti/models/lti_model.rb
91
+ - lib/ims/lti/models/message_handler.rb
92
+ - lib/ims/lti/models/messages.rb
93
+ - lib/ims/lti/models/messages/basic_lti_launch_request.rb
94
+ - lib/ims/lti/models/messages/message.rb
95
+ - lib/ims/lti/models/messages/registration_request.rb
96
+ - lib/ims/lti/models/parameter.rb
97
+ - lib/ims/lti/models/product_family.rb
98
+ - lib/ims/lti/models/product_info.rb
99
+ - lib/ims/lti/models/product_instance.rb
100
+ - lib/ims/lti/models/resource_handler.rb
101
+ - lib/ims/lti/models/resource_type.rb
102
+ - lib/ims/lti/models/rest_service.rb
103
+ - lib/ims/lti/models/rest_service_profile.rb
104
+ - lib/ims/lti/models/security_contract.rb
105
+ - lib/ims/lti/models/service_owner.rb
106
+ - lib/ims/lti/models/service_provider.rb
107
+ - lib/ims/lti/models/tool_consumer_profile.rb
108
+ - lib/ims/lti/models/tool_profile.rb
109
+ - lib/ims/lti/models/tool_proxy.rb
110
+ - lib/ims/lti/models/vendor.rb
111
+ - lib/ims/lti/services.rb
112
+ - lib/ims/lti/services/message_service.rb
113
+ - lib/ims/lti/version.rb
99
114
  homepage: http://github.com/instructure/ims-lti
100
115
  licenses:
101
116
  - MIT
@@ -111,11 +126,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
126
  version: '0'
112
127
  required_rubygems_version: !ruby/object:Gem::Requirement
113
128
  requirements:
114
- - - ">="
129
+ - - ">"
115
130
  - !ruby/object:Gem::Version
116
- version: '0'
131
+ version: 1.3.1
117
132
  requirements: []
118
- rubygems_version: 3.1.2
133
+ rubyforge_project:
134
+ rubygems_version: 2.2.2
119
135
  signing_key:
120
136
  specification_version: 4
121
137
  summary: Ruby library for creating IMS LTI tool providers and consumers