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

Improve embedded requests detection with Sec-Fetch-Dest header #1873

Merged
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.
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
Expand Up @@ -8,6 +8,7 @@ Unreleased
- Keep original path and params when redirecting deep links to embed [#1869](https://github.com/Shopify/shopify_app/pull/1869)
- Fix managed install path for SPIN environments [#1877](https://github.com/Shopify/shopify_app/pull/1877)
- Migrate fullpage redirect to App Bridge CDN [#1870](https://github.com/Shopify/shopify_app/pull/1870)
- Improve embedded requests detection with `Sec-Fetch-Dest` header [#1873](https://github.com/Shopify/shopify_app/pull/1873)

22.2.1 (May 6,2024)
----------
Expand Down
10 changes: 5 additions & 5 deletions lib/shopify_app/controller_concerns/token_exchange.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ def respond_to_invalid_shopify_id_token(error)
return if performed?

if request.headers["HTTP_AUTHORIZATION"].blank?
if missing_embedded_param?
redirect_to_embed_app_in_admin
else
if embedded?
redirect_to_bounce_page
else
redirect_to_embed_app_in_admin
end
else
ShopifyApp::Logger.debug("Responding to invalid Shopify ID token with unauthorized response")
Expand All @@ -94,8 +94,8 @@ def redirect_to_bounce_page
)
end

def missing_embedded_param?
!params[:embedded].present? || params[:embedded] != "1"
def embedded?
params[:embedded] == "1" || request.env["HTTP_SEC_FETCH_DEST"] == "iframe"
end

def online_token_configured?
Expand Down
Loading