http

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ConfigType  = "http"
	ServiceName = "ghost.keeper"
)

ConfigType is the type name for the HTTP secrets keeper.

View Source
const (
	Keeper_ListLocations_FullMethodName    = "/ghost.secrets.Keeper/ListLocations"
	Keeper_ListSecrets_FullMethodName      = "/ghost.secrets.Keeper/ListSecrets"
	Keeper_GetSecretsByName_FullMethodName = "/ghost.secrets.Keeper/GetSecretsByName"
	Keeper_GetSecret_FullMethodName        = "/ghost.secrets.Keeper/GetSecret"
	Keeper_SetSecret_FullMethodName        = "/ghost.secrets.Keeper/SetSecret"
	Keeper_CopySecret_FullMethodName       = "/ghost.secrets.Keeper/CopySecret"
	Keeper_MoveSecret_FullMethodName       = "/ghost.secrets.Keeper/MoveSecret"
	Keeper_DeleteSecret_FullMethodName     = "/ghost.secrets.Keeper/DeleteSecret"
	Keeper_GetServiceInfo_FullMethodName   = "/ghost.secrets.Keeper/GetServiceInfo"
)

Variables

View Source
var File_secrets_proto protoreflect.FileDescriptor
View Source
var Keeper_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "ghost.secrets.Keeper",
	HandlerType: (*KeeperServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GetSecret",
			Handler:    _Keeper_GetSecret_Handler,
		},
		{
			MethodName: "SetSecret",
			Handler:    _Keeper_SetSecret_Handler,
		},
		{
			MethodName: "CopySecret",
			Handler:    _Keeper_CopySecret_Handler,
		},
		{
			MethodName: "MoveSecret",
			Handler:    _Keeper_MoveSecret_Handler,
		},
		{
			MethodName: "DeleteSecret",
			Handler:    _Keeper_DeleteSecret_Handler,
		},
		{
			MethodName: "GetServiceInfo",
			Handler:    _Keeper_GetServiceInfo_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "ListLocations",
			Handler:       _Keeper_ListLocations_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "ListSecrets",
			Handler:       _Keeper_ListSecrets_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "GetSecretsByName",
			Handler:       _Keeper_GetSecretsByName_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "secrets.proto",
}

Keeper_ServiceDesc is the grpc.ServiceDesc for Keeper service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func Builder

func Builder(ctx context.Context, c any) (secrets.Keeper, error)

Builder is the builder function for the HTTP secrets keeper.

func MakeHttpServerSocketName added in v0.0.2

func MakeHttpServerSocketName() string

func RegisterKeeperServer

func RegisterKeeperServer(s grpc.ServiceRegistrar, srv KeeperServer)

Types

type ChangeLocationRequest

type ChangeLocationRequest struct {
	Id       string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Location string `protobuf:"bytes,2,opt,name=location,proto3" json:"location,omitempty"`
	// contains filtered or unexported fields
}

ChangeLocationRequest is a request to change the location of a secret, either move or copy, depending on the rpc call made.

func (*ChangeLocationRequest) Descriptor deprecated

func (*ChangeLocationRequest) Descriptor() ([]byte, []int)

Deprecated: Use ChangeLocationRequest.ProtoReflect.Descriptor instead.

func (*ChangeLocationRequest) GetId

func (x *ChangeLocationRequest) GetId() string

func (*ChangeLocationRequest) GetLocation

func (x *ChangeLocationRequest) GetLocation() string

func (*ChangeLocationRequest) ProtoMessage

func (*ChangeLocationRequest) ProtoMessage()

func (*ChangeLocationRequest) ProtoReflect

func (x *ChangeLocationRequest) ProtoReflect() protoreflect.Message

func (*ChangeLocationRequest) Reset

func (x *ChangeLocationRequest) Reset()

func (*ChangeLocationRequest) String

func (x *ChangeLocationRequest) String() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a secret keeper that communicates with the secret keeper service provided in Server.

func NewClient

func NewClient(client KeeperClient) *Client

NewClient creates a new client for the secret keeper service.

func (*Client) CopySecret

func (c *Client) CopySecret(ctx context.Context, id, location string) (secrets.Secret, error)

CopySecret copies the secret with the given ID to the given location in the secret keeper service.

func (*Client) DeleteSecret

func (c *Client) DeleteSecret(ctx context.Context, id string) error

DeleteSecret deletes the secret with the given ID from the secret keeper service.

func (*Client) GetSecret

func (c *Client) GetSecret(ctx context.Context, id string) (secrets.Secret, error)

GetSecret retrieves the secret with the given ID from the secret keeper service.

func (*Client) GetSecretsByName

func (c *Client) GetSecretsByName(ctx context.Context, name string) ([]secrets.Secret, error)

GetSecretsByName retrieves the list of secrets with the given name from the secret keeper service.

func (*Client) ListLocations

func (c *Client) ListLocations(ctx context.Context) ([]string, error)

ListLocations retrieves the list of locations from the secret keeper service.

func (*Client) ListSecrets

func (c *Client) ListSecrets(ctx context.Context, location string) ([]string, error)

ListSecrets retrieves the list of secrets from the secret keeper service.

func (*Client) MoveSecret

func (c *Client) MoveSecret(ctx context.Context, id, location string) (secrets.Secret, error)

MoveSecret moves the secret with the given ID to the given location in the secret keeper service.

func (*Client) SetSecret

func (c *Client) SetSecret(ctx context.Context, secret secrets.Secret) (secrets.Secret, error)

SetSecret stores the given secret in the secret keeper service.

type Config

type Config struct{}

Config is the configuration of the HTTP secrets keeper.

type DeleteSecretRequest

type DeleteSecretRequest struct {
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

DeleteSecretRequest is a request to delete a secret by its ID.

func (*DeleteSecretRequest) Descriptor deprecated

func (*DeleteSecretRequest) Descriptor() ([]byte, []int)

Deprecated: Use DeleteSecretRequest.ProtoReflect.Descriptor instead.

func (*DeleteSecretRequest) GetId

func (x *DeleteSecretRequest) GetId() string

func (*DeleteSecretRequest) ProtoMessage

func (*DeleteSecretRequest) ProtoMessage()

func (*DeleteSecretRequest) ProtoReflect

func (x *DeleteSecretRequest) ProtoReflect() protoreflect.Message

func (*DeleteSecretRequest) Reset

func (x *DeleteSecretRequest) Reset()

func (*DeleteSecretRequest) String

func (x *DeleteSecretRequest) String() string

type GetSecretRequest

type GetSecretRequest struct {
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

GetSecretRequest is a request to get a secret by its ID.

func (*GetSecretRequest) Descriptor deprecated

func (*GetSecretRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetSecretRequest.ProtoReflect.Descriptor instead.

func (*GetSecretRequest) GetId

func (x *GetSecretRequest) GetId() string

func (*GetSecretRequest) ProtoMessage

func (*GetSecretRequest) ProtoMessage()

func (*GetSecretRequest) ProtoReflect

func (x *GetSecretRequest) ProtoReflect() protoreflect.Message

func (*GetSecretRequest) Reset

func (x *GetSecretRequest) Reset()

func (*GetSecretRequest) String

func (x *GetSecretRequest) String() string

type GetSecretsByNameRequest

type GetSecretsByNameRequest struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

GetSecretsByNameRequest is a request to get secrets by their name.

func (*GetSecretsByNameRequest) Descriptor deprecated

func (*GetSecretsByNameRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetSecretsByNameRequest.ProtoReflect.Descriptor instead.

func (*GetSecretsByNameRequest) GetName

func (x *GetSecretsByNameRequest) GetName() string

func (*GetSecretsByNameRequest) ProtoMessage

func (*GetSecretsByNameRequest) ProtoMessage()

func (*GetSecretsByNameRequest) ProtoReflect

func (x *GetSecretsByNameRequest) ProtoReflect() protoreflect.Message

func (*GetSecretsByNameRequest) Reset

func (x *GetSecretsByNameRequest) Reset()

func (*GetSecretsByNameRequest) String

func (x *GetSecretsByNameRequest) String() string

type KeeperClient

type KeeperClient interface {
	// ListLocations lists all locations where secrets are stored.
	ListLocations(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (Keeper_ListLocationsClient, error)
	// ListSecrets lists all secrets stored in a location.
	ListSecrets(ctx context.Context, in *Location, opts ...grpc.CallOption) (Keeper_ListSecretsClient, error)
	// GetSecretsByName gets all secrets with a given name.
	GetSecretsByName(ctx context.Context, in *GetSecretsByNameRequest, opts ...grpc.CallOption) (Keeper_GetSecretsByNameClient, error)
	// GetSecret gets a secret by its ID.
	GetSecret(ctx context.Context, in *GetSecretRequest, opts ...grpc.CallOption) (*Secret, error)
	// SetSecret sets a secret.
	SetSecret(ctx context.Context, in *Secret, opts ...grpc.CallOption) (*Secret, error)
	// CopySecret copies a secret to a new location.
	CopySecret(ctx context.Context, in *ChangeLocationRequest, opts ...grpc.CallOption) (*Secret, error)
	// MoveSecret moves a secret to a new location.
	MoveSecret(ctx context.Context, in *ChangeLocationRequest, opts ...grpc.CallOption) (*Secret, error)
	// DeleteSecret deletes a secret by its ID.
	DeleteSecret(ctx context.Context, in *DeleteSecretRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// GetServiceInfo returns information about the service.
	GetServiceInfo(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ServiceInfo, error)
}

KeeperClient is the client API for Keeper 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.

func BuildServiceClient added in v0.3.0

func BuildServiceClient(ctx context.Context) (KeeperClient, error)

BuildServiceClient builds the gRPC client for the HTTP secrets keeper.

func NewKeeperClient

func NewKeeperClient(cc grpc.ClientConnInterface) KeeperClient

type KeeperServer

type KeeperServer interface {
	// ListLocations lists all locations where secrets are stored.
	ListLocations(*emptypb.Empty, Keeper_ListLocationsServer) error
	// ListSecrets lists all secrets stored in a location.
	ListSecrets(*Location, Keeper_ListSecretsServer) error
	// GetSecretsByName gets all secrets with a given name.
	GetSecretsByName(*GetSecretsByNameRequest, Keeper_GetSecretsByNameServer) error
	// GetSecret gets a secret by its ID.
	GetSecret(context.Context, *GetSecretRequest) (*Secret, error)
	// SetSecret sets a secret.
	SetSecret(context.Context, *Secret) (*Secret, error)
	// CopySecret copies a secret to a new location.
	CopySecret(context.Context, *ChangeLocationRequest) (*Secret, error)
	// MoveSecret moves a secret to a new location.
	MoveSecret(context.Context, *ChangeLocationRequest) (*Secret, error)
	// DeleteSecret deletes a secret by its ID.
	DeleteSecret(context.Context, *DeleteSecretRequest) (*emptypb.Empty, error)
	// GetServiceInfo returns information about the service.
	GetServiceInfo(context.Context, *emptypb.Empty) (*ServiceInfo, error)
	// contains filtered or unexported methods
}

KeeperServer is the server API for Keeper service. All implementations must embed UnimplementedKeeperServer for forward compatibility

type Keeper_GetSecretsByNameClient

type Keeper_GetSecretsByNameClient interface {
	Recv() (*Secret, error)
	grpc.ClientStream
}

type Keeper_GetSecretsByNameServer

type Keeper_GetSecretsByNameServer interface {
	Send(*Secret) error
	grpc.ServerStream
}

type Keeper_ListLocationsClient

type Keeper_ListLocationsClient interface {
	Recv() (*Location, error)
	grpc.ClientStream
}

type Keeper_ListLocationsServer

type Keeper_ListLocationsServer interface {
	Send(*Location) error
	grpc.ServerStream
}

type Keeper_ListSecretsClient

type Keeper_ListSecretsClient interface {
	Recv() (*Secret, error)
	grpc.ClientStream
}

type Keeper_ListSecretsServer

type Keeper_ListSecretsServer interface {
	Send(*Secret) error
	grpc.ServerStream
}

type Location

type Location struct {
	Location string `protobuf:"bytes,1,opt,name=location,proto3" json:"location,omitempty"`
	// contains filtered or unexported fields
}

Location is a location where secrets are stored.

func (*Location) Descriptor deprecated

func (*Location) Descriptor() ([]byte, []int)

Deprecated: Use Location.ProtoReflect.Descriptor instead.

func (*Location) GetLocation

func (x *Location) GetLocation() string

func (*Location) ProtoMessage

func (*Location) ProtoMessage()

func (*Location) ProtoReflect

func (x *Location) ProtoReflect() protoreflect.Message

func (*Location) Reset

func (x *Location) Reset()

func (*Location) String

func (x *Location) String() string

type Secret

type Secret struct {
	Id           string                 `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Name         string                 `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Username     string                 `protobuf:"bytes,3,opt,name=username,proto3" json:"username,omitempty"`
	Password     string                 `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"`
	Type         string                 `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"`
	Fields       map[string]string      `` /* 153-byte string literal not displayed */
	LastModified *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=last_modified,json=lastModified,proto3" json:"last_modified,omitempty"`
	Url          string                 `protobuf:"bytes,8,opt,name=url,proto3" json:"url,omitempty"`
	Location     string                 `protobuf:"bytes,9,opt,name=location,proto3" json:"location,omitempty"`
	// contains filtered or unexported fields
}

Secret represents a secret to exchange with the secrets service.

func FromSecret

func FromSecret(s secrets.Secret) *Secret

FromSecret creates a new protobuf Secret message from the given secret.

func (*Secret) Descriptor deprecated

func (*Secret) Descriptor() ([]byte, []int)

Deprecated: Use Secret.ProtoReflect.Descriptor instead.

func (*Secret) GetFields

func (x *Secret) GetFields() map[string]string

func (*Secret) GetId

func (x *Secret) GetId() string

func (*Secret) GetLastModified

func (x *Secret) GetLastModified() *timestamppb.Timestamp

func (*Secret) GetLocation

func (x *Secret) GetLocation() string

func (*Secret) GetName

func (x *Secret) GetName() string

func (*Secret) GetPassword

func (x *Secret) GetPassword() string

func (*Secret) GetType

func (x *Secret) GetType() string

func (*Secret) GetUrl

func (x *Secret) GetUrl() string

func (*Secret) GetUsername

func (x *Secret) GetUsername() string

func (*Secret) ProtoMessage

func (*Secret) ProtoMessage()

func (*Secret) ProtoReflect

func (x *Secret) ProtoReflect() protoreflect.Message

func (*Secret) Reset

func (x *Secret) Reset()

func (*Secret) String

func (x *Secret) String() string

type SecretWrapper

type SecretWrapper struct {
	*Secret
}

SecretWrapper is a helper that maps the secrets.Secret interface to the protobuf Secret message.

func NewSecretWrapper

func NewSecretWrapper(s *Secret) *SecretWrapper

NewSecretWrapper creates a new secret wrapper for the given protobuf Secret message.

func (*SecretWrapper) DeleteField

func (s *SecretWrapper) DeleteField(name string)

DeleteField deletes the field with the given name.

func (*SecretWrapper) Fields

func (s *SecretWrapper) Fields() map[string]string

Fields returns the fields of the secret.

func (*SecretWrapper) GetField

func (s *SecretWrapper) GetField(name string) string

GetField returns the value of the field with the given name.

func (*SecretWrapper) ID

func (s *SecretWrapper) ID() string

ID returns the ID of the secret.

func (*SecretWrapper) LastModified

func (s *SecretWrapper) LastModified() time.Time

LastModified returns the last modified date of the secret.

func (*SecretWrapper) Location

func (s *SecretWrapper) Location() string

Location returns the location of the secret.

func (*SecretWrapper) Name

func (s *SecretWrapper) Name() string

Name returns the name of the secret.

func (*SecretWrapper) Password

func (s *SecretWrapper) Password() string

Password returns the password of the secret.

func (*SecretWrapper) SetField

func (s *SecretWrapper) SetField(name, value string)

SetField sets the value of the field with the given name.

func (*SecretWrapper) SetFields

func (s *SecretWrapper) SetFields(flds map[string]string)

SetFields sets the fields of the secret.

func (*SecretWrapper) SetName

func (s *SecretWrapper) SetName(name string)

SetName sets the name of the secret.

func (*SecretWrapper) SetPassword

func (s *SecretWrapper) SetPassword(password string)

SetPassword sets the password of the secret.

func (*SecretWrapper) SetType

func (s *SecretWrapper) SetType(typ string)

SetType sets the type of the secret.

func (*SecretWrapper) SetUrl

func (s *SecretWrapper) SetUrl(url *url.URL)

SetUrl sets the URL of the secret.

func (*SecretWrapper) SetUsername

func (s *SecretWrapper) SetUsername(username string)

SetUsername sets the username of the secret.

func (*SecretWrapper) Type

func (s *SecretWrapper) Type() string

Type returns the type of the secret.

func (*SecretWrapper) Url

func (s *SecretWrapper) Url() *url.URL

Url returns the URL of the secret.

func (*SecretWrapper) Username

func (s *SecretWrapper) Username() string

Username returns the username of the secret.

type Server

type Server struct {
	UnimplementedKeeperServer
	secrets.Keeper
	// contains filtered or unexported fields
}

Server gives a secret keeper a gRPC server interface.

func NewServer

func NewServer(
	keeper secrets.Keeper,
	name string,
	enforcementPeriod time.Duration,
	enforcedPolicies []string,
) *Server

NewServer creates a new gRPC server for the wrapped secret keeper.

func (*Server) CopySecret

func (s *Server) CopySecret(
	ctx context.Context,
	req *ChangeLocationRequest,
) (*Secret, error)

CopySecret maps the CopySecret secret keeper call to the gRPC interface.

func (*Server) DeleteSecret

func (s *Server) DeleteSecret(
	ctx context.Context,
	req *DeleteSecretRequest,
) (*empty.Empty, error)

DeleteSecret maps the DeleteSecret secret keeper call to the gRPC interface.

func (*Server) GetSecret

func (s *Server) GetSecret(
	ctx context.Context,
	req *GetSecretRequest,
) (*Secret, error)

GetSecret maps the GetSecret secret keeper call to the gRPC interface.

func (*Server) GetSecretsByName

func (s *Server) GetSecretsByName(
	req *GetSecretsByNameRequest,
	stream Keeper_GetSecretsByNameServer,
) error

GetSecretsByName maps the GetSecretsByName secret keeper call to the gRPC interface.

func (*Server) GetServiceInfo added in v0.3.0

func (s *Server) GetServiceInfo(
	_ context.Context,
	_ *empty.Empty,
) (*ServiceInfo, error)

GetServiceInfo returns the service info for this server.

func (*Server) ListLocations

func (s *Server) ListLocations(
	_ *empty.Empty,
	stream Keeper_ListLocationsServer,
) error

ListLocations maps the ListLocations secret keeper call to the gRPC interface.

func (*Server) ListSecrets

func (s *Server) ListSecrets(
	location *Location,
	stream Keeper_ListSecretsServer,
) error

ListSecrets maps the ListSecrets secret keeper call to the gRPC interface.

func (*Server) MoveSecret

func (s *Server) MoveSecret(
	ctx context.Context,
	req *ChangeLocationRequest,
) (*Secret, error)

MoveSecret maps the MoveSecret secret keeper call to the gRPC interface.

func (*Server) SetSecret

func (s *Server) SetSecret(
	ctx context.Context,
	rpcSec *Secret,
) (*Secret, error)

SetSecret maps the SetSecret secret keeper call to the gRPC interface.

type ServiceInfo added in v0.3.0

type ServiceInfo struct {
	Keeper            string               `protobuf:"bytes,1,opt,name=keeper,proto3" json:"keeper,omitempty"`
	EnforcementPeriod *durationpb.Duration `protobuf:"bytes,2,opt,name=enforcement_period,json=enforcementPeriod,proto3" json:"enforcement_period,omitempty"`
	EnforcedPolicies  []string             `protobuf:"bytes,3,rep,name=enforced_policies,json=enforcedPolicies,proto3" json:"enforced_policies,omitempty"`
	// contains filtered or unexported fields
}

ServiceInfo is information about the service.

func (*ServiceInfo) Descriptor deprecated added in v0.3.0

func (*ServiceInfo) Descriptor() ([]byte, []int)

Deprecated: Use ServiceInfo.ProtoReflect.Descriptor instead.

func (*ServiceInfo) GetEnforcedPolicies added in v0.3.0

func (x *ServiceInfo) GetEnforcedPolicies() []string

func (*ServiceInfo) GetEnforcementPeriod added in v0.3.0

func (x *ServiceInfo) GetEnforcementPeriod() *durationpb.Duration

func (*ServiceInfo) GetKeeper added in v0.3.0

func (x *ServiceInfo) GetKeeper() string

func (*ServiceInfo) ProtoMessage added in v0.3.0

func (*ServiceInfo) ProtoMessage()

func (*ServiceInfo) ProtoReflect added in v0.3.0

func (x *ServiceInfo) ProtoReflect() protoreflect.Message

func (*ServiceInfo) Reset added in v0.3.0

func (x *ServiceInfo) Reset()

func (*ServiceInfo) String added in v0.3.0

func (x *ServiceInfo) String() string

type UnimplementedKeeperServer

type UnimplementedKeeperServer struct {
}

UnimplementedKeeperServer must be embedded to have forward compatible implementations.

func (UnimplementedKeeperServer) CopySecret

func (UnimplementedKeeperServer) DeleteSecret

func (UnimplementedKeeperServer) GetSecret

func (UnimplementedKeeperServer) GetSecretsByName

func (UnimplementedKeeperServer) GetServiceInfo added in v0.3.0

func (UnimplementedKeeperServer) ListLocations

func (UnimplementedKeeperServer) ListSecrets

func (UnimplementedKeeperServer) MoveSecret

func (UnimplementedKeeperServer) SetSecret

type UnsafeKeeperServer

type UnsafeKeeperServer interface {
	// contains filtered or unexported methods
}

UnsafeKeeperServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to KeeperServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL