chore: refactor instance identity to be a SessionTokenProvider (#19566)

Refactors Agent instance identity to be a SessionTokenProvider.

Refactors the CLI to create Agent clients via a centralized function, rather than add-hoc via individual command handlers and their flags.

This allows commands besides `coder agent`, but which still use the agent identity, to support instance identity authentication.

Fixes #19111 by unifying all API requests to go thru the SessionTokenProvider for auth credentials.
This commit is contained in:
Spike Curtis
2025-09-03 10:38:42 +04:00
committed by GitHub
parent ee35ad3a57
commit 1354d84eb4
35 changed files with 640 additions and 478 deletions
+4 -3
View File
@@ -18,7 +18,8 @@ import (
"github.com/coder/serpent"
)
func (r *RootCmd) gitssh() *serpent.Command {
func gitssh() *serpent.Command {
agentAuth := &AgentAuth{}
cmd := &serpent.Command{
Use: "gitssh",
Hidden: true,
@@ -38,7 +39,7 @@ func (r *RootCmd) gitssh() *serpent.Command {
return err
}
client, err := r.tryCreateAgentClient()
client, err := agentAuth.CreateClient(ctx)
if err != nil {
return xerrors.Errorf("create agent client: %w", err)
}
@@ -108,7 +109,7 @@ func (r *RootCmd) gitssh() *serpent.Command {
return nil
},
}
agentAuth.AttachOptions(cmd, false)
return cmd
}