microcks-cli
microcks-cli copied to clipboard
fix: remove OAuth token logging and redact sensitive data from CLI output
Summary
Fixes #449 — SSO login leaks OAuth access and refresh tokens to CLI logs.
Changes
cmd/login.go
| Before | After | Why |
|---|---|---|
log.Printf("Token: %s\n", tokenString) |
Removed | Unconditionally leaked the full JWT access token to stderr |
log.Printf("Refresh Token: %s\n", refreshToken) |
Removed | Unconditionally leaked the long-lived refresh token to stderr |
log.Printf("Callback: %s\n", r.URL) |
log.Printf("Callback received on: %s\n", r.URL.Path) |
Stripped query parameters containing the OAuth authorization code |
fmt.Printf("Performing ... login: %s\n", url) |
Prints only the base URL (before ?) |
Stripped state nonce, code_challenge, and other sensitive params |
pkg/config/config.go
Added redactSensitiveContent() helper that masks:
Authorizationheader values →Authorization: [REDACTED]- OAuth parameters (
access_token,refresh_token,id_token,code) →param=[REDACTED]
Applied to both DumpRequestIfRequired() and DumpResponseIfRequired() so that --verbose HTTP dumps no longer leak bearer tokens.
Verification
go build ./...✅go vet ./...✅ (pre-existing warning inpkg/watcher/executor.gounrelated to this change)grepconfirms zero remaining token log statements incmd/
Risk Assessment
Low risk — Only removes debug log statements and adds output redaction. No behavioral changes to authentication flow, token storage, or API calls.
Could @Harsh4902 @lbroudoux review this ''