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

Add new SessionUtil method to retrieve current session Id from Shopify ID token #1314

Merged
merged 5 commits into from
Apr 18, 2024

Conversation

zzooeeyy
Copy link
Contributor

@zzooeeyy zzooeeyy commented Apr 17, 2024

Description

Please, include a summary of what the PR is for:

  • What is the problem it is solving?
    • current_session_id expects an "auth_header" that has format - Bearer id_token, extracted the logic to retrieve the current session ID from just id_token for supporting id token in URL param
    • Added tests for SessionUtils that didn't exist before

Impact

  • Existing apps using current_session_id will not be affected, behaviour remained the same.

How has this been tested?

  • Unit tested and it still passes

Checklist:

  • My commit message follow the pattern described in here
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the project documentation.
  • I have added a changelog line.

@zzooeeyy zzooeeyy marked this pull request as ready for review April 17, 2024 21:11
@zzooeeyy zzooeeyy requested a review from a team as a code owner April 17, 2024 21:11
Copy link
Contributor

@paulomarg paulomarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a general question, but I don't think it needs to block this.

lib/shopify_api/utils/session_utils.rb Show resolved Hide resolved
test/utils/session_utils_test.rb Show resolved Hide resolved
Copy link
Contributor

@rachel-carvalho rachel-carvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I just think it would be nice to have that extra test coverage.


assert_equal(
expected_session_id,
ShopifyAPI::Utils::SessionUtils.current_session_id(@auth_header, nil, false),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not new code we added in this PR, but can we expect to raise the missing JWT error when a valid token is present in the header but doesn't follow the Bearer {token} format?

Copy link
Contributor

@paulomarg paulomarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

test/utils/session_utils_test.rb Show resolved Hide resolved
@zzooeeyy zzooeeyy merged commit eaaa96d into main Apr 18, 2024
11 checks passed
@zzooeeyy zzooeeyy deleted the support-id-token branch April 18, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants