purgeNonExpiringForRefreshableLogin removes any non-expiring credential for the user during a refreshable login so the two credential forms cannot coexist. The ordinary keyring is now resolved before the refreshable credential, so a surviving non-expiring token would outrank the freshly stored refre
(hostname, username string)
| 214 | // present", so the check stays silent exactly where a delete error would be spurious. Only a token that genuinely |
| 215 | // survives removal is surfaced. |
| 216 | func (c *AuthConfig) purgeNonExpiringForRefreshableLogin(hostname, username string) error { |
| 217 | // Best-effort removal in both stores, matching login's symmetric cleanup. |
| 218 | _ = c.cfg.Remove([]string{hostsKey, hostname, usersKey, username, oauthTokenKey}) |
| 219 | _ = keyringDelete(keyringServiceName(hostname), username) |
| 220 | |
| 221 | if _, err := keyring.Get(keyringServiceName(hostname), username); err == nil { |
| 222 | return errors.New("could not remove the existing non-expiring credential, which would shadow this login") |
| 223 | } |
| 224 | if _, err := c.cfg.Get([]string{hostsKey, hostname, usersKey, username, oauthTokenKey}); err == nil { |
| 225 | return errors.New("could not remove the existing non-expiring credential, which would shadow this login") |
| 226 | } |
| 227 | return nil |
| 228 | } |
| 229 | |
| 230 | // refreshableForUser returns the refreshable credential stored for the user along with whether it came from secure |
| 231 | // storage. It prefers the secure keyring and falls back to the insecure configuration record, returning |
no test coverage detected