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

handlers: do not fail login if refresh token gone #1670

Merged
merged 1 commit into from
Mar 19, 2020

Conversation

klarose
Copy link
Contributor

@klarose klarose commented Mar 13, 2020

There is a chance that offline storage could fall out of sync with the
refresh token tables. One example is if dex crashes/is stopped in the
middle of handling a login request. If the old refresh token associated
with the offline session is deleted, and then the process stops, the
offline session will still refer to the old token.

Unfortunately, if this case occurs, there is no way to recover from it,
since further logins will be halted due to dex being unable to clean up
the old tokens till referenced in the offline session: the database is
essentially corrupted.

There doesn't seem to be a good reason to fail the auth request if the
old refresh token is gone. This changes the logic in handleAuthCode to
not fail the entire transaction if the old refresh token could not be
deleted because it was not present. This has the effect of installing
the new refresh token, and updating the offline storage, thereby fixing
the issue, however it occurred.

Fixes #1669

@klarose
Copy link
Contributor Author

klarose commented Mar 13, 2020

It looks like the CI may have failed for an unrelated reason. Is there an easy way to retry it?

@bonifaido
Copy link
Member

Please rebase on master, so the CI issue can get resolved.

@bonifaido bonifaido self-assigned this Mar 18, 2020
@bonifaido bonifaido self-requested a review March 18, 2020 14:21
@swade1987
Copy link

It would be great to get this merged as its impacting us as well cc @willvrny

There is a chance that offline storage could fall out of sync with the
refresh token tables. One example is if dex crashes/is stopped in the
middle of handling a login request. If the old refresh token associated
with the offline session is deleted, and then the process stops, the
offline session will still refer to the old token.

Unfortunately, if this case occurs, there is no way to recover from it,
since further logins will be halted due to dex being unable to clean up
the old tokens till referenced in the offline session: the database is
essentially corrupted.

There doesn't seem to be a good reason to fail the auth request if the
old refresh token is gone. This changes the logic in `handleAuthCode` to
not fail the entire transaction if the old refresh token could not be
deleted because it was not present. This has the effect of installing
the new refresh token, and unpdating the offline storage, thereby fixing
the issue, however it occured.
@klarose
Copy link
Contributor Author

klarose commented Mar 18, 2020

@bonifaido Rebased, but it looks like the lint timed out this time. :(

@bonifaido
Copy link
Member

Build is fixed now! :)

Copy link
Member

@bonifaido bonifaido left a comment

Choose a reason for hiding this comment

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

Simple and great. LGTM, thanks!

@bonifaido bonifaido merged commit 741bf02 into dexidp:master Mar 19, 2020
@swade1987
Copy link

@bonifaido any idea when a release with this will be cut?

@bonifaido
Copy link
Member

No planned released for now, but there are some fixes hanging around here, we will review a few and I will cut a patch release. Until that: https://quay.io/repository/dexidp/dex/manifest/sha256:2f5af70a79eae505d122ac40f684cff29fabda434f5fefeb49c0d888323a545d

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.

Offline workflows can get into a bad state: failed to delete refresh token
3 participants