Skip to content

Commit

Permalink
GODRIVER-2911: Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeredit committed Jun 23, 2024
1 parent b343ebb commit 5240a91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
23 changes: 11 additions & 12 deletions cmd/testoidcauth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,13 +585,13 @@ func machine42ReadCommandsFailIfReauthenticationFails() error {
ExpiresAt: &t,
RefreshToken: nil,
}, nil
} else {
return &driver.OIDCCredential{
AccessToken: "this is a bad, bad token",
ExpiresAt: &t,
RefreshToken: nil,
}, nil
}
return &driver.OIDCCredential{
AccessToken: "this is a bad, bad token",
ExpiresAt: &t,
RefreshToken: nil,
}, nil

})

defer client.Disconnect(context.Background())
Expand Down Expand Up @@ -666,13 +666,12 @@ func machine43WriteCommandsFailIfReauthenticationFails() error {
ExpiresAt: &t,
RefreshToken: nil,
}, nil
} else {
return &driver.OIDCCredential{
AccessToken: "this is a bad, bad token",
ExpiresAt: &t,
RefreshToken: nil,
}, nil
}
return &driver.OIDCCredential{
AccessToken: "this is a bad, bad token",
ExpiresAt: &t,
RefreshToken: nil,
}, nil
})

defer client.Disconnect(context.Background())
Expand Down
8 changes: 4 additions & 4 deletions x/mongo/driver/auth/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ func (oa *OIDCAuthenticator) getAccessToken(
// but this is a safety check, since extra invalidation is only a performance impact, not a
// correctness impact.
// This must only be called with the lock held
func (oa *OIDCAuthenticator) invalidateAccessToken(force bool) {
func (oa *OIDCAuthenticator) invalidateAccessToken() {
tokenGenID := oa.cfg.Connection.OIDCTokenGenID()
if force || tokenGenID >= oa.tokenGenID {
if tokenGenID >= oa.tokenGenID {
oa.accessToken = ""
oa.cfg.Connection.SetOIDCTokenGenID(0)
}
Expand All @@ -236,7 +236,7 @@ func (oa *OIDCAuthenticator) invalidateAccessToken(force bool) {
// driver.Authenticator interface.
func (oa *OIDCAuthenticator) Reauth(ctx context.Context) error {
oa.mu.Lock()
oa.invalidateAccessToken(true)
oa.invalidateAccessToken()
oa.mu.Unlock()
// it should be impossible to get a Reauth when an Auth has never occurred,
// so we assume cfg was properly set. There is nothing to enforce this, however,
Expand Down Expand Up @@ -266,7 +266,7 @@ func (oa *OIDCAuthenticator) Auth(ctx context.Context, cfg *Config) error {
if err == nil {
return nil
}
oa.invalidateAccessToken(false)
oa.invalidateAccessToken()
time.Sleep(invalidateSleepTimeout)
}

Expand Down

0 comments on commit 5240a91

Please sign in to comment.