Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4be35472b | ||
|
|
b4e486854d | ||
|
|
8c3c432408 |
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
# Copyright IBM Corp. 2024, 2025
|
# Copyright (c) HashiCorp, Inc.
|
||||||
# SPDX-License-Identifier: MPL-2.0
|
# SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
contact_links:
|
contact_links:
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
## PCI review checklist
|
|
||||||
|
|
||||||
<!-- heimdall_github_prtemplate:grc-pci_dss-2024-01-05 -->
|
|
||||||
|
|
||||||
- [ ] I have documented a clear reason for, and description of, the change I am making.
|
|
||||||
|
|
||||||
- [ ] If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
|
|
||||||
|
|
||||||
- [ ] If applicable, I've documented the impact of any changes to security controls.
|
|
||||||
|
|
||||||
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
Copyright IBM Corp. 2024, 2025
|
Copyright (c) 2021 HashiCorp, Inc.
|
||||||
|
|
||||||
Mozilla Public License Version 2.0
|
Mozilla Public License Version 2.0
|
||||||
==================================
|
==================================
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module github.com/hashicorp/boundary-plugin-gcp
|
module github.com/hashicorp/boundary-plugin-gcp
|
||||||
|
|
||||||
go 1.24.0
|
go 1.21
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.google.com/go/iam v1.2.0
|
cloud.google.com/go/iam v1.2.0
|
||||||
@@ -9,7 +9,7 @@ require (
|
|||||||
github.com/googleapis/gax-go/v2 v2.13.0
|
github.com/googleapis/gax-go/v2 v2.13.0
|
||||||
github.com/hashicorp/boundary/sdk v0.0.47
|
github.com/hashicorp/boundary/sdk v0.0.47
|
||||||
github.com/hashicorp/terraform-json v0.23.0
|
github.com/hashicorp/terraform-json v0.23.0
|
||||||
golang.org/x/oauth2 v0.27.0
|
golang.org/x/oauth2 v0.22.0
|
||||||
google.golang.org/api v0.196.0
|
google.golang.org/api v0.196.0
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ require (
|
|||||||
go.opentelemetry.io/otel v1.29.0 // indirect
|
go.opentelemetry.io/otel v1.29.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.29.0 // indirect
|
go.opentelemetry.io/otel/metric v1.29.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.29.0 // indirect
|
go.opentelemetry.io/otel/trace v1.29.0 // indirect
|
||||||
golang.org/x/sync v0.18.0 // indirect
|
golang.org/x/sync v0.8.0 // indirect
|
||||||
golang.org/x/time v0.6.0 // indirect
|
golang.org/x/time v0.6.0 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||||
@@ -55,10 +55,10 @@ require (
|
|||||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
golang.org/x/crypto v0.45.0 // indirect
|
golang.org/x/crypto v0.26.0 // indirect
|
||||||
golang.org/x/net v0.47.0 // indirect
|
golang.org/x/net v0.28.0 // indirect
|
||||||
golang.org/x/sys v0.38.0 // indirect
|
golang.org/x/sys v0.24.0 // indirect
|
||||||
golang.org/x/text v0.31.0 // indirect
|
golang.org/x/text v0.17.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||||
google.golang.org/grpc v1.66.0
|
google.golang.org/grpc v1.66.0
|
||||||
google.golang.org/protobuf v1.34.2
|
google.golang.org/protobuf v1.34.2
|
||||||
|
|||||||
@@ -215,8 +215,8 @@ go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ
|
|||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
|
||||||
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
@@ -234,27 +234,27 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
|
|||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
|
||||||
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
|
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
|
||||||
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
|
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||||
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
|
||||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
|
||||||
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||||
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
|
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
|
||||||
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
@@ -60,8 +60,6 @@ type ValidateCredsCallback func(*Config, ...option.ClientOption) error
|
|||||||
//
|
//
|
||||||
// If deletion of the old private key is successful, the new private key and
|
// If deletion of the old private key is successful, the new private key and
|
||||||
// private key id are written into the credentials config and nil is returned.
|
// private key id are written into the credentials config and nil is returned.
|
||||||
// If validation fails or deleting the old private key fails, the function
|
|
||||||
// attempts to delete the newly created key as a rollback operation.
|
|
||||||
// On any error, the old credentials are not overwritten.
|
// On any error, the old credentials are not overwritten.
|
||||||
func (c *Config) RotateServiceAccountKey(
|
func (c *Config) RotateServiceAccountKey(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
@@ -90,12 +88,12 @@ func (c *Config) RotateServiceAccountKey(
|
|||||||
clientOptions := []option.ClientOption{option.WithTokenSource(creds.TokenSource)}
|
clientOptions := []option.ClientOption{option.WithTokenSource(creds.TokenSource)}
|
||||||
clientOptions = append(clientOptions, opts...)
|
clientOptions = append(clientOptions, opts...)
|
||||||
|
|
||||||
currentIAMClient, err := admin.NewIamClient(ctx, clientOptions...)
|
iamClient, err := admin.NewIamClient(ctx, clientOptions...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return status.Errorf(codes.Internal, "error creating IAM client: %v", err)
|
return status.Errorf(codes.Internal, "error creating IAM client: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
createServiceAccountKeyRes, err := currentIAMClient.CreateServiceAccountKey(ctx, &adminpb.CreateServiceAccountKeyRequest{
|
createServiceAccountKeyRes, err := iamClient.CreateServiceAccountKey(ctx, &adminpb.CreateServiceAccountKeyRequest{
|
||||||
Name: fmt.Sprintf("projects/%s/serviceAccounts/%s", c.ProjectId, c.ClientEmail),
|
Name: fmt.Sprintf("projects/%s/serviceAccounts/%s", c.ProjectId, c.ClientEmail),
|
||||||
PrivateKeyType: adminpb.ServiceAccountPrivateKeyType_TYPE_GOOGLE_CREDENTIALS_FILE,
|
PrivateKeyType: adminpb.ServiceAccountPrivateKeyType_TYPE_GOOGLE_CREDENTIALS_FILE,
|
||||||
KeyAlgorithm: adminpb.ServiceAccountKeyAlgorithm_KEY_ALG_RSA_2048,
|
KeyAlgorithm: adminpb.ServiceAccountKeyAlgorithm_KEY_ALG_RSA_2048,
|
||||||
@@ -128,37 +126,19 @@ func (c *Config) RotateServiceAccountKey(
|
|||||||
// Validate the new service account key
|
// Validate the new service account key
|
||||||
err = newConfig.ValidateServiceAccountKey(ctx, permissions, validateCredsCallback, clientOptions...)
|
err = newConfig.ValidateServiceAccountKey(ctx, permissions, validateCredsCallback, clientOptions...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Roll back the new key if validation fails.
|
return status.Errorf(codes.PermissionDenied, "error validating rotated service account key: %v", err)
|
||||||
rollbackErr := currentIAMClient.DeleteServiceAccountKey(ctx, &adminpb.DeleteServiceAccountKeyRequest{
|
|
||||||
Name: fmt.Sprintf("projects/%s/serviceAccounts/%s/keys/%s", newConfig.ProjectId, newConfig.ClientEmail, newConfig.PrivateKeyId),
|
|
||||||
})
|
|
||||||
if rollbackErr != nil {
|
|
||||||
return status.Errorf(codes.Internal, "error validating rotated service account key: %v; error rolling back newly created service account key: %v; service account may have multiple active keys", err, rollbackErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
return status.Errorf(codes.PermissionDenied, "error validating rotated service account key: %v; successfully rolled back newly created service account key", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newIAMClient, err := admin.NewIamClient(ctx, clientOptions...)
|
iamClient, err = admin.NewIamClient(ctx, clientOptions...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return status.Errorf(codes.Internal, "error creating IAM client with rotated service account key: %v", err)
|
return status.Errorf(codes.Internal, "error creating IAM client with rotated service account key: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = newIAMClient.DeleteServiceAccountKey(ctx, &adminpb.DeleteServiceAccountKeyRequest{
|
err = iamClient.DeleteServiceAccountKey(ctx, &adminpb.DeleteServiceAccountKeyRequest{
|
||||||
Name: fmt.Sprintf("projects/%s/serviceAccounts/%s/keys/%s", c.ProjectId, c.ClientEmail, c.PrivateKeyId),
|
Name: fmt.Sprintf("projects/%s/serviceAccounts/%s/keys/%s", c.ProjectId, c.ClientEmail, c.PrivateKeyId),
|
||||||
})
|
})
|
||||||
// If deletion of the old key fails, attempt to delete the new key to avoid leaving a dangling key, then return an error.
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// delete the new key using old client since the new client may not have permissions that the old client has.
|
return status.Errorf(codes.Internal, "error deleting service account key: %v", err)
|
||||||
rollbackErr := currentIAMClient.DeleteServiceAccountKey(ctx, &adminpb.DeleteServiceAccountKeyRequest{
|
|
||||||
Name: fmt.Sprintf("projects/%s/serviceAccounts/%s/keys/%s", newConfig.ProjectId, newConfig.ClientEmail, newConfig.PrivateKeyId),
|
|
||||||
})
|
|
||||||
// If rollback also fails, return an error indicating both the failure to delete the old key and the failure to roll back the new key.
|
|
||||||
if rollbackErr != nil {
|
|
||||||
return status.Errorf(codes.Internal, "error deleting service account key: %v; error rolling back newly created service account key: %v; service account may have multiple active keys", err, rollbackErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
return status.Errorf(codes.Internal, "error deleting service account key: %v; successfully rolled back newly created service account key", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c.PrivateKey = newConfig.PrivateKey
|
c.PrivateKey = newConfig.PrivateKey
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
@@ -72,14 +72,11 @@ func TestRotateServiceAccountKey(t *testing.T) {
|
|||||||
},
|
},
|
||||||
setup: func() {
|
setup: func() {
|
||||||
testIAMAdminServer.testCreateServiceAccountKeyError = errors.New("create key error")
|
testIAMAdminServer.testCreateServiceAccountKeyError = errors.New("create key error")
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyError = nil
|
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyErrors = nil
|
|
||||||
testResourceServer.testIamPermissionsError = nil
|
|
||||||
},
|
},
|
||||||
expectedError: errors.New("create key error"),
|
expectedError: errors.New("create key error"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "ValidateServiceAccountKey fails and rollback succeeds",
|
name: "DeleteServiceAccountKey returns error",
|
||||||
config: &Config{
|
config: &Config{
|
||||||
PrivateKey: "some-private-key",
|
PrivateKey: "some-private-key",
|
||||||
PrivateKeyId: "some-private-key-id",
|
PrivateKeyId: "some-private-key-id",
|
||||||
@@ -88,65 +85,9 @@ func TestRotateServiceAccountKey(t *testing.T) {
|
|||||||
},
|
},
|
||||||
setup: func() {
|
setup: func() {
|
||||||
testIAMAdminServer.testCreateServiceAccountKeyError = nil
|
testIAMAdminServer.testCreateServiceAccountKeyError = nil
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyError = nil
|
testIAMAdminServer.testDeleteServiceAccountKeyError = errors.New("delete key error")
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyErrors = []error{nil}
|
|
||||||
testResourceServer.testIamPermissionsError = errors.New("iam permissions error")
|
|
||||||
},
|
},
|
||||||
expectedError: errors.New("successfully rolled back newly created service account key"),
|
expectedError: errors.New("delete key error"),
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ValidateServiceAccountKey fails and rollback fails",
|
|
||||||
config: &Config{
|
|
||||||
PrivateKey: "some-private-key",
|
|
||||||
PrivateKeyId: "some-private-key-id",
|
|
||||||
ClientEmail: "client@example.com",
|
|
||||||
validateServiceAccountKeyTimeout: testValidateTimeout,
|
|
||||||
},
|
|
||||||
setup: func() {
|
|
||||||
testIAMAdminServer.testCreateServiceAccountKeyError = nil
|
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyError = nil
|
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyErrors = []error{errors.New("rollback key error")}
|
|
||||||
testResourceServer.testIamPermissionsError = errors.New("iam permissions error")
|
|
||||||
},
|
|
||||||
expectedError: errors.New("error rolling back newly created service account key"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "DeleteServiceAccountKey old key fails and rollback fails",
|
|
||||||
config: &Config{
|
|
||||||
PrivateKey: "some-private-key",
|
|
||||||
PrivateKeyId: "some-private-key-id",
|
|
||||||
ClientEmail: "client@example.com",
|
|
||||||
validateServiceAccountKeyTimeout: testValidateTimeout,
|
|
||||||
},
|
|
||||||
setup: func() {
|
|
||||||
testIAMAdminServer.testCreateServiceAccountKeyError = nil
|
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyError = nil
|
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyErrors = []error{
|
|
||||||
errors.New("delete key error"),
|
|
||||||
errors.New("rollback key error"),
|
|
||||||
}
|
|
||||||
testResourceServer.testIamPermissionsError = nil
|
|
||||||
},
|
|
||||||
expectedError: errors.New("error rolling back newly created service account key"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "DeleteServiceAccountKey old key fails and rollback succeeds",
|
|
||||||
config: &Config{
|
|
||||||
PrivateKey: "some-private-key",
|
|
||||||
PrivateKeyId: "some-private-key-id",
|
|
||||||
ClientEmail: "client@example.com",
|
|
||||||
validateServiceAccountKeyTimeout: testValidateTimeout,
|
|
||||||
},
|
|
||||||
setup: func() {
|
|
||||||
testIAMAdminServer.testCreateServiceAccountKeyError = nil
|
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyError = nil
|
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyErrors = []error{
|
|
||||||
errors.New("delete key error"),
|
|
||||||
nil,
|
|
||||||
}
|
|
||||||
testResourceServer.testIamPermissionsError = nil
|
|
||||||
},
|
|
||||||
expectedError: errors.New("successfully rolled back newly created service account key"),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Successful rotation",
|
name: "Successful rotation",
|
||||||
@@ -159,8 +100,6 @@ func TestRotateServiceAccountKey(t *testing.T) {
|
|||||||
setup: func() {
|
setup: func() {
|
||||||
testIAMAdminServer.testCreateServiceAccountKeyError = nil
|
testIAMAdminServer.testCreateServiceAccountKeyError = nil
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyError = nil
|
testIAMAdminServer.testDeleteServiceAccountKeyError = nil
|
||||||
testIAMAdminServer.testDeleteServiceAccountKeyErrors = nil
|
|
||||||
testResourceServer.testIamPermissionsError = nil
|
|
||||||
},
|
},
|
||||||
expectedError: nil,
|
expectedError: nil,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package credential
|
package credential
|
||||||
@@ -18,9 +18,8 @@ import (
|
|||||||
|
|
||||||
type testIAMAdminServer struct {
|
type testIAMAdminServer struct {
|
||||||
adminpb.UnimplementedIAMServer
|
adminpb.UnimplementedIAMServer
|
||||||
testCreateServiceAccountKeyError error
|
testCreateServiceAccountKeyError error
|
||||||
testDeleteServiceAccountKeyError error
|
testDeleteServiceAccountKeyError error
|
||||||
testDeleteServiceAccountKeyErrors []error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTestIAMAdminServer(createServiceAccountKeyError error, deleteServiceAccountKeyError error) *testIAMAdminServer {
|
func NewTestIAMAdminServer(createServiceAccountKeyError error, deleteServiceAccountKeyError error) *testIAMAdminServer {
|
||||||
@@ -47,13 +46,6 @@ func (f *testIAMAdminServer) CreateServiceAccountKey(ctx context.Context, req *a
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *testIAMAdminServer) DeleteServiceAccountKey(ctx context.Context, req *adminpb.DeleteServiceAccountKeyRequest) (*emptypb.Empty, error) {
|
func (f *testIAMAdminServer) DeleteServiceAccountKey(ctx context.Context, req *adminpb.DeleteServiceAccountKeyRequest) (*emptypb.Empty, error) {
|
||||||
// Use queued delete results so tests can separately control deleting the old key and deleting the new key during rollback.
|
|
||||||
if len(f.testDeleteServiceAccountKeyErrors) > 0 {
|
|
||||||
err := f.testDeleteServiceAccountKeyErrors[0]
|
|
||||||
f.testDeleteServiceAccountKeyErrors = f.testDeleteServiceAccountKeyErrors[1:]
|
|
||||||
return &emptypb.Empty{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &emptypb.Empty{}, f.testDeleteServiceAccountKeyError
|
return &emptypb.Empty{}, f.testDeleteServiceAccountKeyError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package errors
|
package errors
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package errors
|
package errors
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package values
|
package values
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package values
|
package values
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package plugin
|
package plugin
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package host
|
package host
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package host
|
package host
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package host
|
package host
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package host
|
package host
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package host
|
package host
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package host
|
package host
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package host
|
package host
|
||||||
@@ -617,6 +617,11 @@ func validateSet(s *hostsets.HostSet) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
badFields := make(map[string]string)
|
badFields := make(map[string]string)
|
||||||
|
_, filterSet := attrMap[ConstListInstancesFilter]
|
||||||
|
|
||||||
|
if filterSet && len(attrs.Filters) == 0 {
|
||||||
|
badFields[fmt.Sprintf("attributes.%s", ConstListInstancesFilter)] = "must not be empty"
|
||||||
|
}
|
||||||
|
|
||||||
for f := range attrMap {
|
for f := range attrMap {
|
||||||
if _, ok := allowedSetFields[f]; !ok {
|
if _, ok := allowedSetFields[f]; !ok {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package host
|
package host
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package host
|
package host
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package host
|
package host
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package host
|
package host
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package testing
|
package testing
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Copyright IBM Corp. 2024, 2025
|
# Copyright (c) HashiCorp, Inc.
|
||||||
# SPDX-License-Identifier: MPL-2.0
|
# SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
resource "random_id" "service_account_client_email" {
|
resource "random_id" "service_account_client_email" {
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Copyright IBM Corp. 2024, 2025
|
# Copyright (c) HashiCorp, Inc.
|
||||||
# SPDX-License-Identifier: MPL-2.0
|
# SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
output "client_email" {
|
output "client_email" {
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Copyright IBM Corp. 2024, 2025
|
# Copyright (c) HashiCorp, Inc.
|
||||||
# SPDX-License-Identifier: MPL-2.0
|
# SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
terraform {
|
terraform {
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Copyright IBM Corp. 2024, 2025
|
# Copyright (c) HashiCorp, Inc.
|
||||||
# SPDX-License-Identifier: MPL-2.0
|
# SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
data "google_client_openid_userinfo" "current" {}
|
data "google_client_openid_userinfo" "current" {}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// Copyright IBM Corp. 2024, 2025
|
// Copyright (c) HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
package testing
|
package testing
|
||||||
|
|||||||
Reference in new issue
Block a user