credentialRotatedByPeer re-reads the user's stored refreshable credential after the server rejected rejectedRefreshToken, and returns it when its refresh token differs, which means another process (or a new login) replaced the credential. Each attempt reloads the configuration from disk first, so a
(hostname, username, rejectedRefreshToken string)
| 583 | // hosts.yml by another process is observed, not just one written to the keyring. It must run under |
| 584 | // withFreshConfigForRefresh, whose in-place reload contract it relies on. |
| 585 | func (c *AuthConfig) credentialRotatedByPeer(hostname, username, rejectedRefreshToken string) (gh.Credential, bool) { |
| 586 | sleep := c.sleep |
| 587 | if sleep == nil { |
| 588 | sleep = time.Sleep |
| 589 | } |
| 590 | for _, delay := range refreshRejectionRecheckDelays { |
| 591 | sleep(delay) |
| 592 | // A failed reload still leaves the keyring readable, so carry on with the in-memory configuration. |
| 593 | _ = c.reload() |
| 594 | stored, _, err := c.refreshableForUser(hostname, username) |
| 595 | if err == nil && stored.RefreshToken != rejectedRefreshToken { |
| 596 | return stored, true |
| 597 | } |
| 598 | } |
| 599 | return gh.Credential{}, false |
| 600 | } |
| 601 | |
| 602 | // removeCredentialForUser deletes every stored credential record for the user on the host, covering both the |
| 603 | // refreshable and the non-expiring forms in both the keyring and the insecure config, then writes the config. It |
no test coverage detected