mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Merge commit '0226bbe5165a53658b29e46ddbef6a10507fdc8c' into glitch-soc/merge-upstream
This commit is contained in:
@@ -12,24 +12,6 @@ policy = ContentSecurityPolicy.new
|
||||
assets_host = policy.assets_host
|
||||
media_hosts = policy.media_hosts
|
||||
|
||||
def sso_host
|
||||
return unless ENV['ONE_CLICK_SSO_LOGIN'] == 'true'
|
||||
return unless ENV['OMNIAUTH_ONLY'] == 'true'
|
||||
return unless Devise.omniauth_providers.length == 1
|
||||
|
||||
provider = Devise.omniauth_configs[Devise.omniauth_providers[0]]
|
||||
@sso_host ||= begin
|
||||
case provider.provider
|
||||
when :cas
|
||||
provider.cas_url
|
||||
when :saml
|
||||
provider.options[:idp_sso_target_url]
|
||||
when :openid_connect
|
||||
provider.options.dig(:client_options, :authorization_endpoint) || OpenIDConnect::Discovery::Provider::Config.discover!(provider.options[:issuer]).authorization_endpoint
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Rails.application.config.content_security_policy do |p|
|
||||
p.base_uri :none
|
||||
p.default_src :none
|
||||
@@ -40,8 +22,8 @@ Rails.application.config.content_security_policy do |p|
|
||||
p.media_src :self, :data, *media_hosts
|
||||
p.manifest_src :self, assets_host
|
||||
|
||||
if sso_host.present?
|
||||
p.form_action :self, sso_host
|
||||
if policy.sso_host.present?
|
||||
p.form_action :self, policy.sso_host
|
||||
else
|
||||
p.form_action :self
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user