Documentation
¶
Index ¶
- type AddSecretInstruction
- type FlowStatus
- type OAuthProviderConfig
- type ProviderStatus
- type RunnerInvalidator
- type Service
- func (s *Service) AddSecretInstruction(name, purpose string) AddSecretInstruction
- func (s *Service) CompleteAuthCodeFlow(ctx context.Context, provider, flowID, code string) error
- func (s *Service) CompleteAuthCodeFlowWithOrigin(ctx context.Context, provider, flowID, code string, origin string) error
- func (s *Service) DeleteOAuthProviderConfig(ctx context.Context, providerID string) error
- func (s *Service) DeleteVaultEntry(ctx context.Context, userID string, name string) error
- func (s *Service) Disconnect(ctx context.Context, userID string, provider string) error
- func (s *Service) GetFlowForCallback(flowID string) (oauth.FlowStatus, bool)
- func (s *Service) GetOAuthProviderConfig(ctx context.Context, providerID string) (OAuthProviderConfig, error)
- func (s *Service) GetProviderStatuses(ctx context.Context, userID string) []ProviderStatus
- func (s *Service) GitHubAccessToken(ctx context.Context, userID string) string
- func (s *Service) InvalidateAgent(agentID string) error
- func (s *Service) InvalidateAll() error
- func (s *Service) InvalidateUser(userID string) error
- func (s *Service) ListVault(ctx context.Context, userID string) ([]VaultEntry, error)
- func (s *Service) PollFlow(ctx context.Context, userID string, provider, flowID string) (FlowStatus, bool, error)
- func (s *Service) ProviderClientID(ctx context.Context, providerID string) (string, error)
- func (s *Service) SetBaseURL(url string)
- func (s *Service) SetInvalidator(inv RunnerInvalidator)
- func (s *Service) SetOAuthProviderConfig(ctx context.Context, cfg OAuthProviderConfig) error
- func (s *Service) SetRegistry(r *oauth.ProviderRegistry)
- func (s *Service) SetVaultService(svc *vault.Service)
- func (s *Service) StartFlow(ctx context.Context, userID string, provider string) (FlowStatus, error)
- func (s *Service) StartFlowWithOrigin(ctx context.Context, userID string, provider string, origin string) (FlowStatus, error)
- type VaultEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddSecretInstruction ¶
type AddSecretInstruction struct {
Name string
Purpose string
Command string // exact /config KEY VALUE command to run
}
AddSecretInstruction is returned by add_secret; it never contains the secret value.
type FlowStatus ¶
type FlowStatus struct {
Provider string
FlowID string
VerificationURI string
UserCode string
ExpiresAt time.Time
State string
}
FlowStatus is the model-visible view of an in-flight OAuth flow.
type OAuthProviderConfig ¶ added in v0.27.0
type OAuthProviderConfig struct {
ProviderID string `json:"provider_id"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
RedirectURL string `json:"redirect_url,omitempty"`
}
OAuthProviderConfig holds the mutable credentials for an OAuth provider. ClientSecret is masked as "***" in read responses.
type ProviderStatus ¶
type ProviderStatus struct {
Provider string `json:"provider"`
Icon string `json:"icon,omitempty"`
Available bool `json:"available"`
Configured bool `json:"configured"` // true when DB or YAML has a client_id
Connected bool `json:"connected"`
Username string `json:"username,omitempty"` // label for the connected account
// RequiredBy lists display names of enabled tools that depend on this
// provider being connected. Empty when no enabled tool needs it. Populated
// at the server layer, which has access to the plugin manifest.
RequiredBy []string `json:"required_by,omitempty"`
}
ProviderStatus describes the availability of an OAuth provider.
type RunnerInvalidator ¶
type RunnerInvalidator interface {
InvalidateUser(userID string) error
InvalidateAgent(agentID string) error
InvalidateAll() error
}
RunnerInvalidator closes live runners so the next session reloads vault/OAuth snapshots. Scope determines reach: a single user, one agent across all users, or every runner.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the shared host-side credential manager. It owns vault secret operations and OAuth orchestration. Admin HTTP handlers and the built-in credentials tool both delegate to this service.
func NewService ¶
func NewService( vaultSvc *vault.Service, q *pkgdb.Queries, flowStore *oauth.FlowStore, corsOrigin string, ) *Service
NewService creates a credentials service. vaultSvc and q may be nil if the vault / DB is not yet configured (methods that need them return errors).
func (*Service) AddSecretInstruction ¶
func (s *Service) AddSecretInstruction(name, purpose string) AddSecretInstruction
AddSecretInstruction returns a user-facing instruction to store a secret via /config. It never accepts or echoes the secret value.
func (*Service) CompleteAuthCodeFlow ¶
CompleteAuthCodeFlow finalizes an authorization-code OAuth callback flow.
func (*Service) CompleteAuthCodeFlowWithOrigin ¶
func (*Service) DeleteOAuthProviderConfig ¶ added in v0.27.0
DeleteOAuthProviderConfig removes the DB override for a provider, reverting to YAML defaults.
func (*Service) DeleteVaultEntry ¶
DeleteVaultEntry removes a named vault entry for userID.
func (*Service) Disconnect ¶
Disconnect removes the OAuth bundle for the given provider and user.
func (*Service) GetFlowForCallback ¶
func (s *Service) GetFlowForCallback(flowID string) (oauth.FlowStatus, bool)
GetFlowForCallback returns the stored flow (for callback handlers that need userID).
func (*Service) GetOAuthProviderConfig ¶ added in v0.27.0
func (s *Service) GetOAuthProviderConfig(ctx context.Context, providerID string) (OAuthProviderConfig, error)
GetOAuthProviderConfig returns the effective config for a provider: DB override merged over the YAML default. ClientSecret is masked.
func (*Service) GetProviderStatuses ¶
func (s *Service) GetProviderStatuses(ctx context.Context, userID string) []ProviderStatus
GetProviderStatuses returns status for all registered OAuth providers.
func (*Service) GitHubAccessToken ¶ added in v0.49.0
GitHubAccessToken returns the access token userID has bound for GitHub, or "" when GitHub is not connected (or the vault/registry is unavailable). A near-expiry token is refreshed as a side effect. It never surfaces the not-connected condition as an error: an empty string means "clone anonymously".
func (*Service) InvalidateAgent ¶ added in v0.48.0
InvalidateAgent closes all live runners for one agent across every user.
func (*Service) InvalidateAll ¶ added in v0.48.0
InvalidateAll closes every live runner across all agents and users.
func (*Service) InvalidateUser ¶
InvalidateUser closes all live runners for userID across all pools.
func (*Service) PollFlow ¶
func (s *Service) PollFlow(ctx context.Context, userID string, provider, flowID string) (FlowStatus, bool, error)
PollFlow polls an in-flight OAuth flow. For device-code flows it completes and saves the token when authorized. For auth-code flows it returns completed=true once the callback has finalized the flow.
func (*Service) ProviderClientID ¶ added in v0.43.0
ProviderClientID returns the effective client_id for the given tool OAuth provider.
func (*Service) SetBaseURL ¶ added in v0.38.3
SetBaseURL overrides the base URL used to build OAuth redirect URIs.
func (*Service) SetInvalidator ¶
func (s *Service) SetInvalidator(inv RunnerInvalidator)
SetInvalidator wires the runner invalidator (usually *agent.PoolManager).
func (*Service) SetOAuthProviderConfig ¶ added in v0.27.0
func (s *Service) SetOAuthProviderConfig(ctx context.Context, cfg OAuthProviderConfig) error
SetOAuthProviderConfig persists a provider credential override to the DB. The client_secret is encrypted with the master vault key before storage.
func (*Service) SetRegistry ¶
func (s *Service) SetRegistry(r *oauth.ProviderRegistry)
SetRegistry wires the OAuth provider registry used for generic provider operations.
func (*Service) SetVaultService ¶
SetVaultService sets or replaces the vault service at runtime (e.g. after startup).
func (*Service) StartFlow ¶
func (s *Service) StartFlow(ctx context.Context, userID string, provider string) (FlowStatus, error)
StartFlow starts an OAuth flow for the given provider and user. It prefers device_code flows when available, making it suitable for agent/CLI use.
func (*Service) StartFlowWithOrigin ¶
func (s *Service) StartFlowWithOrigin(ctx context.Context, userID string, provider string, origin string) (FlowStatus, error)
StartFlowWithOrigin starts an OAuth flow for use by the admin UI. It uses the provider's preferred flow type (device_code when available, otherwise authorization_code). The callback URL is built from origin so browser redirects land on the correct host.
type VaultEntry ¶
VaultEntry holds non-sensitive metadata for a stored secret.