strongmind-auth 1.1.118 → 1.1.120
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/controllers/concerns/lti_session_authable.rb +110 -0
- data/lib/strongmind/auth/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28d6ddf754fb03e4b36677e255582bd7c6992b6b48560fd9e1474cda2f268b81
|
4
|
+
data.tar.gz: ddcd7b9d40afd434033c8b83577bcf13711781c9f35d91ac56ae70fe07f9463a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe113a581909a450742f5fec3ca6ece0fa784366d767ede6f2c3a5e48a4f431b736e909146779584b5fb17e6392f3339856f5b13f0837c98534927bfd181c9f2
|
7
|
+
data.tar.gz: 39ec8cf8ec393187735fce6979371ef773fad091304d52997fd3cbf3ae7d56ea7c997f0f72a6cf46081f70ca4d2a4cfa6c71708848a113b062dc4faab55fea15
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LtiSessionAuthable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
SESSION_HEADER_NAME = 'HTTP_LTI_SESSION_ID'
|
7
|
+
UNAUTHORIZED_MESSAGE = 'Session not found. Please refresh the page.'
|
8
|
+
|
9
|
+
def initialize_lti_session
|
10
|
+
@lti_session_id = SecureRandom.uuid
|
11
|
+
initialize_lti_parameters
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize_lti_parameters
|
15
|
+
@lti_context_id = fetch_param('context_id')
|
16
|
+
@lti_context_title = fetch_param('context_title')
|
17
|
+
@lti_resource_link_title = fetch_param('resource_link_title')
|
18
|
+
@lti_consumer_key = fetch_param('oauth_consumer_key')
|
19
|
+
@lti_user_email = fetch_param('lis_person_contact_email_primary')
|
20
|
+
@lti_custom_canvas_api_domain = fetch_param('custom_canvas_api_domain')
|
21
|
+
@lti_custom_canvas_course_id = fetch_param('custom_canvas_course_id')
|
22
|
+
@lti_custom_canvas_user_id = fetch_param('custom_canvas_user_id')
|
23
|
+
@lis_person_name_given = fetch_param('lis_person_name_given')
|
24
|
+
@lis_person_name_family = fetch_param('lis_person_name_family')
|
25
|
+
@user_ext_roles = fetch_param('ext_roles')
|
26
|
+
end
|
27
|
+
|
28
|
+
def fetch_param(key)
|
29
|
+
request.parameters[key]
|
30
|
+
end
|
31
|
+
|
32
|
+
def write_session_to_cache
|
33
|
+
Rails.cache.write(@lti_session_id, {
|
34
|
+
context_id: @lti_context_id,
|
35
|
+
context_title: @lti_context_title,
|
36
|
+
resource_link_title: @lti_resource_link_title,
|
37
|
+
consumer_key: @lti_consumer_key,
|
38
|
+
user_email: @lti_user_email,
|
39
|
+
custom_canvas_api_domain: @lti_custom_canvas_api_domain,
|
40
|
+
custom_canvas_course_id: @lti_custom_canvas_course_id,
|
41
|
+
custom_canvas_user_id: @lti_custom_canvas_user_id,
|
42
|
+
user_first_name: @lis_person_name_given,
|
43
|
+
user_last_name: @lis_person_name_family,
|
44
|
+
user_ext_roles: @user_ext_roles
|
45
|
+
}, expires_in: 12.hours)
|
46
|
+
end
|
47
|
+
|
48
|
+
def lti_session_id
|
49
|
+
request.headers[SESSION_HEADER_NAME] || params[:lti_session_id]
|
50
|
+
end
|
51
|
+
|
52
|
+
def validate_session
|
53
|
+
@lti_session_id = lti_session_id
|
54
|
+
unauthorized_response and return unless @lti_session_id.present?
|
55
|
+
|
56
|
+
@lti_session = Rails.cache.read(@lti_session_id)
|
57
|
+
|
58
|
+
handle_existing_session
|
59
|
+
rotate_session_if_needed
|
60
|
+
unauthorized_response if @lti_session.nil?
|
61
|
+
end
|
62
|
+
|
63
|
+
def handle_existing_session
|
64
|
+
read_session unless @lti_session.nil?
|
65
|
+
end
|
66
|
+
|
67
|
+
def unauthorized_response
|
68
|
+
render plain: UNAUTHORIZED_MESSAGE, status: :unauthorized
|
69
|
+
end
|
70
|
+
|
71
|
+
def rotate_session_if_needed
|
72
|
+
return if params[:dont_rotate_session]
|
73
|
+
return if request.method == 'POST'
|
74
|
+
|
75
|
+
@old_session_id = @lti_session_id
|
76
|
+
@lti_session_id = SecureRandom.uuid
|
77
|
+
end
|
78
|
+
|
79
|
+
def read_session
|
80
|
+
@lti_context_id = @lti_session[:context_id]
|
81
|
+
@lti_context_title = @lti_session[:context_title]
|
82
|
+
@lti_resource_link_title = @lti_session[:resource_link_title]
|
83
|
+
@lti_consumer_key = @lti_session[:consumer_key]
|
84
|
+
@lti_custom_canvas_api_domain = @lti_session[:custom_canvas_api_domain]
|
85
|
+
@lti_custom_canvas_course_id = @lti_session[:custom_canvas_course_id]
|
86
|
+
@lti_custom_canvas_user_id = @lti_session[:custom_canvas_user_id]
|
87
|
+
@lti_user_email = @lti_session[:user_email]
|
88
|
+
@lis_person_name_given = @lti_session[:user_first_name]
|
89
|
+
@lis_person_name_family = @lti_session[:user_last_name]
|
90
|
+
@user_ext_roles = @lti_session[:user_ext_roles]
|
91
|
+
end
|
92
|
+
|
93
|
+
def rotate_session_id
|
94
|
+
return unless @old_session_id
|
95
|
+
|
96
|
+
write_session_to_cache
|
97
|
+
Rails.cache.delete(@old_session_id)
|
98
|
+
end
|
99
|
+
|
100
|
+
def lti_launch_validator
|
101
|
+
@lti_launch_validator ||= LtiLaunchValidator.new(request)
|
102
|
+
end
|
103
|
+
|
104
|
+
def validate_lti_launch
|
105
|
+
raise RequestNotFoundError unless request.is_a? ActionDispatch::Request
|
106
|
+
|
107
|
+
head(:unauthorized) unless lti_launch_validator.is_valid?
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strongmind-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.120
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Belding
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- app/assets/config/strongmind_auth_manifest.js
|
107
107
|
- app/assets/stylesheets/strongmind/auth/application.css
|
108
108
|
- app/controllers/concerns/jwt_utilities.rb
|
109
|
+
- app/controllers/concerns/lti_session_authable.rb
|
109
110
|
- app/controllers/concerns/strong_mind_nav.rb
|
110
111
|
- app/controllers/logins_controller.rb
|
111
112
|
- app/controllers/users/omniauth_callbacks_controller.rb
|
@@ -137,7 +138,7 @@ licenses:
|
|
137
138
|
metadata:
|
138
139
|
homepage_uri: https://www.strongmind.com
|
139
140
|
source_code_uri: https://github.com/StrongMind/rails-auth
|
140
|
-
post_install_message:
|
141
|
+
post_install_message:
|
141
142
|
rdoc_options: []
|
142
143
|
require_paths:
|
143
144
|
- lib
|
@@ -153,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
154
|
version: '0'
|
154
155
|
requirements: []
|
155
156
|
rubygems_version: 3.4.10
|
156
|
-
signing_key:
|
157
|
+
signing_key:
|
157
158
|
specification_version: 4
|
158
159
|
summary: Ruby gem for StrongMind authentication in a strongmind app
|
159
160
|
test_files: []
|