Commit graph

34 commits

Author SHA1 Message Date
Babak K. Shandiz
2bf528ccc7
test(internal/authflow): assert user-agent header is not modified/added
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2026-03-27 11:48:17 +00:00
William Martin
fb8e22a767 fix(auth): preserve User-Agent in authflow getViewer
getViewer was building a new HTTP client from scratch, losing
AppVersion and InvokingAgent from the plain client already passed
into AuthFlow. Reuse the existing client by shallow-copying it and
wrapping its transport with AddAuthTokenHeader for the new token.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-26 17:26:27 +01:00
Babak K. Shandiz
ae9a7ed542
refactor(authflow): receive HTTP client via args
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-10-13 16:48:10 +01:00
Andrey
4e1318eb2a
feat: gh auth Automatically copy one-time OAuth code to clipboard (#11518)
* feat: add ability to copy one-time OAuth code while authenticating

Signed-off-by: Andrey <andrekabatareika@gmail.com>

* fix(docs): wrong example for gh auth refresh

* chore(authflow): update message to include one-time code to it

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>

* chore(authflow): improve message when copied one-time code

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>

* chore(authflow): don't early return error when could not copy OAuth code

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>

* refactor(authflow): make code for working with OAuth code more readable

* Adjust language in `gh auth` help for clipboard

---------

Signed-off-by: Andrey <andrekabatareika@gmail.com>
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2025-08-25 09:52:51 -06:00
Tyler McGoffin
e1a39d8e2b Add ghe.com to tests describing ghec data residency 2024-10-15 12:24:41 -07:00
Tyler McGoffin
81591a09b8 Use go-gh/auth package for IsEnterprise, IsTenancy, and NormalizeHostname 2024-10-15 11:56:43 -07:00
Tyler McGoffin
3a8417f6c7 Add test coverage to places where IsEnterprise incorrectly covers Tenancy
IsEnterprise currently returns `true` when `IsTenancy` returns true. We
prefer that this behavior is orthogonal. This commit adds failing tests to
the instances where IsEnterprise should not behave the same as IsTenancy.

These test cases are expected to pass with the inclusion of the coming
improvements to go-gh to handle the orthogonality of IsEnterprise and
IsTenancy.
2024-10-15 11:56:43 -07:00
bagtoad
ca01bb8f9c Handle errors from parsing hostname in auth flow 2024-10-08 16:12:40 -06:00
Ulf Adams
e6d39eb886 Print the login URL even when opening a browser
Fixes https://github.com/cli/cli/issues/5500.
2024-10-03 17:18:52 +02:00
Sam Coe
024cb939af Rename authCfg.Token to authCfg.ActiveToken and authCfg.SetToken to authCfg.SetActiveToken 2023-12-06 14:06:28 +01:00
Sam Coe
c9a2d85793
Cleanup config.AuthToken and config.DefaultHost methods (#7049) 2023-02-28 00:24:45 +00:00
Sam Coe
a33e12a21d
Refactor Config interface in preperation for encrypted token storage (#7033) 2023-02-28 10:51:12 +11:00
Sam Coe
6a8deb1f5a
Integrate latest go-gh packages (#6084) 2022-08-18 09:04:13 +03:00
Mislav Marohnić
d21d388b8d
Restore old GH_DEBUG=1 behavior for HTTP logging (#6054)
- No HTTP bodies or headers are logged until `GH_DEBUG=api` is used.
- Logging to terminal now supports colorization.
2022-08-10 17:59:13 +02:00
Sam Coe
e5cf302ad8
Post go-gh integration cleanup (#5933) 2022-07-13 14:58:50 +02:00
Sam Coe
1e8cb9c1b2
Fix login flow (#5928) 2022-07-12 15:46:35 +02:00
Sam Coe
cacff4ad6d
Use go-gh config package (#5771) 2022-06-23 11:50:04 +00:00
Sam Coe
074ed50b8a
Integrate go-gh API package (#5614) 2022-06-23 04:05:31 +01:00
Mislav Marohnić
0eedef3947 auth: respect GH_BROWSER, browser config, avoid opening non-HTTP URLs 2022-05-10 17:52:16 +02:00
Naïm Favier
8dbd07212c
Stop auth commands from modifying global config file (#5378) 2022-04-11 17:26:18 +02:00
lylecantcode
56fda0f8c6
Support GH_DEBUG to control verbosity, deprecate DEBUG (#5306)
The GH_DEBUG environment variable is a new gh-specific verbosity control.

For backwards-compatibility, DEBUG will still be respected if it has values
"1", "true", "yes", and "api", but any other values will be ignored.

Finally, support for "oauth" debug value has been dropped in favor of "api".
The "oauth" value only had limited, internal use.

Co-authored-by: Mislav Marohnić <mislav@github.com>
2022-03-29 18:05:35 +02:00
Mislav Marohnić
be9f01101a Tweak auth flow re: interactivity
Fixes non-interactive login flow and make sure "prompt" configuration is
respected by never prompting if it was explicitly disabled.

No longer asks to press Enter again after "Authentication complete"
message, since that didn't provide any value to the user.
2022-01-12 15:50:51 +01:00
Nick Cooper
a408f24d3a auth: add noninteractive flow to login/refresh 2022-01-11 22:44:46 +01:00
Mislav Marohnić
2c86e671f3 Enable gh auth login for github.localhost 2021-10-18 20:01:18 +02:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Mislav Marohnić
111e8dbcf2 Pass web browser to each individual command
This removes sensitivity to the BROWSER environment variable in tests
and makes it easier to verify the URL that the browser was invoked with
without having to stub sub-processes.
2021-03-19 21:22:37 +01:00
Mislav Marohnić
075b6f8aa6 Remove workflow from default OAuth scopes
We now request it conditionally only for "HTTPS" login flow
2021-02-04 17:40:09 +01:00
Mislav Marohnić
5a110c8e42 Add SSH key generation & uploading to gh auth login flow 2021-02-01 23:34:00 +01:00
Mislav Marohnić
536a173364 Enable debugging HTTP traffic during auth login/refresh 2021-01-05 16:24:47 +01:00
Mislav Marohnić
9140e88708 Extract oauth package 2020-12-18 20:27:56 +01:00
Mislav Marohnić
ada59236c6 Add workflow to the list of default OAuth scopes we request
Since GitHub CLI now offers to authenticate your Git as well, the token
we request here will be used for git pushes. Since we do anticipate our
users making edits to their GitHub Actions workflow files, we want them
to be able to push their changes, and this scope allows that.
2020-12-07 20:12:58 +01:00
vilmibm
893fe09a83 try passing iostreams around instead of writer+colorscheme 2020-11-02 11:44:50 -08:00
vilmibm
a2aa154794 port entirely to ColorScheme 2020-10-29 12:37:45 -07:00
vilmibm
15bfb5447b split auth flow code into new internal package 2020-09-10 12:13:48 -05:00