mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-14 00:08:14 +00:00

Some checks failed
Bundler Audit / security (push) Waiting to run
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Crowdin / Upload translations / upload-translations (push) Has been cancelled
60 lines
1.7 KiB
Ruby
60 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module WebAppControllerConcern
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
vary_by 'Accept, Accept-Language, Cookie'
|
|
|
|
before_action :redirect_unauthenticated_to_permalinks!
|
|
before_action :set_referer_header
|
|
before_action :redirect_to_tos_interstitial!
|
|
|
|
content_security_policy do |p|
|
|
policy = ContentSecurityPolicy.new
|
|
|
|
if policy.sso_host.present?
|
|
p.form_action policy.sso_host, -> { "https://#{request.host}/auth/auth/" }
|
|
else
|
|
p.form_action :none
|
|
end
|
|
end
|
|
end
|
|
|
|
def skip_csrf_meta_tags?
|
|
!(ENV['ONE_CLICK_SSO_LOGIN'] == 'true' && ENV['OMNIAUTH_ONLY'] == 'true' && Devise.omniauth_providers.length == 1) && current_user.nil?
|
|
end
|
|
|
|
def redirect_unauthenticated_to_permalinks!
|
|
return if user_signed_in? && current_account.moved_to_account_id.nil?
|
|
|
|
permalink_redirector = PermalinkRedirector.new(request.original_fullpath)
|
|
return if permalink_redirector.redirect_path.blank?
|
|
|
|
expires_in(15.seconds, public: true, stale_while_revalidate: 30.seconds, stale_if_error: 1.day) unless user_signed_in?
|
|
|
|
respond_to do |format|
|
|
format.html do
|
|
redirect_to(permalink_redirector.redirect_confirmation_path, allow_other_host: false)
|
|
end
|
|
|
|
format.json do
|
|
redirect_to(permalink_redirector.redirect_uri, allow_other_host: true)
|
|
end
|
|
end
|
|
end
|
|
|
|
protected
|
|
|
|
def redirect_to_tos_interstitial!
|
|
return unless current_user&.require_tos_interstitial?
|
|
|
|
@terms_of_service = TermsOfService.published.first
|
|
render 'terms_of_service_interstitial/show', layout: 'auth'
|
|
end
|
|
|
|
def set_referer_header
|
|
response.set_header('Referrer-Policy', Setting.allow_referrer_origin ? 'strict-origin-when-cross-origin' : 'same-origin')
|
|
end
|
|
end
|