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

feat: Remove refresh token if token is too big #1092

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Changes from all 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
21 changes: 20 additions & 1 deletion oidc_cli/oidc_impl/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,26 @@ func (c *Cache) refresh(ctx context.Context) (*client.Token, error) {

err = c.storage.Set(ctx, compressedToken)
if err != nil {
return nil, errors.Wrap(err, "Unable to cache the strToken")
if err.Error() == "could not set value to keyring: data passed to Set was too big" {
// TODO: Upgrade keyring library to v0.2.2 to use ErrSetDataTooBig
// if errors.Is(err, keyring.ErrSetDataTooBig) {
logrus.Debug("Token too big, removing refresh token")
strToken, err := token.Marshal(append(c.storage.MarshalOpts(), client.MarshalOptNoRefresh)...)
if err != nil {
return nil, errors.Wrap(err, "unable to marshall token")
}
// gzip encode and save token to storage
compressedToken, err = compressToken(strToken)
if err != nil {
return nil, errors.Wrap(err, "unable to compress token")
}
err = c.storage.Set(ctx, compressedToken)
if err != nil {
return nil, errors.Wrap(err, "Unable to cache the strToken")
}
} else {
return nil, errors.Wrap(err, "Unable to cache the strToken")
}
}

return token, nil
Expand Down
Loading