Skip to content
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

Disable session in ActiveStorage blobs and representations proxy controllers #48869

Merged
merged 2 commits into from Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions activestorage/CHANGELOG.md
@@ -1,3 +1,11 @@
* Disables the session in `ActiveStorage::Blobs::ProxyController`
and `ActiveStorage::Representations::ProxyController`
in order to allow caching by default in some CDNs as CloudFlare

Fixes #44136

*Bruno Prieto*

* Add `tags` to `ActiveStorage::Analyzer::AudioAnalyzer` output

*Keaton Roux*
Expand Down
Expand Up @@ -9,6 +9,7 @@
class ActiveStorage::Blobs::ProxyController < ActiveStorage::BaseController
include ActiveStorage::SetBlob
include ActiveStorage::Streaming
include ActiveStorage::DisableSession

def show
if request.headers["Range"].present?
Expand Down
Expand Up @@ -8,6 +8,7 @@
# {Authenticated Controllers}[https://guides.rubyonrails.org/active_storage_overview.html#authenticated-controllers].
class ActiveStorage::Representations::ProxyController < ActiveStorage::Representations::BaseController
include ActiveStorage::Streaming
include ActiveStorage::DisableSession

def show
http_cache_forever public: true do
Expand Down
@@ -0,0 +1,12 @@
# frozen_string_literal: true

# This concern disables the session in order to allow caching by default in some CDNs as CloudFlare.
module ActiveStorage::DisableSession
extend ActiveSupport::Concern

included do
before_action do
request.session_options[:skip] = true
end
end
end