Documentation ¶
Index ¶
- Variables
- func AutoGeneratePassword(passwordLength int) (string, error)
- func FilterByTag(tag string) func(*account) bool
- func NewAccount(query, password, tag string, insecure bool) (*account, error)
- func NewGroup(name string) (*group, error)
- func SplitQuery(query string) (string, string, error)
- type FileSystem
- type Sherlock
- func (sh *Sherlock) CheckGroupKey(ctx context.Context, query, groupKey string) error
- func (sh *Sherlock) DeleteGroup(ctx context.Context, gid string) error
- func (sh Sherlock) GetAccount(query string, groupKey string) (*account, error)
- func (sh Sherlock) GroupExists(name string) error
- func (sh Sherlock) IsSetUp() error
- func (sh Sherlock) LoadGroup(gid string, groupKey string) (*group, error)
- func (sh Sherlock) ReadRegisteredGroups() ([]string, error)
- func (sh *Sherlock) Setup(groupKey string) error
- func (sh Sherlock) SetupGroup(name string, groupKey string, insecure bool) error
- func (sh Sherlock) UpdateState(ctx context.Context, query, groupKey string, opt StateOption) error
- type StateOption
Constants ¶
This section is empty.
Variables ¶
var ( ErrInsecurePassword = fmt.Errorf("provided password is insecure (use --insecure to ignore this message)") ErrInvalidAccountName = fmt.Errorf("account name must be a consecutive string") ErrMissingValues = fmt.Errorf("account is missing required values") ErrInvalidAccountNameSymbol = fmt.Errorf("account name invalid. Please avoid using '@' character") )
var ( ErrAccountExists = fmt.Errorf("account for group already exists") ErrNoSuchAccount = fmt.Errorf("account not found") ErrInvalidGroupName = fmt.Errorf("group name must be a consecutive string") ErrInvalidGroupNameSymbol = fmt.Errorf("group name invalid. Please avoid using '@' character") )
var ( ErrNotSetup = fmt.Errorf("sherlock needs to bee set-up first (use sherlock setup)") ErrNoSuchGroup = fmt.Errorf("provided group cannot be found (use sherlock add group)") ErrWrongKey = fmt.Errorf("wrong group key") ErrInvalidQuery = fmt.Errorf("invalid query. Query should be %q", "group@account") )
Functions ¶
func AutoGeneratePassword ¶ added in v0.3.2
func FilterByTag ¶
func NewAccount ¶
NewAccount creates a new Account and if insecure=false checks the password strength returning an err if strength security.Low
Types ¶
type FileSystem ¶
type FileSystem interface { InitFs(initVault []byte) error CreateGroup(name string, initVault []byte) error GroupExists(name string) error VaultExists(group string) error ReadGroupVault(group string) ([]byte, error) Delete(ctx context.Context, gid string) error Write(ctx context.Context, gid string, data []byte) error ReadRegisteredGroups() ([]string, error) }
FileSystem declares the functions sherlock requires to interact with the underlying file system
type Sherlock ¶
type Sherlock struct {
// contains filtered or unexported fields
}
func (*Sherlock) CheckGroupKey ¶ added in v0.3.2
CheckGroupKey performs a pre-check to check if groupKey is correct
it should only be used to verify that an inputed groupKey by the user is matching the group the user is trying to access.
func (*Sherlock) DeleteGroup ¶ added in v0.3.2
DeleteGroup irreversible deletes a group from sherlock and the underlying file-system
func (Sherlock) GetAccount ¶
GetAccount looks up the requested account
the lookup is performed through the query (group@account).
func (Sherlock) GroupExists ¶
GroupExists looks up if a group exists within sherlock
func (Sherlock) IsSetUp ¶
IsSetUp verifies that sherlock is operational
to be operational there must be a folder $HOME/.sherlock/group with the default group and an encrypted default vault for which the user has set a group password.
func (Sherlock) LoadGroup ¶
LoadGroup loads a group
it wraps the reading of the group and the decryption functions together
func (Sherlock) ReadRegisteredGroups ¶ added in v0.3.2
ReadRegisteredGroups loads saved groups
func (*Sherlock) Setup ¶
Setup sets the sherlock environment up
the env requires to have an default group with an encrypted default vault sitting in $HOME/.sherlock/group.
func (Sherlock) SetupGroup ¶
SetupGroup creates a new group in sherlock
a group creation will be rejected if the GID already exits, or the groupKey is to weak (if !insecure). The created group will be initialized with an encrypted default vault.
func (Sherlock) UpdateState ¶ added in v0.3.2
UpdateState executes the passed in StateOption to perform state changes on a group
it allows to modify a group/account (adding accounts, changing account) through the passed StateOption.
type StateOption ¶ added in v0.3.2
StateOption describes a function with can alter the state of a group.
func OptAccDelete ¶ added in v0.3.2
func OptAccDelete() StateOption
OptAccDelete returns a StateOption deleting an account if it exists
func OptAccName ¶ added in v0.3.2
func OptAccName(name string) StateOption
OptAccName returns a StateOption to change an account name
func OptAccPassword ¶ added in v0.3.2
func OptAccPassword(password string, insecure bool) StateOption
OptAccPassword returns a StateOption to change an account password
func OptAddAccount ¶ added in v0.3.2
func OptAddAccount(account *account) StateOption
OptAddAccount returns a StateOption allowing to append an account to an group
func OptsAccTag ¶ added in v0.3.2
func OptsAccTag(tag string) StateOption
OptsAccTag returns a StateOption with allows to change the tag field of an account