Documentation ¶
Index ¶
- Variables
- type FilesystemPersistence
- type SafeDumpClient
- type SafeDumpPersistence
- type SafeDumpServer
- func (s *SafeDumpServer) BeginPurgeCron()
- func (s *SafeDumpServer) Close() error
- func (s *SafeDumpServer) CronPurge(ctx context.Context) error
- func (s *SafeDumpServer) DecryptSecret(ctx context.Context, req *pb.DecryptSecretRequest) (*pb.DecryptSecretResponse, error)
- func (s *SafeDumpServer) GetPublicCert(ctx context.Context, req *pb.GetPublicCertRequest) (*pb.GetPublicCertResponse, error)
- func (s *SafeDumpServer) SourceName() string
- type SafeDumpServiceClient
Constants ¶
This section is empty.
Variables ¶
var ( // ErrStorageKeyNotFound returned when object not found in storage ErrStorageKeyNotFound = errors.New("ErrStorageKeyNotFound") // ErrInvalidDate returned when the date is a reason why we won't decrypt ErrInvalidDate = errors.New("ErrInvalidDate") // ErrInvalidRequest returned when an invalid request is received. ErrInvalidRequest = errors.New("ErrInvalidRequest") // ErrInternalError means that an unexpected error occurred. ErrInternalError = errors.New("ErrInternalError") // ErrInvalidConfig means the configuration is not supported. ErrInvalidConfig = errors.New("ErrInvalidConfig") )
Functions ¶
This section is empty.
Types ¶
type FilesystemPersistence ¶
type FilesystemPersistence struct { // Dir is a path to the directory that contains the data Dir string // Immutable means be read-only Immutable bool }
FilesystemPersistence write key/values to the specified directory.
func (*FilesystemPersistence) Load ¶
Load returns value if found, nil otherwise. It should ignore the TTL
type SafeDumpClient ¶
type SafeDumpClient struct { // Server is the server that we talk to Server SafeDumpServiceClient // Storage is used to cache public certs Storage SafeDumpPersistence // SendKnownBadDateToServer allows us to request decryption of files that we know have the wrong TTL. Useful for breakglass utilities. SendKnownBadDateToServer bool }
SafeDumpClient is used to interact with a given server
func CreateClientFromConfiguration ¶
func CreateClientFromConfiguration() (*SafeDumpClient, error)
CreateClientFromConfiguration loads the client configuration file from the standard location, "~/.safedump_config". If no file exists at that location, it will fall back to "/etc/safedump_config", and it that does not exist, we fall back to using a public key server
func (*SafeDumpClient) Close ¶
func (c *SafeDumpClient) Close() error
Close should be called to close all underlying connections
func (*SafeDumpClient) DecryptWithTTL ¶
DecryptWithTTL reads an encrypted header, then decrypts the stream, copying to out. Note that since we don't MAC, we make no guarantees about integrity or authentication. If chunks is set, then look for chunks to decode as part of a larger file, instead of the whole stream. For now, if chunks is set, then the entire input stream is read before processing commences.
func (*SafeDumpClient) EncryptWithTTL ¶
func (c *SafeDumpClient) EncryptWithTTL(ttl time.Time, in io.Reader, out io.Writer, chunk bool) error
EncryptWithTTL will generate a symmetric key, then encrypt this using the specified public key and TTL, write this out, and then apply a stream cipher to in, copying to out. The number of bytes written to out will be the same as those written to in with a small constant number of bytes added to it. If chunk is set, then output is suitable for embedded in a larger file (e.g. log file)
type SafeDumpPersistence ¶
type SafeDumpPersistence interface { // Load returns value if found, nil otherwise Load(ctx context.Context, key []byte) ([]byte, error) // Save sets value // The TTL is a suggestion - and is used for the cleanup function // It should not affect loads. Save(ctx context.Context, key, value []byte, ttl time.Time) error // Delete all content with TTL before this time. Purge(ctx context.Context, now time.Time) error }
SafeDumpPersistence is an abstraction for a persistence layer
type SafeDumpServer ¶
type SafeDumpServer struct { // Storage is a dumb layer that can store and load stuff Storage SafeDumpPersistence // MaxDecryptionPeriod is the maximum length of time the server will commit to being able to decrypt an object encrypted with it's certicates MaxDecryptionPeriod time.Duration // CertificationRotationPeriod is how often a fresh certificate is issued CertificateRotationPeriod time.Duration // OverrideDateChecks, if set, will skip date checks on TTL. This should only be used with breakglass tools that operate on the server directly OverrideDateChecks bool // PurgeOldKeys deletes old keys automatically (assuming cron is started) PurgeOldKeys bool // KeyRetentionPeriod is the period after a key expires that it will be kept anyway // Only used if PurgeOldKeys is set KeyRetentionPeriod time.Duration // contains filtered or unexported fields }
SafeDumpServer is the main server object that can handle the business logic, for the defined gRPC service, regardless of actually protocol and persistence layer
func (*SafeDumpServer) BeginPurgeCron ¶
func (s *SafeDumpServer) BeginPurgeCron()
BeginPurgeCron will start go funcs the purge cron job We run as often as the CertificateRotationPeriod
func (*SafeDumpServer) Close ¶
func (s *SafeDumpServer) Close() error
Close is a no-op for the server, but is required per the interface definition
func (*SafeDumpServer) CronPurge ¶
func (s *SafeDumpServer) CronPurge(ctx context.Context) error
CronPurge should be called regularly
func (*SafeDumpServer) DecryptSecret ¶
func (s *SafeDumpServer) DecryptSecret(ctx context.Context, req *pb.DecryptSecretRequest) (*pb.DecryptSecretResponse, error)
DecryptSecret finds the associated encryption key, and if all matches, decrypts it. Errors returned are ErrInvalidRequest, ErrInvalidDate, ErrInternalError, nil
func (*SafeDumpServer) GetPublicCert ¶
func (s *SafeDumpServer) GetPublicCert(ctx context.Context, req *pb.GetPublicCertRequest) (*pb.GetPublicCertResponse, error)
GetPublicCert is part of the service definition, it returns the current public certificate, rotating if necessary
func (*SafeDumpServer) SourceName ¶
func (s *SafeDumpServer) SourceName() string
SourceName is used to key cache data. Ought not be called in this context
type SafeDumpServiceClient ¶
type SafeDumpServiceClient interface { pb.SafeDumpServiceServer io.Closer // SourceName returns the name of the serving we are connected to. Used to key cached certs. SourceName() string }
SafeDumpServiceClient is to combine a Closer with a Server (which is bascially the same as client)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package pb is a generated protocol buffer package.
|
Package pb is a generated protocol buffer package. |