Skip to content

Commit

Permalink
Fix cookie samesite issue for LTI 1.3 deep linking
Browse files Browse the repository at this point in the history
LTI 1.3 deep linking don't seem to be working in latest Chrome. Seemingly this is due to because SameSite property of session and CSRF token cookies are not set to None to allow cross-site. Even though the deep link selection iframe ends up at same domain (Canvas) it's navigated to through the tool domain which effectively makes it cross-site.

Closes instructuregh-1900

Test plan:
- Test LTI 1.3 deep linking with an external tool
- Test compatibility with different browsers (new browsers supporting SameSite: None and browsers not supporting)
- Investigate any undesired security implications this change might have
  • Loading branch information
jbergfi committed Sep 19, 2022
1 parent 6310840 commit 0e172b1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def masked_authenticity_token(cookies, options = {})
encoded_masked_token = masked_token(unmasked_token(cookies["_csrf_token"]))

cookie = { value: encoded_masked_token }
%i[domain httponly secure].each do |key|
%i[domain httponly secure same_site].each do |key|
next unless options.key?(key)

cookie[key] = options[key]
Expand Down
3 changes: 2 additions & 1 deletion gems/request_context/lib/request_context/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def call(env)
ActionDispatch::Request.new(env).cookie_jar[:log_session_id] = {
value: session_id,
secure: Rails.application.config.session_options[:secure],
httponly: true
httponly: true,
same_site: Rails.application.config.session_options[:same_site]
}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/canvas/request_forgery_protection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def verified_request?

def authenticity_token_options
session_options = CanvasRails::Application.config.session_options
options = session_options.slice(:domain, :secure)
options = session_options.slice(:domain, :secure, :same_site)
options[:httponly] = HostUrl.is_file_host?(request.host_with_port)
options
end
Expand Down

0 comments on commit 0e172b1

Please sign in to comment.