Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Unreleased
----------
- [Patch] Fix sorbet errors in generated webhook handlers
- Deprecate `ShopifyApp.add_csp_directives(policy)` - will be removed in v24.0.0

23.0.1 (December 22, 2025)
- Fix engine initialization [#2040](https://github.com/Shopify/shopify_app/pull/2040)
Expand Down
2 changes: 2 additions & 0 deletions docs/shopify_app/content-security-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ For actions that include the `ShopifyApp::FrameAncestors` controller concern, th

## Strict Content Security Policy

> **Deprecated:** The `ShopifyApp.add_csp_directives` helper is deprecated and will be removed in v24.0.0.

If you enable a strict Content Security Policy in your application, you'll need to explicitly allow Shopify's App Bridge script. The gem provides a helper method to make this easy.

### Without Strict CSP (Default)
Expand Down
5 changes: 5 additions & 0 deletions lib/shopify_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ def self.use_webpacker?
end

def self.add_csp_directives(policy)
ShopifyApp::Logger.deprecated(
"ShopifyApp.add_csp_directives is deprecated and will be removed in v24.0.0.",
"24.0.0",
)

# Get current script-src directives
current_script_src = policy.directives["script-src"] || []

Expand Down
9 changes: 9 additions & 0 deletions test/shopify_app/csp_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ class CspHelperTest < ActiveSupport::TestCase
@policy = ActionDispatch::ContentSecurityPolicy.new
end

test "emits a deprecation warning" do
ShopifyApp::Logger.expects(:deprecated).with(
"ShopifyApp.add_csp_directives is deprecated and will be removed in v24.0.0.",
"24.0.0",
)

ShopifyApp.add_csp_directives(@policy)
end

test "adds App Bridge script source to empty policy" do
ShopifyApp.add_csp_directives(@policy)

Expand Down