feat(secret-engines): bws as a secretengine.v1 extension

This commit is contained in:
sam committed 2026-10-04 00:43:02 +10:00
commit 22b4262b01
11 files changed
+753

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
// Package secretengine is what a Go secret-engine extension builds on: the
// generated secretengine.v1 contract and the handshake archie-core launches
// extensions with.
package secretengine
import (
"context"
goplugin "github.com/hashicorp/go-plugin"
"google.golang.org/grpc"
secretenginev1 "github.com/samcharles93/archipelago/sdk/secretengine/v1"
)
const surface = "secretengine"
type plugin struct {
goplugin.NetRPCUnsupportedPlugin
impl secretenginev1.SecretEngineServiceServer
}
func (p *plugin) GRPCServer(_ *goplugin.GRPCBroker, s *grpc.Server) error {
secretenginev1.RegisterSecretEngineServiceServer(s, p.impl)
return nil
}
func (*plugin) GRPCClient(context.Context, *goplugin.GRPCBroker, *grpc.ClientConn) (any, error) {
return nil, nil
}
// Serve runs impl as the extension process. It returns when archie-core stops
// the extension.
func Serve(impl secretenginev1.SecretEngineServiceServer) {
goplugin.Serve(&goplugin.ServeConfig{
HandshakeConfig: goplugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "ARCHIE_EXTENSION",
MagicCookieValue: "archie",
},
Plugins: goplugin.PluginSet{surface: &plugin{impl: impl}},
GRPCServer: goplugin.DefaultGRPCServer,
})
}
+267
View File
@@ -0,0 +1,267 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.11
// protoc (unknown)
// source: secretengine/v1/secretengine.proto
package secretenginev1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
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 ConfigureRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Settings map[string]string `protobuf:"bytes,1,rep,name=settings,proto3" json:"settings,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ConfigureRequest) Reset() {
*x = ConfigureRequest{}
mi := &file_secretengine_v1_secretengine_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ConfigureRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConfigureRequest) ProtoMessage() {}
func (x *ConfigureRequest) ProtoReflect() protoreflect.Message {
mi := &file_secretengine_v1_secretengine_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ConfigureRequest.ProtoReflect.Descriptor instead.
func (*ConfigureRequest) Descriptor() ([]byte, []int) {
return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{0}
}
func (x *ConfigureRequest) GetSettings() map[string]string {
if x != nil {
return x.Settings
}
return nil
}
type ConfigureResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ConfigureResponse) Reset() {
*x = ConfigureResponse{}
mi := &file_secretengine_v1_secretengine_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ConfigureResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConfigureResponse) ProtoMessage() {}
func (x *ConfigureResponse) ProtoReflect() protoreflect.Message {
mi := &file_secretengine_v1_secretengine_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ConfigureResponse.ProtoReflect.Descriptor instead.
func (*ConfigureResponse) Descriptor() ([]byte, []int) {
return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{1}
}
type ResolveRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ResolveRequest) Reset() {
*x = ResolveRequest{}
mi := &file_secretengine_v1_secretengine_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ResolveRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ResolveRequest) ProtoMessage() {}
func (x *ResolveRequest) ProtoReflect() protoreflect.Message {
mi := &file_secretengine_v1_secretengine_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ResolveRequest.ProtoReflect.Descriptor instead.
func (*ResolveRequest) Descriptor() ([]byte, []int) {
return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{2}
}
func (x *ResolveRequest) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
type ResolveResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ResolveResponse) Reset() {
*x = ResolveResponse{}
mi := &file_secretengine_v1_secretengine_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ResolveResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ResolveResponse) ProtoMessage() {}
func (x *ResolveResponse) ProtoReflect() protoreflect.Message {
mi := &file_secretengine_v1_secretengine_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ResolveResponse.ProtoReflect.Descriptor instead.
func (*ResolveResponse) Descriptor() ([]byte, []int) {
return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{3}
}
func (x *ResolveResponse) GetValue() string {
if x != nil {
return x.Value
}
return ""
}
var File_secretengine_v1_secretengine_proto protoreflect.FileDescriptor
const file_secretengine_v1_secretengine_proto_rawDesc = "" +
"\n" +
"\"secretengine/v1/secretengine.proto\x12\x0fsecretengine.v1\"\x9c\x01\n" +
"\x10ConfigureRequest\x12K\n" +
"\bsettings\x18\x01 \x03(\v2/.secretengine.v1.ConfigureRequest.SettingsEntryR\bsettings\x1a;\n" +
"\rSettingsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x13\n" +
"\x11ConfigureResponse\"\"\n" +
"\x0eResolveRequest\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\"'\n" +
"\x0fResolveResponse\x12\x14\n" +
"\x05value\x18\x01 \x01(\tR\x05value2\xb7\x01\n" +
"\x13SecretEngineService\x12R\n" +
"\tConfigure\x12!.secretengine.v1.ConfigureRequest\x1a\".secretengine.v1.ConfigureResponse\x12L\n" +
"\aResolve\x12\x1f.secretengine.v1.ResolveRequest\x1a .secretengine.v1.ResolveResponseB\xcd\x01\n" +
"\x13com.secretengine.v1B\x11SecretengineProtoP\x01ZFgithub.com/samcharles93/archipelago/sdk/secretengine/v1;secretenginev1\xa2\x02\x03SXX\xaa\x02\x0fSecretengine.V1\xca\x02\x0fSecretengine\\V1\xe2\x02\x1bSecretengine\\V1\\GPBMetadata\xea\x02\x10Secretengine::V1b\x06proto3"
var (
file_secretengine_v1_secretengine_proto_rawDescOnce sync.Once
file_secretengine_v1_secretengine_proto_rawDescData []byte
)
func file_secretengine_v1_secretengine_proto_rawDescGZIP() []byte {
file_secretengine_v1_secretengine_proto_rawDescOnce.Do(func() {
file_secretengine_v1_secretengine_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_secretengine_v1_secretengine_proto_rawDesc), len(file_secretengine_v1_secretengine_proto_rawDesc)))
})
return file_secretengine_v1_secretengine_proto_rawDescData
}
var file_secretengine_v1_secretengine_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_secretengine_v1_secretengine_proto_goTypes = []any{
(*ConfigureRequest)(nil), // 0: secretengine.v1.ConfigureRequest
(*ConfigureResponse)(nil), // 1: secretengine.v1.ConfigureResponse
(*ResolveRequest)(nil), // 2: secretengine.v1.ResolveRequest
(*ResolveResponse)(nil), // 3: secretengine.v1.ResolveResponse
nil, // 4: secretengine.v1.ConfigureRequest.SettingsEntry
}
var file_secretengine_v1_secretengine_proto_depIdxs = []int32{
4, // 0: secretengine.v1.ConfigureRequest.settings:type_name -> secretengine.v1.ConfigureRequest.SettingsEntry
0, // 1: secretengine.v1.SecretEngineService.Configure:input_type -> secretengine.v1.ConfigureRequest
2, // 2: secretengine.v1.SecretEngineService.Resolve:input_type -> secretengine.v1.ResolveRequest
1, // 3: secretengine.v1.SecretEngineService.Configure:output_type -> secretengine.v1.ConfigureResponse
3, // 4: secretengine.v1.SecretEngineService.Resolve:output_type -> secretengine.v1.ResolveResponse
3, // [3:5] is the sub-list for method output_type
1, // [1:3] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_secretengine_v1_secretengine_proto_init() }
func file_secretengine_v1_secretengine_proto_init() {
if File_secretengine_v1_secretengine_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_secretengine_v1_secretengine_proto_rawDesc), len(file_secretengine_v1_secretengine_proto_rawDesc)),
NumEnums: 0,
NumMessages: 5,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_secretengine_v1_secretengine_proto_goTypes,
DependencyIndexes: file_secretengine_v1_secretengine_proto_depIdxs,
MessageInfos: file_secretengine_v1_secretengine_proto_msgTypes,
}.Build()
File_secretengine_v1_secretengine_proto = out.File
file_secretengine_v1_secretengine_proto_goTypes = nil
file_secretengine_v1_secretengine_proto_depIdxs = nil
}
+175
View File
@@ -0,0 +1,175 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.2
// - protoc (unknown)
// source: secretengine/v1/secretengine.proto
package secretenginev1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
SecretEngineService_Configure_FullMethodName = "/secretengine.v1.SecretEngineService/Configure"
SecretEngineService_Resolve_FullMethodName = "/secretengine.v1.SecretEngineService/Resolve"
)
// SecretEngineServiceClient is the client API for SecretEngineService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// SecretEngineService is the surface a secret-engine extension serves. The
// host launches one plugin process per enabled engine and resolves every
// SecretRef naming that engine through it.
type SecretEngineServiceClient interface {
// Configure hands the engine its settings once, right after launch and
// before any Resolve. It is the only channel for configuration: the plugin
// process does not inherit the host environment.
Configure(ctx context.Context, in *ConfigureRequest, opts ...grpc.CallOption) (*ConfigureResponse, error)
// Resolve returns the value for key. An unknown key is NOT_FOUND.
Resolve(ctx context.Context, in *ResolveRequest, opts ...grpc.CallOption) (*ResolveResponse, error)
}
type secretEngineServiceClient struct {
cc grpc.ClientConnInterface
}
func NewSecretEngineServiceClient(cc grpc.ClientConnInterface) SecretEngineServiceClient {
return &secretEngineServiceClient{cc}
}
func (c *secretEngineServiceClient) Configure(ctx context.Context, in *ConfigureRequest, opts ...grpc.CallOption) (*ConfigureResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ConfigureResponse)
err := c.cc.Invoke(ctx, SecretEngineService_Configure_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *secretEngineServiceClient) Resolve(ctx context.Context, in *ResolveRequest, opts ...grpc.CallOption) (*ResolveResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ResolveResponse)
err := c.cc.Invoke(ctx, SecretEngineService_Resolve_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// SecretEngineServiceServer is the server API for SecretEngineService service.
// All implementations must embed UnimplementedSecretEngineServiceServer
// for forward compatibility.
//
// SecretEngineService is the surface a secret-engine extension serves. The
// host launches one plugin process per enabled engine and resolves every
// SecretRef naming that engine through it.
type SecretEngineServiceServer interface {
// Configure hands the engine its settings once, right after launch and
// before any Resolve. It is the only channel for configuration: the plugin
// process does not inherit the host environment.
Configure(context.Context, *ConfigureRequest) (*ConfigureResponse, error)
// Resolve returns the value for key. An unknown key is NOT_FOUND.
Resolve(context.Context, *ResolveRequest) (*ResolveResponse, error)
mustEmbedUnimplementedSecretEngineServiceServer()
}
// UnimplementedSecretEngineServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedSecretEngineServiceServer struct{}
func (UnimplementedSecretEngineServiceServer) Configure(context.Context, *ConfigureRequest) (*ConfigureResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Configure not implemented")
}
func (UnimplementedSecretEngineServiceServer) Resolve(context.Context, *ResolveRequest) (*ResolveResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Resolve not implemented")
}
func (UnimplementedSecretEngineServiceServer) mustEmbedUnimplementedSecretEngineServiceServer() {}
func (UnimplementedSecretEngineServiceServer) testEmbeddedByValue() {}
// UnsafeSecretEngineServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to SecretEngineServiceServer will
// result in compilation errors.
type UnsafeSecretEngineServiceServer interface {
mustEmbedUnimplementedSecretEngineServiceServer()
}
func RegisterSecretEngineServiceServer(s grpc.ServiceRegistrar, srv SecretEngineServiceServer) {
// If the following call panics, it indicates UnimplementedSecretEngineServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&SecretEngineService_ServiceDesc, srv)
}
func _SecretEngineService_Configure_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ConfigureRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SecretEngineServiceServer).Configure(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: SecretEngineService_Configure_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SecretEngineServiceServer).Configure(ctx, req.(*ConfigureRequest))
}
return interceptor(ctx, in, info, handler)
}
func _SecretEngineService_Resolve_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ResolveRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SecretEngineServiceServer).Resolve(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: SecretEngineService_Resolve_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SecretEngineServiceServer).Resolve(ctx, req.(*ResolveRequest))
}
return interceptor(ctx, in, info, handler)
}
// SecretEngineService_ServiceDesc is the grpc.ServiceDesc for SecretEngineService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var SecretEngineService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "secretengine.v1.SecretEngineService",
HandlerType: (*SecretEngineServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Configure",
Handler: _SecretEngineService_Configure_Handler,
},
{
MethodName: "Resolve",
Handler: _SecretEngineService_Resolve_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "secretengine/v1/secretengine.proto",
}