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

fix: possible panic if refresh token has a null session_id #1822

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

kangmingtay
Copy link
Member

What kind of change does this PR introduce?

  • Prior to the auth.sessions table being created, some refresh tokens can contain a null session_id. In those cases, attempting to use those refresh tokens to obtain a new session will result in a panic.
  • This PR creates a new session for those refresh tokens that do not have a session_id to prevent panics from happening.

What is the current behavior?

Please link any relevant issues here.

What is the new behavior?

Feel free to include screenshots if it includes visual changes.

Additional context

Add any other context or screenshots.

@kangmingtay kangmingtay requested a review from a team as a code owner October 29, 2024 11:01
Copy link
Contributor

@hf hf left a comment

Choose a reason for hiding this comment

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

Seems harmless.

@coveralls
Copy link

coveralls commented Oct 29, 2024

Pull Request Test Coverage Report for Build 11592000983

Details

  • 8 of 13 (61.54%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 57.143%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/api/token_refresh.go 8 13 61.54%
Totals Coverage Status
Change from base Build 11555996021: -0.02%
Covered Lines: 9564
Relevant Lines: 16737

💛 - Coveralls

Copy link
Contributor

@cstockton cstockton left a comment

Choose a reason for hiding this comment

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

Looking at the refresh token code and associated calls I think we should take some more time to consider this change.

@kangmingtay kangmingtay requested a review from cstockton October 30, 2024 11:10
@kangmingtay
Copy link
Member Author

we don't need to do the same check here because it's using forUpdate = true - the intention in this block is to retry accessing the refresh_tokens or sessions table after some time because the FOR UPDATE lock is being held by another transaction so it's acceptable for the session to not be found here

@cstockton
Copy link
Contributor

👍

@kangmingtay kangmingtay merged commit a7129df into master Oct 30, 2024
2 checks passed
@kangmingtay kangmingtay deleted the km/fix-panic-refresh-token branch October 30, 2024 14:29
J0 pushed a commit that referenced this pull request Nov 15, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.164.0](v2.163.2...v2.164.0)
(2024-11-13)


### Features

* return validation failed error if captcha request was not json
([#1815](#1815))
([26d2e36](26d2e36))


### Bug Fixes

* add error codes to refresh token flow
([#1824](#1824))
([4614dc5](4614dc5))
* add test coverage for rate limits with 0 permitted events
([#1834](#1834))
([7c3cf26](7c3cf26))
* correct web authn aaguid column naming
([#1826](#1826))
([0a589d0](0a589d0))
* default to files:read scope for Figma provider
([#1831](#1831))
([9ce2857](9ce2857))
* improve error messaging for http hooks
([#1821](#1821))
([fa020d0](fa020d0))
* make drop_uniqueness_constraint_on_phone idempotent
([#1817](#1817))
([158e473](158e473))
* possible panic if refresh token has a null session_id
([#1822](#1822))
([a7129df](a7129df))
* rate limits of 0 take precedence over MAILER_AUTO_CONFIRM
([#1837](#1837))
([cb7894e](cb7894e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

4 participants