Skip to content

Commit bdf7bf7

Browse files
Do not allow PKI-KMS workers to have names updated via API (hashicorp#3143)
Do not allow PKI-KMS workers to have names updated via API This would cause their public IDs to change, which we do not want. Descriptions are also disallowed, since those come from the config file. This also adds logic to allow upgrading from old KMS method to new, with a test. Co-authored-by: Irena Rindos <[email protected]>
1 parent b4a8032 commit bdf7bf7

13 files changed

+423
-143
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ Canonical reference for changes, improvements, and bugfixes for Boundary.
1111
only recommended if compatibility with pre-0.13 workers using the KMS auth
1212
method is required. Requiring opting in removes some potentially confusing
1313
behavior for deciding when to use the old versus new mechanism. To opt in, add
14-
`use_deprecated_kms_auth_method = true` to the `worker` config block.
14+
`use_deprecated_kms_auth_method = true` to the `worker` config block. Note
15+
that if a 0.13+ worker using KMS connects to a 0.13+ controller using KMS, the
16+
transition to the new method will happen automatically. To go back to the old
17+
method after that will require the worker to be deleted and re-added with the
18+
`use_deprecated_kms_auth_method` config field specified.
1519
* When grants are added to roles additional validity checking is now performed.
1620
This extra validity checking is designed to reject grants that are not
1721
[documented grant

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ golangci-lint:
3636
$(eval GOLINT_INSTALLED := $(shell which golangci-lint))
3737

3838
if [ "$(GOLINT_INSTALLED)" = "" ]; then \
39-
sh scripts/install-golangci-lint.sh -b $(GO_PATH)/bin v1.51.2; \
39+
sh scripts/install-golangci-lint.sh -b $(GO_PATH)/bin v1.52.2; \
4040
fi;
4141

4242
.PHONY: cleangen

internal/daemon/controller/handlers/workers/worker_service.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"context"
88
"crypto/sha256"
99
"encoding/hex"
10+
stderrors "errors"
1011
"fmt"
1112
"strings"
1213

@@ -334,8 +335,25 @@ func (s Service) UpdateWorker(ctx context.Context, req *pbs.UpdateWorkerRequest)
334335
if authResults.Error != nil {
335336
return nil, authResults.Error
336337
}
338+
337339
w, err := s.updateInRepo(ctx, authResults.Scope.GetId(), req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
338-
if err != nil {
340+
switch {
341+
case err == nil:
342+
case stderrors.Is(err, server.ErrCannotUpdateKmsWorkerViaApi):
343+
// Treat this like a "bad field" error on name even though we couldn't
344+
// return it in validation without having to make an additional call and
345+
// a lot of additional logic
346+
return nil, handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
347+
badFields := make(map[string]string)
348+
if req.GetItem().GetName().GetValue() != "" {
349+
badFields[globals.NameField] = "KMS-registered workers cannot have their name updated via the API."
350+
}
351+
if req.GetItem().GetDescription().GetValue() != "" {
352+
badFields[globals.DescriptionField] = "KMS-registered workers cannot have their description updated via the API."
353+
}
354+
return badFields
355+
}, globals.WorkerPrefix)
356+
default:
339357
return nil, err
340358
}
341359

0 commit comments

Comments
 (0)