merged commit for plugin rework, storage bucket sql and proto, storage bucket secret rewrapping, storage bucket repository

This commit is contained in:
Danielle Miu authored and Timothy Messier committed 2023-05-31 12:18:13 +00:00
1 parent 38723f8112
commit a4a14fc7fc
66 files changed
+2332 -980

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package plugin
import (
"context"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/types/subtypes"
)
const StorageDomain = "storage"
func init() {
if err := subtypes.Register(StorageDomain, Subtype, globals.PluginStorageBucketPrefix); err != nil {
panic(err)
}
}
// PublicId prefixes for the resources in the plugin package.
const (
Subtype = subtypes.Subtype("plugin")
)
func newStorageBucketId(ctx context.Context) (string, error) {
const op = "plugin.newStorageBucketId"
id, err := db.NewPublicId(globals.PluginStorageBucketPrefix)
if err != nil {
return "", errors.Wrap(ctx, err, op)
}
return id, nil
}
+38
View File
@@ -0,0 +1,38 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package plugin
import (
"context"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/kms"
)
type Repository struct {
reader db.Reader
writer db.Writer
kms *kms.Kms
}
// NewRepository creates a new Repository. The returned repository is not
// safe for concurrent go routines to access it
func NewRepository(ctx context.Context, r db.Reader, w db.Writer, kms *kms.Kms) (*Repository, error) {
const op = "plugin.NewRepository"
switch {
case r == nil:
return nil, errors.New(ctx, errors.InvalidParameter, op, "nil db.Reader")
case w == nil:
return nil, errors.New(ctx, errors.InvalidParameter, op, "nil db.Writer")
case kms == nil:
return nil, errors.New(ctx, errors.InvalidParameter, op, "nil kms")
}
return &Repository{
reader: r,
writer: w,
kms: kms,
}, nil
}
@@ -0,0 +1,89 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package plugin
import (
"context"
"testing"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/kms"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestRepository_NewRepository(t *testing.T) {
conn, _ := db.TestSetup(t, "postgres")
rw := db.New(conn)
wrapper := db.TestWrapper(t)
kmsCache := kms.TestKms(t, conn, wrapper)
tests := []struct {
name string
in *Repository
want *Repository
wantErrContains string
wantErrCode errors.Code
}{
{
name: "no-reader",
in: &Repository{
writer: rw,
kms: kmsCache,
},
wantErrContains: "nil db.Reader",
wantErrCode: errors.InvalidParameter,
},
{
name: "no-writer",
in: &Repository{
reader: rw,
kms: kmsCache,
},
wantErrContains: "nil db.Writer",
wantErrCode: errors.InvalidParameter,
},
{
name: "no-kms",
in: &Repository{
reader: rw,
writer: rw,
},
wantErrContains: "nil kms",
wantErrCode: errors.InvalidParameter,
},
{
name: "valid-repository",
in: &Repository{
reader: rw,
writer: rw,
kms: kmsCache,
},
want: &Repository{
reader: rw,
writer: rw,
kms: kmsCache,
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
require, assert := require.New(t), assert.New(t)
ctx := context.Background()
repo, err := NewRepository(ctx, tt.in.reader, tt.in.writer, tt.in.kms)
if tt.wantErrContains != "" {
require.ErrorContains(err, tt.wantErrContains)
return
}
require.NoError(err)
assert.Equal(tt.want.reader, repo.reader)
assert.Equal(tt.want.writer, repo.writer)
assert.Equal(tt.want.kms, repo.kms)
})
}
}
+60
View File
@@ -0,0 +1,60 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package plugin
import (
"context"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/kms"
"github.com/hashicorp/boundary/internal/util"
)
const (
storageBucketSecretTablename = "storage_plugin_storage_bucket_secret"
)
func init() {
kms.RegisterTableRewrapFn(storageBucketSecretTablename, storageBucketSecretRewrapFn)
}
// storageBucketRewrapFn provides a kms.Rewrapfn for the StorageBucketSecret type
func storageBucketSecretRewrapFn(ctx context.Context, dataKeyVersionId, scopeId string, reader db.Reader, writer db.Writer, kmsRepo kms.GetWrapperer) error {
const op = "storage.storageBucketRewrapFn"
switch {
case dataKeyVersionId == "":
return errors.New(ctx, errors.InvalidParameter, op, "missing data key version id")
case scopeId == "":
return errors.New(ctx, errors.InvalidParameter, op, "missing scope id")
case util.IsNil(reader):
return errors.New(ctx, errors.InvalidParameter, op, "missing database reader")
case util.IsNil(writer):
return errors.New(ctx, errors.InvalidParameter, op, "missing database writer")
case kmsRepo == nil:
return errors.New(ctx, errors.InvalidParameter, op, "missing kms repository")
}
var secrets []*StorageBucketSecret
// The only index on this table is on the primary key (storage bucket id) and we can't find it that way.
// This is the fastest query we can use without creating a new index on key_id.
if err := reader.SearchWhere(ctx, &secrets, "key_id=?", []any{dataKeyVersionId}, db.WithLimit(-1)); err != nil {
return errors.Wrap(ctx, err, op, errors.WithMsg("failed to query sql for rows that need rewrapping"))
}
wrapper, err := kmsRepo.GetWrapper(ctx, scopeId, kms.KeyPurposeDatabase)
if err != nil {
return errors.Wrap(ctx, err, op, errors.WithMsg("failed to fetch kms wrapper for rewrapping"))
}
for _, secret := range secrets {
if err := secret.decrypt(ctx, wrapper); err != nil {
return errors.Wrap(ctx, err, op, errors.WithMsg("failed to decrypt storage bucket secret"))
}
if err := secret.encrypt(ctx, wrapper); err != nil {
return errors.Wrap(ctx, err, op, errors.WithMsg("failed to re-encrypt storage bucket secret"))
}
if _, err := writer.Update(ctx, secret, []string{"CtSecrets", "KeyId"}, nil); err != nil {
return errors.Wrap(ctx, err, op, errors.WithMsg("failed to update storage bucket secret row with rewrapped fields"))
}
}
return nil
}
+111
View File
@@ -0,0 +1,111 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package plugin
import (
"context"
"errors"
"testing"
"time"
"github.com/DATA-DOG/go-sqlmock"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/kms"
"github.com/hashicorp/boundary/internal/libs/patchstruct"
"github.com/hashicorp/boundary/internal/plugin"
"github.com/hashicorp/boundary/internal/storage/plugin/store"
"github.com/hashicorp/go-kms-wrapping/extras/kms/v2/migrations"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/structpb"
)
func TestRewrap_storageBucketSecretRewrapFn(t *testing.T) {
ctx := context.Background()
t.Run("errors-on-query-error", func(t *testing.T) {
conn, mock := db.TestSetupWithMock(t)
wrapper := db.TestWrapper(t)
mock.ExpectQuery(
`SELECT \* FROM "kms_schema_version" WHERE 1=1 ORDER BY "kms_schema_version"\."version" LIMIT 1`,
).WillReturnRows(sqlmock.NewRows([]string{"version", "create_time"}).AddRow(migrations.Version, time.Now()))
kmsCache := kms.TestKms(t, conn, wrapper)
rw := db.New(conn)
mock.ExpectQuery(
`SELECT \* FROM "storage_plugin_storage_bucket_secret" WHERE key_id=\$1`,
).WillReturnError(errors.New("Query error"))
err := storageBucketSecretRewrapFn(ctx, "some_id", "some_scope", rw, rw, kmsCache)
require.Error(t, err)
})
t.Run("success", func(t *testing.T) {
require, assert := require.New(t), assert.New(t)
conn, _ := db.TestSetup(t, "postgres")
rw := db.New(conn)
wrapper := db.TestWrapper(t)
org, _ := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
plg := plugin.TestPlugin(t, conn, "test", plugin.WithStorageFlag(true))
kmsCache := kms.TestKms(t, conn, wrapper)
sb := &StorageBucket{
StorageBucket: &store.StorageBucket{
ScopeId: org.PublicId,
PluginId: plg.PublicId,
BucketName: "test-bucket-name",
Attributes: []byte{},
SecretsHmac: []byte("test"),
WorkerFilter: "test worker filter",
},
Secrets: &structpb.Struct{
Fields: map[string]*structpb.Value{
"AWS_ACCESS_KEY_ID": structpb.NewStringValue("access_key_id"),
"AWS_SECRET_ACCESS_KEY": structpb.NewStringValue("secret_access_key"),
},
},
}
// first store bucket
var err error
sb.PublicId, err = newStorageBucketId(ctx)
require.NoError(err)
sb.Attributes, err = patchstruct.PatchBytes([]byte{}, sb.Attributes)
require.NoError(err)
require.NoError(rw.Create(ctx, sb))
// now store secret
cred, err := newStorageBucketSecret(ctx, sb.PublicId, sb.Secrets)
require.NoError(err)
kmsWrapper1, err := kmsCache.GetWrapper(context.Background(), org.GetPublicId(), 1)
require.NoError(err)
require.NoError(cred.encrypt(ctx, kmsWrapper1))
require.NoError(rw.Create(ctx, cred))
assert.NoError(cred.decrypt(ctx, kmsWrapper1))
// now things are stored in the db, we can rotate and rewrap
require.NoError(kmsCache.RotateKeys(ctx, org.Scope.GetPublicId()))
require.NoError(storageBucketSecretRewrapFn(ctx, cred.KeyId, org.Scope.GetPublicId(), rw, rw, kmsCache))
// now we pull the config back from the db, decrypt it with the new key, and ensure things match
got := &StorageBucketSecret{
StorageBucketSecret: &store.StorageBucketSecret{
StorageBucketId: sb.PublicId,
},
}
assert.NoError(rw.LookupById(ctx, got))
// fetch the new key version
kmsWrapper2, err := kmsCache.GetWrapper(ctx, org.Scope.GetPublicId(), kms.KeyPurposeDatabase, kms.WithKeyId(got.GetKeyId()))
assert.NoError(err)
newKeyVersion, err := kmsWrapper2.KeyId(ctx)
assert.NoError(err)
// decrypt with the new key version and check to make sure things match
assert.NoError(got.decrypt(ctx, kmsWrapper2))
assert.NotEmpty(got.GetKeyId())
assert.NotEqual(cred.GetKeyId(), got.GetKeyId())
assert.Equal(newKeyVersion, got.GetKeyId())
assert.Equal(cred.Secrets, got.GetSecrets())
})
}
+239
View File
@@ -0,0 +1,239 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package plugin
import (
"context"
"github.com/hashicorp/boundary/internal/db/timestamp"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/libs/crypto"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/storage/plugin/store"
"github.com/hashicorp/boundary/internal/util"
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
"github.com/hashicorp/go-kms-wrapping/v2/extras/structwrapping"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/structpb"
)
// StorageBucket represents a bucket within an external object store. It contains secret
// data needed to create and read objects within the external object store.
type StorageBucket struct {
*store.StorageBucket
tableName string `gorm:"-"`
Secrets *structpb.Struct `gorm:"-"`
}
func allocStorageBucket() *StorageBucket {
return &StorageBucket{
StorageBucket: &store.StorageBucket{},
}
}
// clone provides a deep copy of the storage bucket with the exception of the
// secret. The secret shallow copied.
func (s *StorageBucket) clone() *StorageBucket {
cp := proto.Clone(s.StorageBucket)
newSecret := proto.Clone(s.Secrets)
sb := &StorageBucket{
StorageBucket: cp.(*store.StorageBucket),
Secrets: newSecret.(*structpb.Struct),
}
// proto.Clone will convert slices with length and capacity of 0 to nil.
// Fix this since gorm treats empty slices differently than nil.
if s.Attributes != nil && len(s.Attributes) == 0 && sb.Attributes == nil {
sb.Attributes = []byte{}
}
return sb
}
// TableName returns the table name for the storage bucket.
func (s *StorageBucket) TableName() string {
if s.tableName != "" {
return s.tableName
}
return "storage_plugin_storage_bucket"
}
// SetTableName sets the table name.
func (s *StorageBucket) SetTableName(n string) {
s.tableName = n
}
func (s *StorageBucket) oplog(op oplog.OpType) oplog.Metadata {
metadata := oplog.Metadata{
"resource-public-id": []string{s.PublicId},
"resource-type": []string{"plugin-storage-bucket"},
"op-type": []string{op.String()},
}
if s.ScopeId != "" {
metadata["scope-id"] = []string{s.ScopeId}
}
return metadata
}
type StorageBucketSecret struct {
*store.StorageBucketSecret
tableName string `gorm:"-"`
}
func allocStorageBucketSecret() *StorageBucketSecret {
return &StorageBucketSecret{
StorageBucketSecret: &store.StorageBucketSecret{},
}
}
// newStorageBucketSecret creates an in memory storage bucket secret from a json
// formatted generic struct.
func newStorageBucketSecret(ctx context.Context, storageBucketId string, secret *structpb.Struct) (*StorageBucketSecret, error) {
const op = "plugin.newStorageBucketSecret"
s := &StorageBucketSecret{
StorageBucketSecret: &store.StorageBucketSecret{
StorageBucketId: storageBucketId,
},
}
if secret != nil {
sec, err := proto.Marshal(secret)
if err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithCode(errors.InvalidParameter))
}
s.Secrets = sec
}
return s, nil
}
func (sbs *StorageBucketSecret) clone() *StorageBucketSecret {
cp := proto.Clone(sbs.StorageBucketSecret)
return &StorageBucketSecret{
StorageBucketSecret: cp.(*store.StorageBucketSecret),
}
}
// TableName returns the table name for the storage bucket secrets.
func (sbs *StorageBucketSecret) TableName() string {
if sbs.tableName != "" {
return sbs.tableName
}
return "storage_plugin_storage_bucket_secret"
}
// SetTableName sets the table name.
func (sbs *StorageBucketSecret) SetTableName(n string) {
sbs.tableName = n
}
// hmacField simply hmac's a field in a consistent manner for this pkg
func hmacField(ctx context.Context, cipher wrapping.Wrapper, field []byte, publicId string) ([]byte, error) {
const op = "plugin.hmacField"
hm, err := crypto.HmacSha256(ctx, field, cipher, []byte(publicId), nil)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
return []byte(hm), nil
}
// only hmac's the secret's value. does not modify the underlying secret
// returns nil on failure
func (sbs *StorageBucketSecret) hmacSecrets(ctx context.Context, cipher wrapping.Wrapper) ([]byte, error) {
const op = "plugin.(StorageBucketSecret).hmacSecrets"
if cipher == nil {
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing cipher")
}
var err error
if _, err = cipher.KeyId(ctx); err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithCode(errors.Encrypt), errors.WithMsg("failed to read cipher key id"))
}
var hmac []byte
if hmac, err = hmacField(ctx, cipher, sbs.Secrets, sbs.StorageBucketId); err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithCode(errors.Encrypt), errors.WithMsg("failed to hmac secrets"))
}
return hmac, nil
}
// encrypt the bind credential before writing it to the database
func (sbs *StorageBucketSecret) encrypt(ctx context.Context, cipher wrapping.Wrapper) error {
const op = "plugin.(StorageBucketSecret).encrypt"
if util.IsNil(cipher) {
return errors.New(ctx, errors.InvalidParameter, op, "missing cipher")
}
if err := structwrapping.WrapStruct(ctx, cipher, sbs.StorageBucketSecret); err != nil {
return errors.Wrap(ctx, err, op, errors.WithCode(errors.Encrypt))
}
var err error
if sbs.KeyId, err = cipher.KeyId(ctx); err != nil {
return errors.Wrap(ctx, err, op, errors.WithCode(errors.Encrypt), errors.WithMsg("failed to read cipher key id"))
}
return nil
}
func (sbs *StorageBucketSecret) decrypt(ctx context.Context, cipher wrapping.Wrapper) error {
const op = "plugin.(StorageBucketSecret).decrypt"
if util.IsNil(cipher) {
return errors.New(ctx, errors.InvalidParameter, op, "missing cipher")
}
if err := structwrapping.UnwrapStruct(ctx, cipher, sbs.StorageBucketSecret, nil); err != nil {
return errors.Wrap(ctx, err, op, errors.WithCode(errors.Decrypt))
}
sbs.CtSecrets = nil
return nil
}
type storageBucketAgg struct {
PublicId string `gorm:"primary_key"`
ScopeId string
Name string
Description string
CreateTime *timestamp.Timestamp
UpdateTime *timestamp.Timestamp
Version uint32
PluginId string
BucketName string
BucketPrefix string
WorkerFilter string
Attributes []byte
SecretsEncrypted []byte
SecretsHmac []byte
KeyId string
}
// TableName returns the table name for gorm
func (sba *storageBucketAgg) TableName() string {
return "storage_plugin_storage_bucket_with_secret"
}
func (sba *storageBucketAgg) GetPublicId() string {
return sba.PublicId
}
func (sba *storageBucketAgg) toStorageBucketAndSecret() (*StorageBucket, *StorageBucketSecret) {
sb := allocStorageBucket()
sb.PublicId = sba.PublicId
sb.ScopeId = sba.ScopeId
sb.Name = sba.Name
sb.Description = sba.Description
sb.CreateTime = sba.CreateTime
sb.UpdateTime = sba.UpdateTime
sb.Version = sba.Version
sb.PluginId = sba.PluginId
sb.BucketName = sba.BucketName
sb.BucketPrefix = sba.BucketPrefix
sb.WorkerFilter = sba.WorkerFilter
sb.Attributes = sba.Attributes
sb.SecretsHmac = sba.SecretsHmac
var sbs *StorageBucketSecret
if len(sba.SecretsEncrypted) > 0 {
sbs = allocStorageBucketSecret()
sbs.StorageBucketId = sba.PublicId
sbs.CtSecrets = sba.SecretsEncrypted
sbs.KeyId = sba.KeyId
}
return sb, sbs
}
+423
View File
@@ -0,0 +1,423 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.30.0
// protoc (unknown)
// source: controller/storage/storage/plugin/store/v1/storage.proto
// Package store provides protobufs for storing types in the storage plugin
// package.
package store
import (
timestamp "github.com/hashicorp/boundary/internal/db/timestamp"
_ "github.com/hashicorp/boundary/sdk/pbs/controller/protooptions"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type StorageBucket struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// public_id is a surrogate key suitable for use in a public API.
// @inject_tag: `gorm:"primary_key"`
PublicId string `protobuf:"bytes,1,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty" gorm:"primary_key"`
// The scope_id of the owning scope and must be set.
// @inject_tag: `gorm:"not_null"`
ScopeId string `protobuf:"bytes,2,opt,name=scope_id,json=scopeId,proto3" json:"scope_id,omitempty" gorm:"not_null"`
// name is optional. If set, it must be globally unique.
// @inject_tag: `gorm:"default:null"`
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" gorm:"default:null"`
// description is optional.
// @inject_tag: `gorm:"default:null"`
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty" gorm:"default:null"`
// The create_time is set by the database.
// @inject_tag: `gorm:"default:current_timestamp"`
CreateTime *timestamp.Timestamp `protobuf:"bytes,5,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"`
// The update_time is set by the database.
// @inject_tag: `gorm:"default:current_timestamp"`
UpdateTime *timestamp.Timestamp `protobuf:"bytes,6,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"`
// @inject_tag: `gorm:"default:null"`
Version uint32 `protobuf:"varint,7,opt,name=version,proto3" json:"version,omitempty" gorm:"default:null"`
// The plugin_id is the public id of the plugin managing this storage bucket.
// @inject_tag: `gorm:"not_null"`
PluginId string `protobuf:"bytes,8,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty" gorm:"not_null"`
// The name of the external storage bucket (as opposed to the name within boundary)
// @inject_tag: `gorm:"not_null"`
BucketName string `protobuf:"bytes,9,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty" gorm:"not_null"`
// @inject_tag: `gorm:"default:null"`
BucketPrefix string `protobuf:"bytes,10,opt,name=bucket_prefix,json=bucketPrefix,proto3" json:"bucket_prefix,omitempty" gorm:"default:null"`
// A boolean expression that allows filtering the workers that can handle a storage buckets
// @inject_tag: `gorm:"not_null"`
WorkerFilter string `protobuf:"bytes,11,opt,name=worker_filter,json=workerFilter,proto3" json:"worker_filter,omitempty" gorm:"not_null"`
// attributes is a json formatted field.
// @inject_tag: `gorm:"not_null"`
Attributes []byte `protobuf:"bytes,12,opt,name=attributes,proto3" json:"attributes,omitempty" gorm:"not_null"`
// secrets_hmac is a sha256-hmac of the unencrypted secrets stored in the db.
// @inject_tag: `gorm:"not_null"`
SecretsHmac []byte `protobuf:"bytes,13,opt,name=secrets_hmac,json=secretsHmac,proto3" json:"secrets_hmac,omitempty" gorm:"not_null"`
}
func (x *StorageBucket) Reset() {
*x = StorageBucket{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_storage_storage_plugin_store_v1_storage_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StorageBucket) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StorageBucket) ProtoMessage() {}
func (x *StorageBucket) ProtoReflect() protoreflect.Message {
mi := &file_controller_storage_storage_plugin_store_v1_storage_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StorageBucket.ProtoReflect.Descriptor instead.
func (*StorageBucket) Descriptor() ([]byte, []int) {
return file_controller_storage_storage_plugin_store_v1_storage_proto_rawDescGZIP(), []int{0}
}
func (x *StorageBucket) GetPublicId() string {
if x != nil {
return x.PublicId
}
return ""
}
func (x *StorageBucket) GetScopeId() string {
if x != nil {
return x.ScopeId
}
return ""
}
func (x *StorageBucket) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *StorageBucket) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
func (x *StorageBucket) GetCreateTime() *timestamp.Timestamp {
if x != nil {
return x.CreateTime
}
return nil
}
func (x *StorageBucket) GetUpdateTime() *timestamp.Timestamp {
if x != nil {
return x.UpdateTime
}
return nil
}
func (x *StorageBucket) GetVersion() uint32 {
if x != nil {
return x.Version
}
return 0
}
func (x *StorageBucket) GetPluginId() string {
if x != nil {
return x.PluginId
}
return ""
}
func (x *StorageBucket) GetBucketName() string {
if x != nil {
return x.BucketName
}
return ""
}
func (x *StorageBucket) GetBucketPrefix() string {
if x != nil {
return x.BucketPrefix
}
return ""
}
func (x *StorageBucket) GetWorkerFilter() string {
if x != nil {
return x.WorkerFilter
}
return ""
}
func (x *StorageBucket) GetAttributes() []byte {
if x != nil {
return x.Attributes
}
return nil
}
func (x *StorageBucket) GetSecretsHmac() []byte {
if x != nil {
return x.SecretsHmac
}
return nil
}
type StorageBucketSecret struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// storage_bucket_id is the public id of the storage bucket using this secret.
// @inject_tag: `gorm:"primary_key"`
StorageBucketId string `protobuf:"bytes,1,opt,name=storage_bucket_id,json=storageBucketId,proto3" json:"storage_bucket_id,omitempty" gorm:"primary_key"`
// secrets is the plain-text of the secret data. We are not storing this plain-text
// value in the database.
// @inject_tag: `gorm:"-" wrapping:"pt,secrets_data"`
Secrets []byte `protobuf:"bytes,2,opt,name=secrets,proto3" json:"secrets,omitempty" gorm:"-" wrapping:"pt,secrets_data"`
// ct_secrets is the ciphertext of the secret data stored in the db.
// @inject_tag: `gorm:"column:secrets_encrypted;not_null" wrapping:"ct,secrets_data"`
CtSecrets []byte `protobuf:"bytes,3,opt,name=ct_secrets,json=ctSecrets,proto3" json:"ct_secrets,omitempty" gorm:"column:secrets_encrypted;not_null" wrapping:"ct,secrets_data"`
// The key_id of the kms database key used for encrypting this entry.
// It must be set.
// @inject_tag: `gorm:"not_null"`
KeyId string `protobuf:"bytes,4,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty" gorm:"not_null"`
}
func (x *StorageBucketSecret) Reset() {
*x = StorageBucketSecret{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_storage_storage_plugin_store_v1_storage_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StorageBucketSecret) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StorageBucketSecret) ProtoMessage() {}
func (x *StorageBucketSecret) ProtoReflect() protoreflect.Message {
mi := &file_controller_storage_storage_plugin_store_v1_storage_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StorageBucketSecret.ProtoReflect.Descriptor instead.
func (*StorageBucketSecret) Descriptor() ([]byte, []int) {
return file_controller_storage_storage_plugin_store_v1_storage_proto_rawDescGZIP(), []int{1}
}
func (x *StorageBucketSecret) GetStorageBucketId() string {
if x != nil {
return x.StorageBucketId
}
return ""
}
func (x *StorageBucketSecret) GetSecrets() []byte {
if x != nil {
return x.Secrets
}
return nil
}
func (x *StorageBucketSecret) GetCtSecrets() []byte {
if x != nil {
return x.CtSecrets
}
return nil
}
func (x *StorageBucketSecret) GetKeyId() string {
if x != nil {
return x.KeyId
}
return ""
}
var File_controller_storage_storage_plugin_store_v1_storage_proto protoreflect.FileDescriptor
var file_controller_storage_storage_plugin_store_v1_storage_proto_rawDesc = []byte{
0x0a, 0x38, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x6f,
0x72, 0x61, 0x67, 0x65, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6c, 0x75,
0x67, 0x69, 0x6e, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x6f,
0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2a, 0x63, 0x6f, 0x6e, 0x74,
0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x73,
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x73, 0x74,
0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x2a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c,
0x65, 0x72, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x1a, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73,
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70,
0x2f, 0x76, 0x31, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0xae, 0x04, 0x0a, 0x0d, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x42,
0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63,
0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x64, 0x12, 0x24, 0x0a,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x10, 0xc2, 0xdd, 0x29,
0x0c, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69,
0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1e, 0xc2, 0xdd, 0x29, 0x1a, 0x0a, 0x0b,
0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x64, 0x65, 0x73,
0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69,
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f,
0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e,
0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e,
0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d,
0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69,
0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d,
0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f,
0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d,
0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74,
0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12,
0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d,
0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x6c, 0x75,
0x67, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c,
0x75, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74,
0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x75, 0x63,
0x6b, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x62, 0x75, 0x63, 0x6b, 0x65,
0x74, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c,
0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x23, 0x0a, 0x0d,
0x77, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x0b, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0c, 0x77, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x46, 0x69, 0x6c, 0x74, 0x65,
0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18,
0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65,
0x73, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x73, 0x5f, 0x68, 0x6d, 0x61,
0x63, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x73,
0x48, 0x6d, 0x61, 0x63, 0x22, 0x91, 0x01, 0x0a, 0x13, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65,
0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x2a, 0x0a, 0x11,
0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65,
0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x63, 0x72,
0x65, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x73, 0x65, 0x63, 0x72, 0x65,
0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x73,
0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x63, 0x74, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74,
0x73, 0x12, 0x15, 0x0a, 0x06, 0x6b, 0x65, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28,
0x09, 0x52, 0x05, 0x6b, 0x65, 0x79, 0x49, 0x64, 0x42, 0x43, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70,
0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
0x61, 0x6c, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69,
0x6e, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_controller_storage_storage_plugin_store_v1_storage_proto_rawDescOnce sync.Once
file_controller_storage_storage_plugin_store_v1_storage_proto_rawDescData = file_controller_storage_storage_plugin_store_v1_storage_proto_rawDesc
)
func file_controller_storage_storage_plugin_store_v1_storage_proto_rawDescGZIP() []byte {
file_controller_storage_storage_plugin_store_v1_storage_proto_rawDescOnce.Do(func() {
file_controller_storage_storage_plugin_store_v1_storage_proto_rawDescData = protoimpl.X.CompressGZIP(file_controller_storage_storage_plugin_store_v1_storage_proto_rawDescData)
})
return file_controller_storage_storage_plugin_store_v1_storage_proto_rawDescData
}
var file_controller_storage_storage_plugin_store_v1_storage_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_controller_storage_storage_plugin_store_v1_storage_proto_goTypes = []interface{}{
(*StorageBucket)(nil), // 0: controller.storage.storage.plugin.store.v1.StorageBucket
(*StorageBucketSecret)(nil), // 1: controller.storage.storage.plugin.store.v1.StorageBucketSecret
(*timestamp.Timestamp)(nil), // 2: controller.storage.timestamp.v1.Timestamp
}
var file_controller_storage_storage_plugin_store_v1_storage_proto_depIdxs = []int32{
2, // 0: controller.storage.storage.plugin.store.v1.StorageBucket.create_time:type_name -> controller.storage.timestamp.v1.Timestamp
2, // 1: controller.storage.storage.plugin.store.v1.StorageBucket.update_time:type_name -> controller.storage.timestamp.v1.Timestamp
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_controller_storage_storage_plugin_store_v1_storage_proto_init() }
func file_controller_storage_storage_plugin_store_v1_storage_proto_init() {
if File_controller_storage_storage_plugin_store_v1_storage_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_storage_storage_plugin_store_v1_storage_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StorageBucket); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_controller_storage_storage_plugin_store_v1_storage_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StorageBucketSecret); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_controller_storage_storage_plugin_store_v1_storage_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_controller_storage_storage_plugin_store_v1_storage_proto_goTypes,
DependencyIndexes: file_controller_storage_storage_plugin_store_v1_storage_proto_depIdxs,
MessageInfos: file_controller_storage_storage_plugin_store_v1_storage_proto_msgTypes,
}.Build()
File_controller_storage_storage_plugin_store_v1_storage_proto = out.File
file_controller_storage_storage_plugin_store_v1_storage_proto_rawDesc = nil
file_controller_storage_storage_plugin_store_v1_storage_proto_goTypes = nil
file_controller_storage_storage_plugin_store_v1_storage_proto_depIdxs = nil
}