-
Notifications
You must be signed in to change notification settings - Fork 684
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
EnsureBilling and EnsureAuthenticatedLinks works with token exchange #1833
Changes from 8 commits
470164a
841857f
bdf4b23
7b45c70
3b912ac
53b9c8b
cf5f209
0aef12b
9d0123c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,13 +79,6 @@ def signal_access_token_required | |
response.set_header(ACCESS_TOKEN_REQUIRED_HEADER, "true") | ||
end | ||
|
||
def jwt_expire_at | ||
expire_at = request.env["jwt.expire_at"] | ||
return unless expire_at | ||
|
||
expire_at - 5.seconds # 5s gap to start fetching new token in advance | ||
end | ||
Comment on lines
-82
to
-87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extracted these 'jwt' helpers to be inside |
||
|
||
def add_top_level_redirection_headers(url: nil, ignore_response_code: false) | ||
if request.xhr? && (ignore_response_code || response.code.to_i == 401) | ||
ShopifyApp::Logger.debug("Adding top level redirection headers") | ||
|
@@ -104,21 +97,12 @@ def add_top_level_redirection_headers(url: nil, ignore_response_code: false) | |
url ||= login_url_with_optional_shop | ||
|
||
ShopifyApp::Logger.debug("Setting Reauthorize-Url to #{url}") | ||
response.set_header("X-Shopify-API-Request-Failure-Reauthorize", "1") | ||
response.set_header("X-Shopify-API-Request-Failure-Reauthorize-Url", url) | ||
RedirectForEmbedded.add_app_bridge_redirect_url_header(url, response) | ||
end | ||
end | ||
|
||
protected | ||
|
||
def jwt_shopify_domain | ||
request.env["jwt.shopify_domain"] | ||
end | ||
|
||
def jwt_shopify_user_id | ||
request.env["jwt.shopify_user_id"] | ||
end | ||
Comment on lines
-114
to
-120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extracted these 'jwt' helpers to be inside |
||
|
||
def host | ||
params[:host] | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing an infinite redirect loop in auth code flow because the
shop
param gets added to the login path, andCallbackController
would re-check billing on auto login with theshop
param..Changing the logic to redirect to login page without
shop
param.