Documentation ¶
Index ¶
- Constants
- Variables
- type Data
- func (d *Data) AddShare(share string) error
- func (d *Data) Apply(l *raft.Log) interface{}
- func (d *Data) Bootstrap(username, name, desc, passwd, certDN string) (err error)
- func (d *Data) BuildBootstrap() (masterKey []byte, sharedKeys []string, err error)
- func (d *Data) Can(session structs.Session, path, permission string) bool
- func (d *Data) Close() (err error)
- func (d *Data) Delete(k []byte) error
- func (d *Data) DeleteTemporalConfiguration(bucket string) (err error)
- func (d *Data) DeleteVersion(bucket, key string, version uint16) (err error)
- func (d *Data) DeleteVersionFullKey(bucket, key string) (err error)
- func (d *Data) ForEach(fn func(k, v []byte) error) error
- func (d *Data) ForEachPrefix(prefix []byte, fn func(k, v []byte) error) error
- func (d *Data) Get(k []byte) (v []byte, err error)
- func (d *Data) GetCiphered(k, c []byte) (v []byte, err error)
- func (d *Data) GetDataVersion(bucket, key string, version uint16) (data []byte, err error)
- func (d *Data) GetInterface(k []byte, i interface{}) error
- func (d *Data) GetMetadata(bucket, key string) (meta veil.KVMetadata, err error)
- func (d *Data) GetTemporal(bucket, key string) (data []byte, err error)
- func (d *Data) GetTemporalConfiguration(bucket string) (temporal veil.TemporalConfiguration, err error)
- func (d *Data) GetTransit(bucket string, source string) (data []byte, err error)
- func (d *Data) GetVersionCiphered(bucket, key string, version uint16, c []byte) (data []byte, err error)
- func (d *Data) GetVersioned(bucket, key string, version uint16) (data []byte, v uint16, creationDate int64, err error)
- func (d *Data) GetVersionedStruct(bucket, key string, version uint16) (entry veil.KVEntry, err error)
- func (d *Data) Has(k []byte) (exists bool, err error)
- func (d *Data) IsLeader() bool
- func (d *Data) LeaderAddress(timeout time.Duration) (raft.ServerAddress, error)
- func (d *Data) Len() (int64, int64)
- func (d *Data) LoadPolicies() error
- func (d *Data) LoginCertificateList(session structs.Session) (certLogins map[string]veil.LoginCertificate, err error)
- func (d *Data) LoginCertificateSet(key string, loginCertificate veil.LoginCertificate) error
- func (d *Data) LoginWithCertificate(conn *tls.ConnectionState) (session structs.Session, err error)
- func (d *Data) LoginWithPassword(bucket, username, password string) (user structs.User, maxTTL int64, err error)
- func (d *Data) LoginWithPasswordAPI(bucket, username, password string) (user structs.User, err error)
- func (d *Data) Open() (err error)
- func (d *Data) PoliciesAll() (policies map[string]veil.Policy, err error)
- func (d *Data) PoliciesAllByPath() (policies map[string]map[string][]string, err error)
- func (d *Data) PolicyCreate(name string, policy veil.Policy) error
- func (d *Data) PolicyCreateDefault() error
- func (d *Data) PolicyCreateRaft() error
- func (d *Data) PolicyDelete(name string) (err error)
- func (d *Data) PolicyList(session structs.Session) (policies map[string]veil.Policy, err error)
- func (d *Data) RAFTPeers() (peers []veil.Peer)
- func (d *Data) RAFTStart() error
- func (d *Data) RAFTStop() error
- func (d *Data) RaftAnnounce(ctx context.Context, req *cluster.Peer) (*cluster.GenericResponse, error)
- func (d *Data) RaftJoin(ctx context.Context, req *cluster.JoinRequest) (*cluster.Key, error)
- func (d *Data) RaftLeave(ctx context.Context, req *cluster.LeaveRequest) (*cluster.GenericResponse, error)
- func (d *Data) RaftLocalJoin(ctx context.Context, req *cluster.Empty) (*cluster.GenericResponse, error)
- func (d *Data) RaftSeal(ctx context.Context, req *cluster.Empty) (*cluster.GenericResponse, error)
- func (d *Data) RaftTryJoinCluster(remotes []string) error
- func (d *Data) RaftUnseal(ctx context.Context, req *cluster.Key) (*cluster.GenericResponse, error)
- func (d *Data) Resolve(source interface{}) interface{}
- func (d *Data) ResolveByte(source []byte) (destination []byte, err error)
- func (d *Data) ResolveMap(source map[string]interface{}) (destination map[string]interface{})
- func (d *Data) Restore(rc io.ReadCloser) error
- func (d *Data) Seal() (err error)
- func (d *Data) Sealed() bool
- func (d *Data) SessionCreate(bucket, username string, user structs.User, ttl, maxTTL int64) (session structs.Session, err error)
- func (d *Data) SessionDelete(token string) error
- func (d *Data) SessionGet(token string) (session structs.Session, err error)
- func (d *Data) Set(k, v []byte, ttl int64) error
- func (d *Data) SetCiphered(k, v, c []byte, ttl int64) error
- func (d *Data) SetInterface(k []byte, i interface{}, ttl int64) error
- func (d *Data) SetTemporal(bucket, key string, data []byte) error
- func (d *Data) SetTemporalConfiguration(bucket string, temporal veil.TemporalConfiguration) error
- func (d *Data) SetTransit(bucket string, source []byte) (response string, err error)
- func (d *Data) SetVersion(bucket, key string, value []byte) error
- func (d *Data) SetVersionChipered(bucket, key string, value []byte, c []byte) error
- func (d *Data) Snapshot() (raft.FSMSnapshot, error)
- func (d *Data) StrategyCreateDefault() (err error)
- func (d *Data) StrategyGet(bucket string) (strategy veil.LoginStrategy, err error)
- func (d *Data) StrategyList(session structs.Session) (strategies map[string]veil.LoginStrategy, err error)
- func (d *Data) StrategySet(bucket string, strategy veil.LoginStrategy) (err error)
- func (d *Data) Unseal() (err error)
- func (d *Data) UserGet(bucket, username string) (user structs.User, err error)
- func (d *Data) UserList(session structs.Session, strategy string) (users map[string]veil.User, err error)
- func (d *Data) UserSet(bucket, username string, usersimple *veil.User) (err error)
- func (d *Data) WaitForDetectLeader(timeout time.Duration) error
Constants ¶
const ( CmdNone int = iota // if command == 0 the command has a problem or programming error CmdSet CmdDelete CmdJoin CmdLeave )
Commands:
Variables ¶
var ( ErrMalformed = errors.New("malformed") // returned if share is invalid ErrBadCombination = errors.New("bad combination of shares") // returned when shares cannot decrypt the master key ErrNotFound = errors.New("not found") // returned when key/metadata is not found ErrAlreadySealed = errors.New("already sealed") // returned when database still not open )
Shares / key errors
var ( ErrNotLeader = errors.New("not leader") // returned when server is not leader and asked to apply information ErrCouldNotJoin = errors.New("could not join the cluster") ErrNotLeaderInCluster = errors.New("no leader in cluster") ErrSealed = errors.New("cluster is sealed") ErrInvalidReplicationCommand = errors.New("invalid replication command") ErrTimeout = errors.New("timeout") )
RAFT errors
var ( ErrPasswordDoesNotMeetRequirements = errors.New("Password does not meet strategy password requirements") ErrPasswordIsManagedByThirdParty = errors.New("Password is managed by third party") )
user / validation errors
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct { Masterkey []byte // DB: key to open the database RaftID string // RAFT: server id that will be used to identify the server in the cluster sync.RWMutex // mutex for maps / tree cluster.UnimplementedClusterServer // required for implement the GRPC interface // contains filtered or unexported fields }
Data holds the database and its operations
func New ¶
func New(dbPath string, metrics *metrics.Metrics, sharesMin, sharesTotal int, logger *logging.Logging, apiAddr, raftID, raftDir, raftBind, raftCertPath, raftKeyPath, raftCAPath string, raftTimeout int64, raftPeers []string, raftBootstrap bool) *Data
New returns a Data object with the default configuration
func (*Data) AddShare ¶
AddShare adds a share to the array of shares, returns error if verification fails
func (*Data) BuildBootstrap ¶
BuildBootstrap creates a masterkey and its parts, it returns the parts and/or the error if arised
func (*Data) DeleteTemporalConfiguration ¶
DeleteTemporalConfiguration deletes configuration and key
func (*Data) DeleteVersion ¶
DeleteVersion deletes a desired version of the key
func (*Data) DeleteVersionFullKey ¶
DeleteVersionFullKey deletes all remaining versions and the metadata key
func (*Data) ForEachPrefix ¶
ForEachPrefix get all key and value
func (*Data) GetCiphered ¶
GetCiphered returns an ciphered value
func (*Data) GetDataVersion ¶
GetDataVersion retrieves the value from the database as []byte
func (*Data) GetInterface ¶
GetInterface retrieves the requested key and stores the result on the interface passed
func (*Data) GetMetadata ¶
func (d *Data) GetMetadata(bucket, key string) (meta veil.KVMetadata, err error)
GetMetadata retrieves the metadata for the required key
func (*Data) GetTemporal ¶
GetTemporal get the temporal info on the /temporal/:bucket/:id
func (*Data) GetTemporalConfiguration ¶
func (d *Data) GetTemporalConfiguration(bucket string) (temporal veil.TemporalConfiguration, err error)
GetTemporalConfiguration returns the configuration for the temporal store on the bucket `bucket` It will create a new one with default values if not found
func (*Data) GetTransit ¶
GetTransit returns the data decrypted from the encrypted one This endpoint expects the source string to have two parts
<hmac>:<cyphered>
This ensure accuracy of data
func (*Data) GetVersionCiphered ¶
func (d *Data) GetVersionCiphered(bucket, key string, version uint16, c []byte) (data []byte, err error)
GetVersionCiphered retrieves the value from the database and its type to allow its treatment
func (*Data) GetVersioned ¶
func (d *Data) GetVersioned(bucket, key string, version uint16) (data []byte, v uint16, creationDate int64, err error)
GetVersioned returns raw output for the api
func (*Data) GetVersionedStruct ¶
func (d *Data) GetVersionedStruct(bucket, key string, version uint16) (entry veil.KVEntry, err error)
GetVersionedStruct returns a formatted output for the api
func (*Data) LeaderAddress ¶
LeaderAddress returns the current leader address
func (*Data) Len ¶
Len returns the size of lsm and value log files in bytes. It can be used to decide how often to call RunValueLogGC.
func (*Data) LoadPolicies ¶
LoadPolicies loads/refresh the policies from the database this process blocks sessionmgr to ensure no other goroutine tries to read from the paths/permisions radix tree
func (*Data) LoginCertificateList ¶
func (d *Data) LoginCertificateList(session structs.Session) (certLogins map[string]veil.LoginCertificate, err error)
LoginCertificateList returns those certificates the user can read
func (*Data) LoginCertificateSet ¶
func (d *Data) LoginCertificateSet(key string, loginCertificate veil.LoginCertificate) error
LoginCertificateSet creates/updates a login certificate with its policies
func (*Data) LoginWithCertificate ¶
LoginWithCertificate returns a session struct if certificate has associated a policy (so can be used for login)
func (*Data) LoginWithPassword ¶
func (d *Data) LoginWithPassword(bucket, username, password string) (user structs.User, maxTTL int64, err error)
LoginWithPassword tries a login by using the strategy defined by the bucket metadata
func (*Data) LoginWithPasswordAPI ¶
func (d *Data) LoginWithPasswordAPI(bucket, username, password string) (user structs.User, err error)
LoginWithPasswordAPI retrieves from the database the user and try to log in the user X
func (*Data) PoliciesAll ¶
PoliciesAll retrieves all policies from the database
func (*Data) PoliciesAllByPath ¶
PoliciesAllByPath retrieves all policies from the database for radix tree
func (*Data) PolicyCreate ¶
PolicyCreate creates the policy on the database
func (*Data) PolicyCreateDefault ¶
PolicyCreateDefault creates the default policies needed to bootstrap the service
func (*Data) PolicyCreateRaft ¶
PolicyCreateRaft creates the default policies needed to bootstrap the service
func (*Data) PolicyDelete ¶
PolicyDelete ensures policy is not locked so can be deleted
func (*Data) PolicyList ¶
PolicyList returns those policies the user can read
func (*Data) RAFTPeers ¶
RAFTPeers returns the peers as array, as expected by the API (don't want to send more information as ids)
func (*Data) RaftAnnounce ¶
func (d *Data) RaftAnnounce(ctx context.Context, req *cluster.Peer) (*cluster.GenericResponse, error)
RaftAnnounce is the command used to anounce the server into the cluster.
func (*Data) RaftLeave ¶
func (d *Data) RaftLeave(ctx context.Context, req *cluster.LeaveRequest) (*cluster.GenericResponse, error)
RaftLeave leaves the cluster
func (*Data) RaftLocalJoin ¶
func (d *Data) RaftLocalJoin(ctx context.Context, req *cluster.Empty) (*cluster.GenericResponse, error)
RaftLocalJoin is the command received locally that tries to connect to the cluster
func (*Data) RaftTryJoinCluster ¶
RaftTryJoinCluster tries join to the configured remotes, it could fail if remotes are sealed but it's expected
func (*Data) RaftUnseal ¶
RaftUnseal is the command used to receive the unseal key. Executed when leader gets the correctly the shared keys to unseal.
func (*Data) Resolve ¶
func (d *Data) Resolve(source interface{}) interface{}
Resolve iterates over the keys to find commands on values executing them
func (*Data) ResolveByte ¶
ResolveByte takes a []byte, unmarshals, resolves and return marshalled []byte
func (*Data) ResolveMap ¶
ResolveMap iterates over a map
func (*Data) SessionCreate ¶
func (d *Data) SessionCreate(bucket, username string, user structs.User, ttl, maxTTL int64) (session structs.Session, err error)
SessionCreate creates, saves and returns a session object
func (*Data) SessionDelete ¶
SessionDelete removes a session from the database by Token
func (*Data) SessionGet ¶
SessionGet returns a session object
func (*Data) Set ¶
Set send the set/update command to the raft cluster to apply the change on quorum k: key where store the data v: value to store ttl: time in seconds the key will expire
func (*Data) SetCiphered ¶
SetCiphered sets and encrypts the data using the cypher key k: key where store the data v: value to store c: cypher key
func (*Data) SetInterface ¶
SetInterface creates or updates data: k: key where store the data i: interface
func (*Data) SetTemporal ¶
SetTemporal sets the temporal info on the /temporal/:bucket/:key key
func (*Data) SetTemporalConfiguration ¶
func (d *Data) SetTemporalConfiguration(bucket string, temporal veil.TemporalConfiguration) error
SetTemporalConfiguration save the configuration information and creates if not exists a new key for the bucket
func (*Data) SetTransit ¶
SetTransit returns the data source encrypted and signed
func (*Data) SetVersion ¶
SetVersion writes a new version of the data on the desired bucket and key
func (*Data) SetVersionChipered ¶
SetVersionChipered writes a new version of the data on the desired bucket and key
func (*Data) StrategyCreateDefault ¶
StrategyCreateDefault creates the default API strategy, used on the PostBootstrap
func (*Data) StrategyGet ¶
func (d *Data) StrategyGet(bucket string) (strategy veil.LoginStrategy, err error)
StrategyGet retrieves the information about a strategy on the database
func (*Data) StrategyList ¶
func (d *Data) StrategyList(session structs.Session) (strategies map[string]veil.LoginStrategy, err error)
StrategyList returns those strategies the user can read
func (*Data) StrategySet ¶
func (d *Data) StrategySet(bucket string, strategy veil.LoginStrategy) (err error)
StrategySet saves the information about a strategy on the database
func (*Data) Unseal ¶
Unseal tries to start the Data service by unsealing the database by using the master key
func (*Data) UserList ¶
func (d *Data) UserList(session structs.Session, strategy string) (users map[string]veil.User, err error)
UserList returns those users the user can read
Source Files ¶
- admin_bootstrap.go
- admin_login_certificate.go
- admin_login_strategies.go
- admin_policies.go
- admin_seal.go
- admin_sessions.go
- admin_users.go
- data.go
- data_crypt.go
- errors.go
- kv.go
- kv_resolver.go
- kv_versioned.go
- raft.go
- raft_fsm.go
- raft_fsm_backup.go
- raft_grpc.go
- raft_membership.go
- service_temporal.go
- service_transit.go