Complete platform management workflows
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user