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

Etcd cleanup #5064

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG-6.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic
Versioning](http://semver.org/spec/v2.0.0.html).

## [6.11.1] - 2024-09-12

### Changed
- Added TTl to each entry in user-session within etcd
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rephrase this to something like this and have just one entry:

### Fixed
- ADD TTL to each user session in the etcd data store to prevent leak.

- TTl value is 6 minutes

## [6.11.0] - 2024-01-31

### Changed
Expand Down
10 changes: 6 additions & 4 deletions backend/store/etcd/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ func (s *Store) GetSession(ctx context.Context, username, sessionID string) (str
}

// UpdateSession applies the supplied state to the session uniquely identified
// by the given username and session ID.
// by the given username and session ID and TTL of 6 minutes added considering access token expires in 5 minutes
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of hard-coding the value to 6 minutes I would calculate it based on the token expiration. I think something like (token expiration * 1.5) would be ok.

func (s *Store) UpdateSession(ctx context.Context, username, sessionID, state string) error {
if _, err := s.client.Put(ctx, userSessionPath(username, sessionID), state); err != nil {
leaseResp, err := s.client.Grant(ctx, 60*6)
if err != nil {
return fmt.Errorf("%s", err)
}
if _, err := s.client.Put(ctx, userSessionPath(username, sessionID), state, clientv3.WithLease(leaseResp.ID)); err != nil {
return err
}

return nil
}

Expand All @@ -45,6 +48,5 @@ func (s *Store) DeleteSession(ctx context.Context, username, sessionID string) e
if _, err := s.client.Delete(ctx, userSessionPath(username, sessionID)); err != nil {
return err
}

return nil
}
Loading