Documentation ¶
Index ¶
- Constants
- func AddDevice(wid types.UUID, devid types.UUID, devkey ezn.CryptoString, status string) error
- func AddEntry(entry *keycard.Entry) error
- func AddFolderEntry(wid types.UUID, serverPath string, clientPath ezn.CryptoString) error
- func AddSyncRecord(wid string, rec UpdateRecord) error
- func AddWorkspace(wid string, uid string, domain string, password string, status string, ...) error
- func CheckDevice(wid types.UUID, devid types.UUID, devkey ezn.CryptoString) (bool, error)
- func CheckLockout(failType string, id string, source string) (string, error)
- func CheckPasscode(wid types.UUID, passcode string) (bool, error)
- func CheckPassword(wid types.UUID, password string) (bool, error)
- func CheckRegCode(addr types.MAddress, regcode string) (string, string, error)
- func CheckUserID(uid types.UserID) (bool, string)
- func CheckWorkspace(wid string) (bool, string)
- func Connect()
- func CountSyncRecords(wid string, unixtime int64) (int64, error)
- func CullOldSyncRecords(wid string, unixtime int64) error
- func DeletePasscode(wid types.UUID, passcode string) error
- func DeleteRegCode(addr types.MAddress, regcode string) error
- func Disconnect()
- func GetAliases(wid types.UUID) (gostringlist.StringList, error)
- func GetEncryptionPair() (*ezn.EncryptionPair, error)
- func GetLastLogin(wid types.UUID, devid types.UUID) (int64, error)
- func GetOrgEntries(startIndex int, endIndex int) ([]string, error)
- func GetOrgKeycard() (keycard.Keycard, error)
- func GetPrimarySigningPair() (*ezn.SigningPair, error)
- func GetQuotaInfo(wid types.UUID) (uint64, uint64, error)
- func GetUserEntries(wid types.UUID, startIndex int, endIndex int) ([]string, error)
- func GetUserKeycard(wid types.UUID) (keycard.Keycard, error)
- func IsAlias(wid string) (bool, error)
- func IsConnected() bool
- func IsDomainLocal(domain types.DomainT) (bool, error)
- func LogFailure(failType string, wid types.UUID, sourceip string) error
- func ModifyQuotaUsage(wid types.UUID, amount int64) (uint64, error)
- func PreregWorkspace(wid types.UUID, uid types.UserID, domain types.DomainT, ...) (string, error)
- func RemoveDevice(wid types.UUID, devid types.UUID) (bool, error)
- func RemoveExpiredPasscodes() error
- func RemoveFolderEntry(wid types.UUID, serverPath string) error
- func RemoveWorkspace(wid string) error
- func ResetPassword(wid types.UUID, passcode string, expires string) error
- func ResetQuotaUsage() error
- func ResolveAddress(addr types.MAddress) (types.UUID, error)
- func ResolveWID(wid types.UUID) (types.WAddress, error)
- func SetPassword(wid types.UUID, password string) error
- func SetQuota(wid types.UUID, quota uint64) error
- func SetQuotaUsage(wid types.UUID, total uint64) error
- func SetWorkspaceStatus(wid string, status string) error
- func UpdateDevice(wid types.UUID, devid types.UUID, oldkey ezn.CryptoString, ...) error
- func UpdateLastLogin(wid types.UUID, devid types.UUID) error
- func ValidateUUID(uuid string) bool
- type UpdateRecord
- type UpdateType
Constants ¶
const ( // We start at 1 so that we know if the UpdateRecord struct is initialized or not UpdateCreate = iota + 1 UpdateDelete UpdateMove UpdateReplace UpdateRotate UpdateMkDir UpdateRmDir )
Variables ¶
This section is empty.
Functions ¶
func AddDevice ¶
AddDevice is used for adding a device to a workspace. The initial last login is set to when this method is called because a new device is only at certain times, such as at registration or when a user logs into a workspace on a new device.
func AddEntry ¶
AddEntry adds an entry to the database. The caller is responsible for validation of *ALL* data passed to this command.
func AddFolderEntry ¶
AddFolderEntry adds a mapping of a server path to an encrypted client path
func AddSyncRecord ¶
func AddSyncRecord(wid string, rec UpdateRecord) error
AddSyncRecord adds a record to the update table
func AddWorkspace ¶
func AddWorkspace(wid string, uid string, domain string, password string, status string, wtype string) error
AddWorkspace is used for adding a workspace to a server. Upon failure, it returns the error state for the failure. It makes the necessary database modifications and creates the folder for the workspace in the filesystem. Note that this function is strictly for adding workspaces for individuals. Shared workspaces are not yet supported/implemented. Status may be 'active', 'pending', or 'disabled'.
func CheckDevice ¶
CheckDevice checks if a device has been added to a workspace.
func CheckLockout ¶
CheckLockout corresponds to LogFailure() in that it checks to see if said source has a lockout timestamp and returns it if there is or an empty string if not. It also has the added benefit of resetting a counter to 0 if there is an expired lockout for a particular source. The ID parameter is a string specific to the failure type. For example, for logins, it is the workspace ID. For preregistration codes, it is the IP address of the remote host.
func CheckPasscode ¶
CheckPasscode checks the validity of a workspace/passcode combination. This function will return an error of "expired" if the combination is valid but expired.
func CheckPassword ¶
CheckPassword checks a password hash against the one stored in the database. It returns true if the two hashes match. It does not perform any validity checking of the input--this should be done when the input is received from the user.
func CheckRegCode ¶
CheckRegCode handles authenticating a host using a user/workspace ID and registration code provided by PreregWorkspace. Based on authentication it either returns the workspace ID (success) or an empty string (failure). An error is returned only if authentication was not successful. The caller is still responsible for performing the necessary steps to add the workspace to the database.
func CheckUserID ¶
CheckUserID works the same as CheckWorkspace except that it checks for user IDs
func CheckWorkspace ¶
CheckWorkspace checks to see if a workspace exists. If the workspace does exist, True is returned along with a string containing the workspace's status. If the workspace does not exist, it returns false and an empty string. The workspace status can be 'active', 'pending', or 'disabled'. Preregistered workspaces have the status 'approved'. Note that this function does not check the validity of the WID string passed to it. This should be done when the input is received from the user.
func Connect ¶
func Connect()
Connect utilizes the viper config system and connects to the specified database. Because problems in the connection are almost always fatal to the successful continuation of the server daemon, if there are problems, it logs the problem and exits the main process.
func CountSyncRecords ¶
CountSyncRecords returns the number of sync records which occurred after the specified time
func CullOldSyncRecords ¶
func DeletePasscode ¶
DeletePasscode deletes a workspace/passcode combination
func DeleteRegCode ¶
DeleteRegCode removes preregistration data from the database.
func GetAliases ¶
func GetAliases(wid types.UUID) (gostringlist.StringList, error)
GetAliases returns a StringList containing the aliases pointing to the specified WID
func GetEncryptionPair ¶
func GetEncryptionPair() (*ezn.EncryptionPair, error)
GetEncryptionPair returns the organization's encryption keypair as an EncryptionPair
func GetLastLogin ¶
GetLastLogin gets the last time a device logged in UTC time, UNIX format
func GetOrgEntries ¶
GetOrgEntries pulls one or more entries from the database. If an end index is not desired, set it to 0. Passing a starting index of 0 will return the current entry for the organization.
func GetOrgKeycard ¶
GetOrgKeycard obtains a organization's entire keycard as a Keycard object
func GetPrimarySigningPair ¶
func GetPrimarySigningPair() (*ezn.SigningPair, error)
GetPrimarySigningPair obtains the organization's primary signing and verification keys
func GetQuotaInfo ¶
GetQuotaInfo returns the disk usage and quota size of a workspace in bytes
func GetUserEntries ¶
GetUserEntries pulls one or more entries from the database. If an end index is not desired, set it to 0. Passing a starting index of 0 will return the current entry for the workspace specified.
func GetUserKeycard ¶
GetUserKeycard obtains a user's entire keycard as a Keycard object
func IsConnected ¶
func IsConnected() bool
IsConnected returns a boolean if it has successfully connected to the Mensago server database
func IsDomainLocal ¶
IsDomainLocal checks to see if the domain passed to it is managed by this server
func LogFailure ¶
LogFailure adds an entry to the database of a failure which needs tracked. This includes a type (workspace, password, recipient), the source (IP address, WID), and the timestamp of the failure. This function will check the server configuration and if the failure has exceeded the threshold for that type of failure, then a lockout timestamp will be set.
func ModifyQuotaUsage ¶
ModifyQuotaUsage modifies the disk usage by a relative amount, specified in bytes. Note that if
func PreregWorkspace ¶
func PreregWorkspace(wid types.UUID, uid types.UserID, domain types.DomainT, wordList *diceware.Wordlist, wordcount int) (string, error)
PreregWorkspace preregisters a workspace, adding a specified wid to the database and returns a randomly-generated registration code needed to authenticate the first login. Registration codes are stored in the clear, but that's merely because if an attacker already has access to the server to see the codes, the attacker can easily create new workspaces.
func RemoveDevice ¶
RemoveDevice removes a device from a workspace. It returns true if successful and false if not.
func RemoveExpiredPasscodes ¶
func RemoveExpiredPasscodes() error
RemoveExpiredPasscodes removes any workspace/passcode combination entries which are expired
func RemoveFolderEntry ¶
RemoveFolderEntry deletes a folder mapping
func RemoveWorkspace ¶
RemoveWorkspace deletes a workspace. It returns an error if unsuccessful. Note that this does not remove all information about the workspace. WIDs and UIDs may not be reused for security purposes, so the uid and wid attached to the workspace will remain in the database for this reason
func ResetPassword ¶
ResetPassword adds a reset code combination to the database for later authentication by the user. All parameters are expected to be populated.
func ResetQuotaUsage ¶
func ResetQuotaUsage() error
ResetQuotaUsage resets the disk quota usage count in the database for all workspaces
func ResolveAddress ¶
ResolveAddress returns the WID corresponding to an Mensago address.
func SetPassword ¶
SetPassword does just that: sets the password for a workspace. It returns a boolean state, indicating a match (or lack thereof) and an error state. It will take any input string of up to 64 characters and store it in the database.
func SetQuotaUsage ¶
SetQuotaUsage sets the disk quota usage for a workspace to a specified number of bytes. If the usage has not been updated since boot, the total is ignored and the actual value from disk is used.
func SetWorkspaceStatus ¶
SetWorkspaceStatus sets the status of a workspace. Valid values are "disabled", "active", and "approved". Although a workspace can also have a status of "awaiting", this state is internal to the dbhandler API and cannot be set directly.
func UpdateDevice ¶
func UpdateDevice(wid types.UUID, devid types.UUID, oldkey ezn.CryptoString, newkey ezn.CryptoString) error
UpdateDevice replaces a device's old key with a new one
func UpdateLastLogin ¶
UpdateLastLogin sets the last login timestamp for a device
func ValidateUUID ¶
ValidateUUID just returns whether or not a string is a valid UUID.
Types ¶
type UpdateRecord ¶
type UpdateRecord struct { ID string Type UpdateType Data string Time int64 }
func GetSyncRecords ¶
func GetSyncRecords(wid string, unixtime int64) ([]UpdateRecord, error)
GetSyncRecords gets all the update records after a specified period of time
type UpdateType ¶
type UpdateType int