-
Notifications
You must be signed in to change notification settings - Fork 699
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
Ensure post authenticate jobs run after for jwt based callback requests #1079
Conversation
No test for the |
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.
LGTM.
This is easier to read than the previous implementation, which is good! Curious why you decided to refactor in this direction where every sub-method contains a conditional on JWT vs. splitting into two callback methods for JWT vs. normal browser? There's very little overlap other than persisting the token and running these callbacks.
if jwt_request? | ||
Rails.logger.debug("[ShopifyApp::CallbackController] JWT request detected. Setting shopify session...") |
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.
Are we intentionally not replacing the debug logs?
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.
Just added the logs back
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.
LGTM!
install_scripttags | ||
perform_after_authenticate_job | ||
def store_access_token_and_build_session | ||
prevent_session_fixation if native_browser_request? |
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.
Do we need to check native_browser_request?
here, if it's also checked in prevent_session_fixation
?
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.
You're right! Just refactored it.
We had thought of splitting it into two but there seems to be a general pattern of processing the callback where we are doing the following:
The only difference is that the other flow returns early when needing to get an online (user) token. So we had to leave the extra conditional. Also the reason why we have conditional splits between JWT and non-JWT is so that there is symmetry in where they diverge and that it's easier to see the boundaries for further refactoring in the future. |
91485f5
to
ebcdf65
Compare
Nice catch! Just added :) |
What does this PR solve?
There is an issue noticed where the OAuth flow for getting an online (user) token fails to redirect back into the callback endpoint. The online token is eventually retrieved on failed requests to the Shopify API and we exchange an auth code for the online token via App Bridge Auth. However, when making the callback request to with session tokens (as JWTs) in the Authorization header, the post authenticate background jobs are not run, which is undesirable.
This PR ensures that the post authenticated background jobs are triggered after the callback request is made with session tokens in the request.
Before submitting the PR, please consider if any of the following are needed:
CHANGELOG.md
if the changes would impact usersREADME.md
, if appropriate.docs/
, if necessary