credentials_sanitize.go 767 B

123456789101112131415161718192021
  1. package service
  2. // SanitizeStoredCredentials strips secrets that must never be persisted on the
  3. // account credentials map after conversion to OAuth tokens (Grok Web SSO / password).
  4. // Call from admin create/update/import/apply-oauth paths.
  5. //
  6. // Cookie is always stripped: bulk paths may pass an empty platform label, and
  7. // session-jar residue must never sit next to OAuth tokens on any platform.
  8. // The platform argument is retained for call-site clarity / future scrubbing.
  9. func SanitizeStoredCredentials(platform string, creds map[string]any) map[string]any {
  10. if creds == nil {
  11. return nil
  12. }
  13. _ = platform
  14. for _, key := range []string{
  15. "password", "sso_token", "sso", "sso-rw", "clearTextPassword", "cookie",
  16. } {
  17. delete(creds, key)
  18. }
  19. return creds
  20. }