Skip to content

Commit

Permalink
Improve embedded requests detection with Sec-Fetch-Dest header
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillplatonov committed Jul 4, 2024
1 parent c625c3b commit 490b689
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 490b689

Please sign in to comment.