Skip to content

Add an Output io.Writer so auth flow output can be redirected - #102

Merged
wesleymccollam merged 1 commit into
mainfrom
ioWriter
Sep 11, 2026
Merged

wesleymccollam merged 1 commit into
mainfrom
ioWriter

Conversation

@wesleymccollam

Copy link
Copy Markdown
Contributor

Summary

Adds an Output io.Writer field to the authorization-code and device-code configs so consumers can route (or silence, via io.Discard) the progress messages the default handlers write, instead of having that output locked to stdout.

This ports the equivalent changes from pingidentity/pingfederate-go-client#92.

Changes

  • config/pingone.go: new Output field on the authorization-code and device-code configs, replacing OnOpenBrowser / OnDisplayPrompt; new WithAuthorizationCodeOutput(w) / WithDeviceCodeOutput(w) builder methods
  • config/authorization_code.go: handler selection uses the default handler honoring Output; new DefaultAuthorizationCodeBrowserHandlerTo(w) constructor and best-effort write helpers
  • config/device_auth.go: same pattern with DefaultDeviceCodePromptHandlerTo(w)
  • config/hooks_test.go (new): coverage for redirecting output, os.Stdout, and silent-by-default behavior
  • config/authorization_code_test.go, config/device_auth_test.go, config/pingone_test.go: coverage for output redirection and io.Discard
  • README.md: document the new field

Breaking change

Consumers setting OnOpenBrowser or OnDisplayPrompt must migrate to the Output field (or call the *To constructors directly), as the default handler is now always used.

Testing

  • go test ./...
  • go vet ./...

🤖 Generated with Claude Code

Ports the equivalent changes from pingfederate-go-client#92.

Adds an Output io.Writer field to the authorization-code and device-code
configs so consumers can route (or silence, via io.Discard) progress
messages, instead of having that output locked to stdout. The default
handlers for both flows now stay silent by default and write their
progress messages to the configured writer:

- Replace OnOpenBrowser / OnDisplayPrompt with Output io.Writer on
  AuthorizationCode and DeviceCode
- Add WithAuthorizationCodeOutput / WithDeviceCodeOutput builder methods
- Add DefaultAuthorizationCodeBrowserHandlerTo /
  DefaultDeviceCodePromptHandlerTo, returning handlers with the same
  browser-opening behavior that write to a given writer (nil -> silent)
- Document the new field in the README "Output control" section
@wesleymccollam
wesleymccollam merged commit 0630a18 into main Sep 11, 2026
6 checks passed
@wesleymccollam
wesleymccollam deleted the ioWriter branch September 11, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants