atomic_lti 3.1.0 → 4.1.0
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.
- checksums.yaml +4 -4
- data/app/lib/atomic_lti/definitions.rb +4 -1
- data/app/lib/atomic_lti/exceptions.rb +12 -0
- data/app/lib/atomic_lti/services/base.rb +20 -0
- data/app/lib/atomic_lti/services/line_items.rb +1 -1
- data/app/lib/atomic_lti/services/names_and_roles.rb +10 -3
- data/app/lib/atomic_lti/services/platform_notifications.rb +2 -2
- data/app/lib/atomic_lti/services/results.rb +1 -1
- data/lib/atomic_lti/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 85bbb3f09349a238fe07e1f664477114dbff5d9deaec5cff86f4b63c57514294
|
|
4
|
+
data.tar.gz: f73553255553793b3e63428f49d6cb4bb174407f9b0c3be86cecde079ec28561
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16dc2fd29958db745053c69f4be435c05bad81fba8e5245154c0d072f181bf73ee98c758531fd09cb54ac995fe727e31ecc10b1cc320f2812ff5bc1f9fb1ba13
|
|
7
|
+
data.tar.gz: 9bef5be2085d8018ea5f98ac80a179f50fd2d750045fc33a214568d43fd073bf26a0d6eb74c7824dab24646638180055cd1bd71c2f4ded6fe82495b8d556524a
|
|
@@ -33,7 +33,7 @@ module AtomicLti
|
|
|
33
33
|
|
|
34
34
|
PLATFORM_NOTIFICATION_SERVICE_CLAIM = "https://purl.imsglobal.org/spec/lti/claim/platformnotificationservice".freeze
|
|
35
35
|
PLATFORM_NOTIFICATION_SERVICE_VERSIONS = ["1.0".freeze].freeze
|
|
36
|
-
|
|
36
|
+
NOTICE_CLAIM = "https://purl.imsglobal.org/spec/lti/claim/notice".freeze
|
|
37
37
|
PLATFORM_NOTIFICATION_CONTEXT_COPY_NOTICE = "LtiContextCopyNotice".freeze
|
|
38
38
|
PLATFORM_NOTIFICATION_CONTEXT_COPY_ORIGINS_CLAIM = "https://purl.imsglobal.org/spec/lti/claim/origin_contexts".freeze
|
|
39
39
|
|
|
@@ -122,6 +122,8 @@ module AtomicLti
|
|
|
122
122
|
MANAGER_CONTEXT_ROLE = "http://purl.imsglobal.org/vocab/lis/v2/membership#Manager".freeze
|
|
123
123
|
MEMBER_CONTEXT_ROLE = "http://purl.imsglobal.org/vocab/lis/v2/membership#Member".freeze
|
|
124
124
|
OFFICER_CONTEXT_ROLE = "http://purl.imsglobal.org/vocab/lis/v2/membership#Officer".freeze
|
|
125
|
+
## Context sub-roles
|
|
126
|
+
INSTRUCTOR_TEACHING_ASSISTANT_CONTEXT_ROLE = "http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistant".freeze
|
|
125
127
|
|
|
126
128
|
ROLES = [
|
|
127
129
|
ADMINISTRATOR_SYSTEM_ROLE,
|
|
@@ -153,6 +155,7 @@ module AtomicLti
|
|
|
153
155
|
MANAGER_CONTEXT_ROLE,
|
|
154
156
|
MEMBER_CONTEXT_ROLE,
|
|
155
157
|
OFFICER_CONTEXT_ROLE,
|
|
158
|
+
INSTRUCTOR_TEACHING_ASSISTANT_CONTEXT_ROLE,
|
|
156
159
|
].freeze
|
|
157
160
|
|
|
158
161
|
ADMINISTRATOR_ROLES = [
|
|
@@ -101,6 +101,18 @@ module AtomicLti
|
|
|
101
101
|
class PaginationLimitExceeded < AtomicLtiException
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
+
# The platform answered a service request with an error status or a body
|
|
105
|
+
# that is not JSON (Canvas sends an HTML page for some refusals).
|
|
106
|
+
class ServiceResponseError < AtomicLtiException
|
|
107
|
+
attr_reader :status, :body
|
|
108
|
+
|
|
109
|
+
def initialize(msg = nil, status: nil, body: nil)
|
|
110
|
+
@status = status
|
|
111
|
+
@body = body
|
|
112
|
+
super(msg || "LTI service request failed with status #{status}")
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
104
116
|
class InvalidPlatformNotification < AtomicLtiException; end
|
|
105
117
|
end
|
|
106
118
|
end
|
|
@@ -30,6 +30,26 @@ module AtomicLti
|
|
|
30
30
|
next_url
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
# Parses one page of a list request, raising ServiceResponseError when
|
|
34
|
+
# the platform refused the request or did not answer with JSON.
|
|
35
|
+
def parse_list_page(response)
|
|
36
|
+
if !response.success?
|
|
37
|
+
raise AtomicLti::Exceptions::ServiceResponseError.new(
|
|
38
|
+
status: response.code,
|
|
39
|
+
body: response.body,
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# A bodyless response (such as a 204) has a nil body
|
|
44
|
+
JSON.parse(response.body.to_s)
|
|
45
|
+
rescue JSON::ParserError
|
|
46
|
+
raise AtomicLti::Exceptions::ServiceResponseError.new(
|
|
47
|
+
"LTI service response was not valid JSON (status #{response.code})",
|
|
48
|
+
status: response.code,
|
|
49
|
+
body: response.body,
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
33
53
|
def service_get(*args)
|
|
34
54
|
logged_service_call(:get, *args)
|
|
35
55
|
end
|
|
@@ -81,7 +81,7 @@ module AtomicLti
|
|
|
81
81
|
def list_all(query = {})
|
|
82
82
|
AtomicLti::PagingHelper.paginate_request do |next_link|
|
|
83
83
|
result_page = list(query, page_url: next_link)
|
|
84
|
-
[
|
|
84
|
+
[parse_list_page(result_page), get_next_url(result_page)]
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -66,7 +66,7 @@ module AtomicLti
|
|
|
66
66
|
|
|
67
67
|
members = AtomicLti::PagingHelper.paginate_request do |next_link|
|
|
68
68
|
result_page = list(query: query, page_url: next_link)
|
|
69
|
-
page_body =
|
|
69
|
+
page_body = parse_list_page(result_page)
|
|
70
70
|
[page_body["members"], get_next_url(result_page)]
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -75,8 +75,15 @@ module AtomicLti
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
def verify_received_user_names(names_and_roles_memberships)
|
|
78
|
-
if names_and_roles_memberships&.body.present?
|
|
79
|
-
members =
|
|
78
|
+
if names_and_roles_memberships&.success? && names_and_roles_memberships.body.present?
|
|
79
|
+
members = begin
|
|
80
|
+
JSON.parse(names_and_roles_memberships.body)["members"]
|
|
81
|
+
rescue JSON::ParserError => e
|
|
82
|
+
# The body itself is logged by logged_service_call, and list_all
|
|
83
|
+
# raises ServiceResponseError for it
|
|
84
|
+
Rails.logger.warn("Skipped the Names and Roles private key check: the response was not JSON (#{e.message})")
|
|
85
|
+
nil
|
|
86
|
+
end
|
|
80
87
|
if members.present? && members.all? { |member| member["name"].nil? }
|
|
81
88
|
raise(
|
|
82
89
|
AtomicLti::Exceptions::NamesAndRolesError,
|
|
@@ -77,9 +77,9 @@ module AtomicLti
|
|
|
77
77
|
)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
if decoded_token[AtomicLti::Definitions::
|
|
80
|
+
if decoded_token[AtomicLti::Definitions::NOTICE_CLAIM].blank?
|
|
81
81
|
errors.push(
|
|
82
|
-
"LTI token is missing required claim #{AtomicLti::Definitions::
|
|
82
|
+
"LTI token is missing required claim #{AtomicLti::Definitions::NOTICE_CLAIM}",
|
|
83
83
|
)
|
|
84
84
|
end
|
|
85
85
|
|
|
@@ -25,7 +25,7 @@ module AtomicLti
|
|
|
25
25
|
def list_all(line_item_id, query: {})
|
|
26
26
|
AtomicLti::PagingHelper.paginate_request do |next_link|
|
|
27
27
|
result_page = list(line_item_id, query: query, page_url: next_link)
|
|
28
|
-
[
|
|
28
|
+
[parse_list_page(result_page), get_next_url(result_page)]
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
data/lib/atomic_lti/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: atomic_lti
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Petro
|
|
8
8
|
- Justin Ball
|
|
9
9
|
- Nick Benoit
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: pg
|
|
@@ -139,7 +138,6 @@ licenses:
|
|
|
139
138
|
metadata:
|
|
140
139
|
homepage_uri: https://github.com/atomicjolt/atomic_lti
|
|
141
140
|
source_code_uri: https://github.com/atomicjolt/atomic_lti
|
|
142
|
-
post_install_message:
|
|
143
141
|
rdoc_options: []
|
|
144
142
|
require_paths:
|
|
145
143
|
- lib
|
|
@@ -154,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
154
152
|
- !ruby/object:Gem::Version
|
|
155
153
|
version: '0'
|
|
156
154
|
requirements: []
|
|
157
|
-
rubygems_version:
|
|
158
|
-
signing_key:
|
|
155
|
+
rubygems_version: 4.0.20
|
|
159
156
|
specification_version: 4
|
|
160
157
|
summary: AtomicLti implements the LTI Advantage specification.
|
|
161
158
|
test_files: []
|