Complete platform management workflows

This commit is contained in:
npc0-hue
2026-07-14 16:39:37 +08:00
parent 7e05d0a4e7
commit 4f33f761a3
106 changed files with 11313 additions and 460 deletions
+25
View File
@@ -19,6 +19,27 @@ func (svc *CoreService) RegisterRunHello(hello domain.RunControlHello) (domain.R
if err := validator.ValidateRunControlHello(hello); err != nil {
return domain.RunControlHelloResult{}, err
}
if hasComponentAuthIdentity(hello) {
auth, err := svc.AuthenticateComponent(domain.ComponentAuthenticationRequest{
ServerInstanceID: hello.ServerInstanceID,
ComponentKind: hello.ComponentKind,
ComponentKey: hello.ComponentKey,
Generation: hello.KeyGeneration,
Key: hello.RegistrationToken,
})
if err != nil {
return domain.RunControlHelloResult{}, err
}
if !auth.Allowed {
return domain.CopyRunControlHelloResult(domain.RunControlHelloResult{
Accepted: false,
RunEndpointID: hello.RunEndpointID,
ServerTime: svc.now(),
HeartbeatIntervalSeconds: defaultHeartbeatIntervalSeconds,
FeatureFlags: []string{"runtime-key.auth.denied"},
}), nil
}
}
stamp := svc.now()
endpoint := domain.RunEndpoint{
@@ -60,6 +81,10 @@ func (svc *CoreService) RegisterRunHello(hello domain.RunControlHello) (domain.R
}), nil
}
func hasComponentAuthIdentity(hello domain.RunControlHello) bool {
return hello.ServerInstanceID != "" || hello.PluginID != "" || hello.ComponentKind != "" || hello.ComponentKey != "" || hello.KeyGeneration != 0
}
func (svc *CoreService) AcceptRunHeartbeat(heartbeat domain.RunControlHeartbeat) (domain.RunControlHeartbeatResult, error) {
heartbeat = domain.CopyRunControlHeartbeat(heartbeat)
if err := validator.ValidateRunControlHeartbeat(heartbeat); err != nil {