source: advance the checked projection
Source-Sha: 194a59adfd6c901635da7a9c18253bb2210e2426 Policy-Sha: b9b0be0ee74e55f561a803b8aef6be3c2134f5a83b46816a069a372f2eb04f4d Tree-Digest: 4697f2e281c1c6ecafff17cf6eeb391a0a1ac0fa6e5fc429f5b473f4579c252c
This commit is contained in:
parent
0401c76c79
commit
ffdccba10f
42 changed files with 2516 additions and 554 deletions
|
|
@ -182,6 +182,13 @@ type Config struct {
|
|||
// Desktop App Configuration
|
||||
Desktop DesktopConfig `json:"desktop,omitempty"`
|
||||
|
||||
// Standalone to fleet transition. Non-nil means the Server has accepted
|
||||
// this identity but local authority replacement has not fully converged.
|
||||
PendingFleetJoin *PendingFleetJoin `json:"pending_fleet_join,omitempty"`
|
||||
// Stable across retries so a lost Server response cannot turn one join into
|
||||
// a second credential-minting request.
|
||||
FleetJoinRequestID string `json:"fleet_join_request_id,omitempty"`
|
||||
|
||||
// Process Explorer Configuration
|
||||
ProcessExplorer ProcessExplorerConfig `json:"process_explorer,omitempty"`
|
||||
|
||||
|
|
@ -199,6 +206,20 @@ type DesktopConfig struct {
|
|||
RestartDelaySec int `json:"restart_delay_sec"` // Seconds between restart attempts
|
||||
}
|
||||
|
||||
// PendingFleetJoin is persisted only after the fleet server has accepted this
|
||||
// standalone identity. It is the crash-recovery bridge between remote
|
||||
// registration and the privileged helper replacing local authority.
|
||||
type PendingFleetJoin struct {
|
||||
RequestID string `json:"request_id"`
|
||||
ServerURL string `json:"server_url"`
|
||||
Token string `json:"token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
SigningPublicKey string `json:"signing_public_key"`
|
||||
SigningKeyID string `json:"signing_key_id"`
|
||||
CheckInInterval int `json:"check_in_interval,omitempty"`
|
||||
RegisteredAt time.Time `json:"registered_at"`
|
||||
}
|
||||
|
||||
// Load reads configuration from multiple sources with priority order:
|
||||
// 1. CLI flags
|
||||
// 2. Environment variables
|
||||
|
|
@ -776,21 +797,21 @@ func (c *Config) SetDegradedMode(enabled bool) error {
|
|||
|
||||
// IsRegistered checks if the agent is registered
|
||||
func (c *Config) IsRegistered() bool {
|
||||
return c.AgentID != uuid.Nil && c.Token != ""
|
||||
return c.AgentID != uuid.Nil && c.Token != "" && c.RefreshToken != "" && c.PendingFleetJoin == nil
|
||||
}
|
||||
|
||||
// IsStandalone reports whether this config has a stable local identity and no
|
||||
// fleet credential. A partial fleet enrollment is not standalone: refresh or
|
||||
// registration material must never silently become local mutation authority.
|
||||
func (c *Config) IsStandalone() bool {
|
||||
return c.AgentID != uuid.Nil && c.Token == "" && c.RefreshToken == "" && c.RegistrationToken == ""
|
||||
return c.AgentID != uuid.Nil && c.Token == "" && c.RefreshToken == "" && c.RegistrationToken == "" && c.PendingFleetJoin == nil
|
||||
}
|
||||
|
||||
// InitializeStandalone gives a local-only Agent one durable UUID. It is
|
||||
// idempotent, but refuses any fleet credential so provisioning cannot convert a
|
||||
// fleet host into local authority by accident.
|
||||
func (c *Config) InitializeStandalone() error {
|
||||
if c.IsRegistered() || c.Token != "" || c.RefreshToken != "" || c.RegistrationToken != "" {
|
||||
if c.IsRegistered() || c.Token != "" || c.RefreshToken != "" || c.RegistrationToken != "" || c.PendingFleetJoin != nil {
|
||||
return fmt.Errorf("standalone identity refused: fleet enrollment material is present")
|
||||
}
|
||||
if c.AgentID != uuid.Nil {
|
||||
|
|
@ -930,6 +951,13 @@ func mergeConfigPreservingDefaults(target, source *Config) {
|
|||
if source.Desktop != (DesktopConfig{}) {
|
||||
target.Desktop = source.Desktop
|
||||
}
|
||||
if source.PendingFleetJoin != nil {
|
||||
pending := *source.PendingFleetJoin
|
||||
target.PendingFleetJoin = &pending
|
||||
}
|
||||
if source.FleetJoinRequestID != "" {
|
||||
target.FleetJoinRequestID = source.FleetJoinRequestID
|
||||
}
|
||||
|
||||
// Version info
|
||||
if source.Version != "" {
|
||||
|
|
|
|||
Loading…
Reference in a new issue