skydbstorage

package module
v0.0.0-...-71adcf2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 13 Imported by: 0

README

SkyDB Storage adapter for CertMagic

This project is a fork of DynamoDB Storage adapter for CertMagic, adapted to work with SkyDB.

CertMagic Is an awesome package for doing all the heavy lifting with Let's Encrypt for certificate provisioning and use. In order to be flexible about how you use CertMagic, it has support for various methods of storing certificates. CertMagic has a Storage Interface allowing for multiple storage implementations.

This package is an implementation of the Storage interface that uses DynamoDB for certificate storage. We created this implementation for use in a clustered environment where our application runs in containers behind a load-balancer with no shared filesystem.

Authentication with SkyDB

Work in progress...

License

MIT License

Copyright (c) 2021 Skynet Labs

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	PrimaryKey  string    `json:"PrimaryKey"`
	Contents    []byte    `json:"Contents"`
	LastUpdated time.Time `json:"LastUpdated"`
}

Item holds structure of domain, certificate data, and last updated for marshaling with SkyDB

type Storage

type Storage struct {
	SkyDB               skydb.SkyDBI   `json:"-"`
	LockTimeout         caddy.Duration `json:"lock_timeout,omitempty"`
	LockPollingInterval caddy.Duration `json:"lock_polling_interval,omitempty"`
	KeyListDataKey      crypto.Hash    `json:"key_list_data_key"`
}

Storage implements certmagic.Storage to facilitate storage of certificates in DynamoDB for a clustered environment. Also implements certmagic.Locker to facilitate locking and unlocking of cert data during storage

func NewStorage

func NewStorage() (*Storage, error)

func (Storage) CaddyModule

func (Storage) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Storage) CertMagicStorage

func (s *Storage) CertMagicStorage() (certmagic.Storage, error)

CertMagicStorage converts s to a certmagic.Storage instance.

func (*Storage) Delete

func (s *Storage) Delete(key string) error

Delete deletes key.

func (*Storage) Exists

func (s *Storage) Exists(key string) bool

Exists returns true if the key exists and there was no error checking.

func (*Storage) List

func (s *Storage) List(prefix string, _ bool) ([]string, error)

List returns all keys that match prefix. If recursive is true, non-terminal keys will be enumerated (i.e. "directories" should be walked); otherwise, only keys prefixed exactly by prefix will be listed.

func (*Storage) Load

func (s *Storage) Load(key string) ([]byte, error)

Load retrieves the value at key.

func (*Storage) Lock

func (s *Storage) Lock(ctx context.Context, key string) error

Lock acquires the lock for key, blocking until the lock can be obtained or an error is returned. Note that, even after acquiring a lock, an idempotent operation may have already been performed by another process that acquired the lock before - so always check to make sure idempotent operations still need to be performed after acquiring the lock.

The actual implementation of obtaining of a lock must be an atomic operation so that multiple Lock calls at the same time always results in only one caller receiving the lock at any given time.

To prevent deadlocks, all implementations (where this concern is relevant) should put a reasonable expiration on the lock in case Unlock is unable to be called due to some sort of network failure or system crash.

func (*Storage) Stat

func (s *Storage) Stat(key string) (certmagic.KeyInfo, error)

Stat returns information about key.

func (*Storage) Store

func (s *Storage) Store(key string, value []byte) error

Store puts value at key.

func (*Storage) Unlock

func (s *Storage) Unlock(key string) error

Unlock releases the lock for key. This method must ONLY be called after a successful call to Lock, and only after the critical section is finished, even if it errored or timed out. Unlock cleans up any resources allocated during Lock.

func (*Storage) UnmarshalCaddyfile

func (s *Storage) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the storage module from Caddyfile tokens. Syntax:

skydb {
		key_list_datakey <hex encoded dataKey>
}

Optional. If not provided, the hardcoded key will be used.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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