-
Notifications
You must be signed in to change notification settings - Fork 13
Introduce authenticated client in Go using the Legacy CLI #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
akalipetis
commented
Aug 26, 2025
- Use the Legacy CLI for getting a token
- If the token is not valid (ie expired), force re-authentication
- If the client receives a 401 response, force re-authentication
1. Use the Legacy CLI for getting a token 2. If the token is not valid (ie expired), force re-authentication 3. If the client receives a 401 response, force re-authentication
macos is using a symlink for temporary directories and the tests were failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces authenticated HTTP client functionality for Go using the Legacy CLI to obtain and manage authentication tokens. The implementation includes automatic token refresh and retry mechanisms for handling expired or invalid tokens.
- Adds OAuth2-based authentication client that integrates with the Legacy CLI for token management
- Implements automatic retry logic for 401 responses with token refresh
- Extends configuration schema to support OAuth2 client settings and session management
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/auth/client.go | Creates authenticated HTTP client using Legacy CLI token source |
| internal/auth/legacy.go | Implements OAuth2 token source that retrieves tokens from Legacy CLI |
| internal/auth/transport.go | Provides HTTP transport with automatic 401 retry and token refresh |
| internal/auth/jwt.go | Adds JWT parsing utility for extracting token expiry information |
| internal/auth/transport_test.go | Tests the retry mechanism for 401 responses |
| internal/config/schema.go | Extends config schema with OAuth2 and session ID fields |
| internal/legacy/legacy.go | Adds ForceColor option to CLI wrapper |
| pkg/mockssh/server_test.go | Resolves symlinks in temp directory for test stability |
| internal/config/alt/path_test.go | Resolves symlinks in temp directory for test stability |
| go.mod | Updates dependencies including adding golang.org/x/oauth2 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
89439ac to
2f203f8
Compare
|
Right now this fails the legacy-cli tests ... but that's just on the test side, we can fix it |