Skip to content

Commit

Permalink
Merge branch 'main' into biazmoreira/identity/group/consistency/fix
Browse files Browse the repository at this point in the history
  • Loading branch information
biazmoreira authored Feb 4, 2025
2 parents ee51bc1 + 6f8b5da commit d8a49be
Show file tree
Hide file tree
Showing 38 changed files with 473 additions and 220 deletions.
5 changes: 5 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ lint:
- physical/raft/types.proto
- sdk/database/dbplugin/database.proto
- sdk/database/dbplugin/v5/proto/database.proto
- sdk/database/dbplugin/v5/proto/database_ent.proto
- sdk/helper/pluginutil/multiplexing.proto
- sdk/logical/event.proto
- sdk/logical/identity.proto
Expand Down Expand Up @@ -94,13 +95,15 @@ lint:
RPC_REQUEST_RESPONSE_UNIQUE:
- sdk/database/dbplugin/database.proto
- sdk/database/dbplugin/v5/proto/database.proto
- sdk/database/dbplugin/v5/proto/database_ent.proto
- sdk/plugin/pb/backend.proto
- sdk/plugin/pb/system_view_service_ent.proto
- vault/replication_services_ent.proto
- vault/request_forwarding_service.proto
RPC_REQUEST_STANDARD_NAME:
- sdk/database/dbplugin/database.proto
- sdk/database/dbplugin/v5/proto/database.proto
- sdk/database/dbplugin/v5/proto/database_ent.proto
- sdk/logical/version.proto
- sdk/plugin/pb/backend.proto
- sdk/plugin/pb/system_view_service_ent.proto
Expand All @@ -110,6 +113,7 @@ lint:
RPC_RESPONSE_STANDARD_NAME:
- sdk/database/dbplugin/database.proto
- sdk/database/dbplugin/v5/proto/database.proto
- sdk/database/dbplugin/v5/proto/database_ent.proto
- sdk/logical/version.proto
- sdk/plugin/pb/backend.proto
- vault/hcp_link/proto/meta/meta.proto
Expand All @@ -119,6 +123,7 @@ lint:
SERVICE_SUFFIX:
- sdk/database/dbplugin/database.proto
- sdk/database/dbplugin/v5/proto/database.proto
- sdk/database/dbplugin/v5/proto/database_ent.proto
- sdk/helper/pluginutil/multiplexing.proto
- sdk/logical/version.proto
- sdk/plugin/pb/backend.proto
Expand Down
3 changes: 3 additions & 0 deletions changelog/29402.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
core: add support for reading certain sensitive seal wrap and managed key (enterprise) configuration values from the environment or files.
```
3 changes: 3 additions & 0 deletions changelog/29416.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui (enterprise): Fixes token renewal to ensure capability checks are performed in the relevant namespace, resolving 'Not authorized' errors for resources that users have permission to access.
```
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ require (
github.com/hashicorp/go-gcp-common v0.9.1
github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.1
github.com/hashicorp/go-kms-wrapping/v2 v2.0.16
github.com/hashicorp/go-kms-wrapping/wrappers/aead/v2 v2.0.9
github.com/hashicorp/go-kms-wrapping/wrappers/alicloudkms/v2 v2.0.3
github.com/hashicorp/go-kms-wrapping/wrappers/awskms/v2 v2.0.9
github.com/hashicorp/go-kms-wrapping/wrappers/azurekeyvault/v2 v2.0.11
github.com/hashicorp/go-kms-wrapping/wrappers/gcpckms/v2 v2.0.12
github.com/hashicorp/go-kms-wrapping/wrappers/ocikms/v2 v2.0.7
github.com/hashicorp/go-kms-wrapping/wrappers/transit/v2 v2.0.12
github.com/hashicorp/go-kms-wrapping/v2 v2.0.18
github.com/hashicorp/go-kms-wrapping/wrappers/aead/v2 v2.0.10
github.com/hashicorp/go-kms-wrapping/wrappers/alicloudkms/v2 v2.0.4
github.com/hashicorp/go-kms-wrapping/wrappers/awskms/v2 v2.0.11
github.com/hashicorp/go-kms-wrapping/wrappers/azurekeyvault/v2 v2.0.12
github.com/hashicorp/go-kms-wrapping/wrappers/gcpckms/v2 v2.0.13
github.com/hashicorp/go-kms-wrapping/wrappers/ocikms/v2 v2.0.9
github.com/hashicorp/go-kms-wrapping/wrappers/transit/v2 v2.0.13
github.com/hashicorp/go-memdb v1.3.4
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-plugin v1.6.1
Expand All @@ -112,7 +112,7 @@ require (
github.com/hashicorp/go-secure-stdlib/kv-builder v0.1.2
github.com/hashicorp/go-secure-stdlib/mlock v0.1.3
github.com/hashicorp/go-secure-stdlib/nonceutil v0.1.0
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.8
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.9
github.com/hashicorp/go-secure-stdlib/password v0.1.1
github.com/hashicorp/go-secure-stdlib/permitpool v1.0.0
github.com/hashicorp/go-secure-stdlib/reloadutil v0.1.1
Expand Down
36 changes: 18 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1419,22 +1419,22 @@ github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJ
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.1 h1:KIge4FHZEDb2/xjaWgmBheCTgRL6HV4sgTfDsH876L8=
github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.1/go.mod h1:aHO1EoFD0kBYLBedqxXgalfFT8lrWfP7kpuSoaqGjH0=
github.com/hashicorp/go-kms-wrapping/v2 v2.0.16 h1:WZeXfD26QMWYC35at25KgE021SF9L3u9UMHK8fJAdV0=
github.com/hashicorp/go-kms-wrapping/v2 v2.0.16/go.mod h1:ZiKZctjRTLEppuRwrttWkp71VYMbTTCkazK4xT7U/NQ=
github.com/hashicorp/go-kms-wrapping/wrappers/aead/v2 v2.0.9 h1:HpGOHc0Vd3aacMAEtAUVe38zMcq7BfYQSjrGCmtRNx0=
github.com/hashicorp/go-kms-wrapping/wrappers/aead/v2 v2.0.9/go.mod h1:ygxw8l40DbAQQ587OzoB3bsBWVpB0e/BOWKlXgYkfG8=
github.com/hashicorp/go-kms-wrapping/wrappers/alicloudkms/v2 v2.0.3 h1:36Pxy8BQd7DAJ2Mk6vuJlIjqQ80e20vlO7a4Ep3RTOg=
github.com/hashicorp/go-kms-wrapping/wrappers/alicloudkms/v2 v2.0.3/go.mod h1:heY2PS1SGU0cMamgv+zId/sKT+XFHaf61bLOSnP1Gb8=
github.com/hashicorp/go-kms-wrapping/wrappers/awskms/v2 v2.0.9 h1:qdxeZvDMRGZ3YSE4Oz0Pp7WUSUn5S6cWZguEOkEVL50=
github.com/hashicorp/go-kms-wrapping/wrappers/awskms/v2 v2.0.9/go.mod h1:DcXbvVpgNWbxGmxgmu3QN64bEydMu14Cpe34RRR30HY=
github.com/hashicorp/go-kms-wrapping/wrappers/azurekeyvault/v2 v2.0.11 h1:/7SKkYIhA8cr3l8m1EKT6Q90bPoSVqqVBuQ6HgoMIkw=
github.com/hashicorp/go-kms-wrapping/wrappers/azurekeyvault/v2 v2.0.11/go.mod h1:LepS5s6ESGE0qQMpYaui5lX+mQYeiYiy06VzwWRioO8=
github.com/hashicorp/go-kms-wrapping/wrappers/gcpckms/v2 v2.0.12 h1:PCqWzT/Hii0KL07JsBZ3lJbv/wx02IAHYlhWQq8rxRY=
github.com/hashicorp/go-kms-wrapping/wrappers/gcpckms/v2 v2.0.12/go.mod h1:HSaOaX/lv3ShCdilUYbOTPnSvmoZ9xtQhgw+8hYcZkg=
github.com/hashicorp/go-kms-wrapping/wrappers/ocikms/v2 v2.0.7 h1:KeG3QGrbxbr2qAqCJdf3NR4ijAYwdcWLTmwSbR0yusM=
github.com/hashicorp/go-kms-wrapping/wrappers/ocikms/v2 v2.0.7/go.mod h1:rXxYzjjGw4HltEwxPp9zYSRIo6R+rBf1MSPk01bvodc=
github.com/hashicorp/go-kms-wrapping/wrappers/transit/v2 v2.0.12 h1:E8pzzF7i44OZCYDol+U7VbTBmHe65/6dx1nYxS0P1k0=
github.com/hashicorp/go-kms-wrapping/wrappers/transit/v2 v2.0.12/go.mod h1:YRqguGarF7kbHeojTPkanH3qvjbEP2pelq5b0ifaQ1M=
github.com/hashicorp/go-kms-wrapping/v2 v2.0.18 h1:DLfC677GfKEpSAFpEWvl1vXsGpEcSHmbhBaPLrdDQHc=
github.com/hashicorp/go-kms-wrapping/v2 v2.0.18/go.mod h1:t/eaR/mi2mw3klfl1WEAuiLKrlZ/Q8cosmsT+RIPLu0=
github.com/hashicorp/go-kms-wrapping/wrappers/aead/v2 v2.0.10 h1:am7ai27sEGpfOefHhUShbWAOa6EvkBaiMpB7zZ/PUyo=
github.com/hashicorp/go-kms-wrapping/wrappers/aead/v2 v2.0.10/go.mod h1:sYX07HI7wMCFe9+FmxMOCwJ7q5CD4aq3VI+KoB8FYZY=
github.com/hashicorp/go-kms-wrapping/wrappers/alicloudkms/v2 v2.0.4 h1:8XgCt3ZDfE0MPBLJsUE4ZnPkFAF4K13Zxqyjx1lA22A=
github.com/hashicorp/go-kms-wrapping/wrappers/alicloudkms/v2 v2.0.4/go.mod h1:Inx0DLGr58Un5TerS8je0SGZwKKihotqaxqoAKHpSmk=
github.com/hashicorp/go-kms-wrapping/wrappers/awskms/v2 v2.0.11 h1:J9zGa9SlcOHT3SQTj0Vv3shHo0anWbs58weURGCgChI=
github.com/hashicorp/go-kms-wrapping/wrappers/awskms/v2 v2.0.11/go.mod h1:iAOCu7/lG5eugg8+k7NVvQt0IpWT8s2Q9wnMtC/guM4=
github.com/hashicorp/go-kms-wrapping/wrappers/azurekeyvault/v2 v2.0.12 h1:ZL6jMQVOOvtog9/L9MLR1J7VssliIBVEFQlzKC9nn2c=
github.com/hashicorp/go-kms-wrapping/wrappers/azurekeyvault/v2 v2.0.12/go.mod h1:qAc0pzuhbesYKpFUmCWCPiOo6XdgpGEeYSE7Y7EXfgM=
github.com/hashicorp/go-kms-wrapping/wrappers/gcpckms/v2 v2.0.13 h1:NGBZnF+yPRZ3gjFl69Y2m58/U0iyB2oH9HaznL9tekA=
github.com/hashicorp/go-kms-wrapping/wrappers/gcpckms/v2 v2.0.13/go.mod h1:4Xb+6d8VPeDcUNuh4toPqJlDpkajeJyIQeg36TtWhKw=
github.com/hashicorp/go-kms-wrapping/wrappers/ocikms/v2 v2.0.9 h1:rlKOPHzZ41QeV/H6UIX2wVkPhLzVK+nKhLRIbIAZ0Yc=
github.com/hashicorp/go-kms-wrapping/wrappers/ocikms/v2 v2.0.9/go.mod h1:pHJfTvq97FAKCWxIJOHZWQmVfRXmUN6tmgEcgj3nC+M=
github.com/hashicorp/go-kms-wrapping/wrappers/transit/v2 v2.0.13 h1:UuDeq3nr0e+H9CrZM3dvpDGkWFSJYTtuTqVekn2za2k=
github.com/hashicorp/go-kms-wrapping/wrappers/transit/v2 v2.0.13/go.mod h1:E2dYgXYNkvKe84PIxD9eJqqhFRA4guCTDweJR4i0gds=
github.com/hashicorp/go-memdb v1.3.4 h1:XSL3NR682X/cVk2IeV0d70N4DZ9ljI885xAEU8IoK3c=
github.com/hashicorp/go-memdb v1.3.4/go.mod h1:uBTr1oQbtuMgd1SSGoR8YV27eT3sBHbYiNm53bMpgSg=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
Expand Down Expand Up @@ -1474,8 +1474,8 @@ github.com/hashicorp/go-secure-stdlib/mlock v0.1.3 h1:kH3Rhiht36xhAfhuHyWJDgdXXE
github.com/hashicorp/go-secure-stdlib/mlock v0.1.3/go.mod h1:ov1Q0oEDjC3+A4BwsG2YdKltrmEw8sf9Pau4V9JQ4Vo=
github.com/hashicorp/go-secure-stdlib/nonceutil v0.1.0 h1:iJG9Q3iUme12yH+wzBMGYrw/Am4CfX3sDcA8m5OGfhQ=
github.com/hashicorp/go-secure-stdlib/nonceutil v0.1.0/go.mod h1:s28ohJ0kU6tersf0it/WsBCyZSdziPlP+G1FRA3ar28=
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.8 h1:iBt4Ew4XEGLfh6/bPk4rSYmuZJGizr6/x/AEizP0CQc=
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.8/go.mod h1:aiJI+PIApBRQG7FZTEBx5GiiX+HbOHilUdNxUZi4eV0=
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.9 h1:FW0YttEnUNDJ2WL9XcrrfteS1xW8u+sh4ggM8pN5isQ=
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.9/go.mod h1:Ll013mhdmsVDuoIXVfBtvgGJsXDYkTw1kooNcoCXuE0=
github.com/hashicorp/go-secure-stdlib/password v0.1.1 h1:6JzmBqXprakgFEHwBgdchsjaA9x3GyjdI568bXKxa60=
github.com/hashicorp/go-secure-stdlib/password v0.1.1/go.mod h1:9hH302QllNwu1o2TGYtSk8I8kTAN0ca1EHpwhm5Mmzo=
github.com/hashicorp/go-secure-stdlib/permitpool v1.0.0 h1:U6y5MXGiDVOOtkWJ6o/tu1TxABnI0yKTQWJr7z6BpNk=
Expand Down
5 changes: 3 additions & 2 deletions sdk/database/dbplugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"fmt"
"time"

"google.golang.org/grpc"

"github.com/hashicorp/errwrap"
log "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/vault/sdk/helper/consts"
"github.com/hashicorp/vault/sdk/helper/pluginutil"
"google.golang.org/grpc"
)

// Database is the interface that all database objects must implement.
Expand Down
16 changes: 2 additions & 14 deletions sdk/database/dbplugin/v5/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/golang/protobuf/ptypes"

"github.com/hashicorp/vault/sdk/database/dbplugin/v5/proto"
"github.com/hashicorp/vault/sdk/helper/pluginutil"
"github.com/hashicorp/vault/sdk/logical"
Expand All @@ -25,6 +26,7 @@ var (
)

type gRPCClient struct {
entGRPCClient
client proto.DatabaseClient
versionClient logical.PluginVersionClient
doneCtx context.Context
Expand Down Expand Up @@ -285,20 +287,6 @@ func (c gRPCClient) Type() (string, error) {
return typeResp.GetType(), nil
}

func (c gRPCClient) Close() error {
ctx, cancel := getContextWithTimeout(pluginutil.PluginGRPCTimeoutClose)
defer cancel()

_, err := c.client.Close(ctx, &proto.Empty{})
if err != nil {
if c.doneCtx.Err() != nil {
return ErrPluginShutdown
}
return err
}
return nil
}

func getContextWithTimeout(env string) (context.Context, context.CancelFunc) {
timeout := 1 // default timeout
if envTimeout, err := strconv.Atoi(os.Getenv(env)); err == nil && envTimeout > 0 {
Expand Down
27 changes: 27 additions & 0 deletions sdk/database/dbplugin/v5/grpc_client_oss.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

//go:build !enterprise

package dbplugin

import (
"github.com/hashicorp/vault/sdk/database/dbplugin/v5/proto"
"github.com/hashicorp/vault/sdk/helper/pluginutil"
)

type entGRPCClient struct{}

func (c gRPCClient) Close() error {
ctx, cancel := getContextWithTimeout(pluginutil.PluginGRPCTimeoutClose)
defer cancel()

_, err := c.client.Close(ctx, &proto.Empty{})
if err != nil {
if c.doneCtx.Err() != nil {
return ErrPluginShutdown
}
return err
}
return nil
}
31 changes: 31 additions & 0 deletions sdk/database/dbplugin/v5/grpc_client_oss_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

//go:build !enterprise

package dbplugin

import (
"github.com/hashicorp/vault/sdk/database/dbplugin/v5/proto"
)

var _ proto.DatabaseClient = fakeClient{}

type fakeClient struct {
initResp *proto.InitializeResponse
initErr error

newUserResp *proto.NewUserResponse
newUserErr error

updateUserResp *proto.UpdateUserResponse
updateUserErr error

deleteUserResp *proto.DeleteUserResponse
deleteUserErr error

typeResp *proto.TypeResponse
typeErr error

closeErr error
}
21 changes: 1 addition & 20 deletions sdk/database/dbplugin/v5/grpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,26 +518,7 @@ func assertErrEquals(expectedErr error) errorAssertion {
}
}

var _ proto.DatabaseClient = fakeClient{}

type fakeClient struct {
initResp *proto.InitializeResponse
initErr error

newUserResp *proto.NewUserResponse
newUserErr error

updateUserResp *proto.UpdateUserResponse
updateUserErr error

deleteUserResp *proto.DeleteUserResponse
deleteUserErr error

typeResp *proto.TypeResponse
typeErr error

closeErr error
}
// fakeClient methods

func (f fakeClient) Initialize(context.Context, *proto.InitializeRequest, ...grpc.CallOption) (*proto.InitializeResponse, error) {
return f.initResp, f.initErr
Expand Down
39 changes: 0 additions & 39 deletions sdk/database/dbplugin/v5/grpc_database_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
package dbplugin

import (
"context"

"github.com/hashicorp/go-plugin"
"github.com/hashicorp/vault/sdk/database/dbplugin/v5/proto"
"github.com/hashicorp/vault/sdk/helper/pluginutil"
"github.com/hashicorp/vault/sdk/logical"
"google.golang.org/grpc"
)

// handshakeConfigs are used to just do a basic handshake between
Expand All @@ -37,36 +31,3 @@ var (
_ plugin.Plugin = &GRPCDatabasePlugin{}
_ plugin.GRPCPlugin = &GRPCDatabasePlugin{}
)

func (d GRPCDatabasePlugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error {
var server gRPCServer

if d.Impl != nil {
server = gRPCServer{singleImpl: d.Impl}
} else {
// multiplexing is supported
server = gRPCServer{
factoryFunc: d.FactoryFunc,
instances: make(map[string]Database),
}

// Multiplexing is enabled for this plugin, register the server so we
// can tell the client in Vault.
pluginutil.RegisterPluginMultiplexingServer(s, pluginutil.PluginMultiplexingServerImpl{
Supported: true,
})
}

proto.RegisterDatabaseServer(s, &server)
logical.RegisterPluginVersionServer(s, &server)
return nil
}

func (GRPCDatabasePlugin) GRPCClient(doneCtx context.Context, _ *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
client := gRPCClient{
client: proto.NewDatabaseClient(c),
versionClient: logical.NewPluginVersionClient(c),
doneCtx: doneCtx,
}
return client, nil
}
56 changes: 56 additions & 0 deletions sdk/database/dbplugin/v5/grpc_database_plugin_oss.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

//go:build !enterprise

package dbplugin

import (
"context"

"google.golang.org/grpc"

"github.com/hashicorp/go-plugin"
"github.com/hashicorp/vault/sdk/database/dbplugin/v5/proto"
"github.com/hashicorp/vault/sdk/helper/pluginutil"
"github.com/hashicorp/vault/sdk/logical"
)

// GRPCClient (Vault CE edition) initializes and returns a gRPCClient with Database and
// PluginVersion gRPC clients. It implements GRPCClient() defined
// by GRPCPlugin interface in go-plugin/plugin.go
func (GRPCDatabasePlugin) GRPCClient(doneCtx context.Context, _ *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
client := gRPCClient{
client: proto.NewDatabaseClient(c),
versionClient: logical.NewPluginVersionClient(c),
doneCtx: doneCtx,
}
return client, nil
}

// GRPCServer (Vault CE edition) registers multiplexing server if the plugin supports it, and
// registers the Database and PluginVersion gRPC servers. It implements GRPCServer() defined
// by GRPCPlugin interface in go-plugin/plugin.go
func (d GRPCDatabasePlugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error {
var server gRPCServer

if d.Impl != nil {
server = gRPCServer{singleImpl: d.Impl}
} else {
// multiplexing is supported
server = gRPCServer{
factoryFunc: d.FactoryFunc,
instances: make(map[string]Database),
}

// Multiplexing is enabled for this plugin, register the server so we
// can tell the client in Vault.
pluginutil.RegisterPluginMultiplexingServer(s, pluginutil.PluginMultiplexingServerImpl{
Supported: true,
})
}

proto.RegisterDatabaseServer(s, &server)
logical.RegisterPluginVersionServer(s, &server)
return nil
}
Loading

0 comments on commit d8a49be

Please sign in to comment.