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

authenticateflow: change how sessions are deleted #4893

Merged
merged 1 commit into from Jan 3, 2024

Conversation

kenjenkins
Copy link
Contributor

Summary

The identity manager expects to be able to read session ID and user ID from any deleted databroker session records. The session.Delete() wrapper method is not compatible with this expectation, as it calls Put() with a record containing an empty session. The stateful authentication flow currently calls session.Delete() from its RevokeSession() method.

The result is that the identity manager will not correctly track sessions deleted by the the stateful authentication flow, and will still try to use them during session refresh and user info refresh.

Instead, let's change the stateful authentication flow RevokeSession() method to perform deletions in a way that is compatible with the current identity manager code. That is, include the existing session data in the Put() call to delete the revoked session.

Related issues

#4892

User Explanation

Checklist

  • reference any related issues
  • updated docs
  • updated unit tests
  • updated UPGRADING.md
  • add appropriate tag (improvement / bug / etc)
  • ready for review

The identity manager expects to be able to read session ID and user ID
from any deleted databroker session records. The session.Delete()
wrapper method is not compatible with this expectation, as it calls
Put() with a record containing an empty session. The stateful
authentication flow currently calls session.Delete() from its
RevokeSession() method.

The result is that the identity manager will not correctly track
sessions deleted by the the stateful authentication flow, and will still
try to use them during session refresh and user info refresh.

Instead, let's change the stateful authentication flow RevokeSession()
method to perform deletions in a way that is compatible with the current
identity manager code. That is, include the existing session data in the
Put() call to delete the revoked session.
@kenjenkins kenjenkins requested a review from a team as a code owner January 2, 2024 23:38
@coveralls
Copy link

Coverage Status

coverage: 59.853% (+0.04%) from 59.818%
when pulling c536a40 on kenjenkins/identity-manager-session-delete
into 18717a9 on main.

// identity manager itself: fetch the existing databroker session record,
// explicitly set the DeletedAt timestamp, and Put() that record back.

res, err := s.dataBrokerClient.Get(ctx, &databroker.GetRequest{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use Patch instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea, but I think we can't, because the deleted_at field is part of the databroker Record message itself, rather than the data it contains (e.g. the Session message).

It might be worth a bigger conversation at some point about whether we should modify the Patch method to make it be able to delete a record.

@kenjenkins kenjenkins merged commit fb9eb31 into main Jan 3, 2024
11 checks passed
@kenjenkins kenjenkins deleted the kenjenkins/identity-manager-session-delete branch January 3, 2024 17:48
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