-
Notifications
You must be signed in to change notification settings - Fork 20
Cross-space authentication #1242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9d30ef1
06f9507
210dad5
29b0bb3
4db69de
e02fae1
317c649
1ef62e3
7710bdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| module SpaceRedirect | ||
| extend ActiveSupport::Concern | ||
|
|
||
| private | ||
|
|
||
| def redirect_to_space(path, space) | ||
| if space&.is_subdomain? | ||
| port_part = '' | ||
| port_part = ":#{request.port}" if (request.protocol == "http://" && request.port != 80) || | ||
| (request.protocol == "https://" && request.port != 443) | ||
| redirect_to URI.join("#{request.protocol}#{space.host}#{port_part}", path).to_s, allow_other_host: true | ||
| else | ||
| redirect_to path | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| class TessDevise::SessionsController < Devise::SessionsController | ||
|
|
||
| def create | ||
| clear_legacy_cookie | ||
|
|
||
| super | ||
| end | ||
|
|
||
| def destroy | ||
| super | ||
|
|
||
| clear_legacy_cookie | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def clear_legacy_cookie | ||
| # Clean up legacy host-only session cookie | ||
| key = Rails.application.config.session_options[:key] | ||
| append_set_cookie("#{key}=; path=/; Max-Age=0; HttpOnly; SameSite=Lax") | ||
| end | ||
|
|
||
| def append_set_cookie(value) | ||
| existing = response.headers['Set-Cookie'] | ||
|
|
||
| case existing | ||
| when nil | ||
| response.headers['Set-Cookie'] = value | ||
| when String | ||
| response.headers['Set-Cookie'] = [existing, value] | ||
| when Array | ||
| existing << value | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,10 @@ | ||||||||||||||||||||||||||||||||
| # Be sure to restart your server when you modify this file. | ||||||||||||||||||||||||||||||||
| opts = {} | ||||||||||||||||||||||||||||||||
| opts = { | ||||||||||||||||||||||||||||||||
| domain: :all | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
Comment on lines
+2
to
5
|
||||||||||||||||||||||||||||||||
| opts = { | |
| domain: :all | |
| } | |
| opts = {} | |
| if defined?(TeSS::Config) && TeSS::Config.respond_to?(:base_uri) && TeSS::Config.base_uri | |
| base_uri = TeSS::Config.base_uri | |
| cookie_domain = | |
| if base_uri.respond_to?(:domain) | |
| base_uri.domain | |
| elsif base_uri.respond_to?(:host) | |
| base_uri.host | |
| end | |
| opts[:domain] = cookie_domain if cookie_domain.present? | |
| end |
Uh oh!
There was an error while loading. Please reload this page.