Skip to content

Commit 91394cc

Browse files
keep enrollment token when replacing data with signed (#10115)
1 parent 26a5543 commit 91394cc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

internal/pkg/agent/application/actions/handlers/handler_action_migrate.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,19 @@ func (h *Migrate) Handle(ctx context.Context, a fleetapi.Action, ack acker.Acker
7777
return err
7878
}
7979

80+
// signed data contains secret reference to the enrollment token so we extract the cleartext value
81+
// out of action.Data and replace it after unmarshalling the signed data into action.Data
82+
// see: https://github.com/elastic/fleet-server/blob/22f1f7a0474080d3f56c7148a6505cff0957f549/internal/pkg/secret/secret.go#L75
83+
enrollmentToken := action.Data.EnrollmentToken
84+
8085
if signedData != nil {
8186
if err := json.Unmarshal(signedData, &action.Data); err != nil {
8287
return fmt.Errorf("failed to convert signed data to action data: %w", err)
8388
}
8489
}
8590

91+
action.Data.EnrollmentToken = enrollmentToken
92+
8693
if err := h.coord.Migrate(ctx, action, fleetgateway.RequestBackoff); err != nil {
8794
// this should not happen, unmanaged agent should not receive the action
8895
// defensive coding to avoid misbehavior

0 commit comments

Comments
 (0)