This commit is contained in:
kayos@tcp.direct 2021-10-05 05:35:09 -07:00
commit f288d6f861
4 changed files with 96 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/dumps/

36
emailaccount.go Normal file
View File

@ -0,0 +1,36 @@
package sso
// EmailStorage represents where emails are stored for an EmailAccount.
type EmailStorage uint8
//goland:noinspection GoUnusedConst
const (
// MailDirStorage uses traditional Maildir format to store emails.
MailDirStorage EmailStorage = iota
// BitcaskMailStorage bitcask to store emails. (unimplemented)
BitcaskMailStorage
// PostgresMailStorage uses Postgresql to store emails. (unimplemented)
PostgresMailStorage
// TemporaryMailStorage stores temporary, disposable emails. (unimplemented)
TemporaryMailStorage
)
// EmailAccount represents an email inbox owned by a User. Aims to be partially compatible with Dovecot.
type EmailAccount struct {
// Domain is the internal email domain associated with this Maildir.
Domain string `json:"domain"`
// Quota is the maximum amount of email allowed to be stored in bytes. A quota of 0 means no quota.
Quota int `json:"quota"`
// Type represents the type of EmailStorage an email account uses.
Type EmailStorage `json:"storage"`
// DomainAdmin determines if the user has administrative permissions of the parent Domain.
DomainAdmin bool `json:"isadmin"`
// MaildirDetails represents an EmailAccount's maildir if applicable.
MaildirDetails Maildir `json:"maildir,omitempty"`
// BitcaskDetails represents an EmailAccount's BitcaskStore if applicable.
BitcaskDetails BitcaskStore `json:"bitcaskdb,omitempty"`
// BoltDetails represents an EmailAccount's BitcaskStore if applicable.
BoltDetails BoltStore `json:"boltdb,omitempty"`
}

31
emailstorage.go Normal file
View File

@ -0,0 +1,31 @@
package sso
// TODO: Make interfaces for email stores.
// BitcaskStore contains details of a bitcask backed email store.
type BitcaskStore struct {
// StoreNode is an identifying string pointing to what server the BitcaskStore is primarily stored on.
StoreNode string `json:"storage_node"`
}
// BoltStore contains details of a Bolt backed email store.
type BoltStore struct {
// StoreNode is an identifying string pointing to what server the BoltStore is primarily stored on.
StoreNode string `json:"storage_node"`
}
// TemporaryStore contains details of a temporary email store.
type TemporaryStore struct {
// StoreNode is an identifying string pointing to what server the BoltStore is primarily stored on.
StoreNode string `json:"storage_node"`
}
// Maildir contains information about where a users email is stored. Aims to be partially compatible with Dovecot.
type Maildir struct {
// StoreNode is an identifying string pointing to what server the Maildir is primarily stored on.
StoreNode string `json:"storage_node"`
// StoreBaseDirectory is the base name of the Maildir directory.
StoreBaseDirectory string `json:"storage_base_directory"`
// StoreMailDir is the actual directory containing email messages.
StoreMaildir string `json:"maildir"`
}

28
user.go Normal file
View File

@ -0,0 +1,28 @@
package sso
// User contains account information for an SSO user.
type User struct {
// UserID is a key that is likely cached in memory used to lookup GlobalUsers.
UserID string `json:"id"`
// PassHash should be a bcrypt hashed password used for authentication.
PassHash string `json:"password"`
// FriendlyName is a nickname that the user decides.
FriendlyName string `json:"friendly_name,omitempty"`
// ExternalEmail is an email address to reach the user.
// Note that one can place the address of an internal email account here as well.
ExternalEmail string `json:"email,omitempty"`
// EmailAccounts contains, if applicable, the details of a users internal email account.
EmailAccounts []EmailAccount `json:"email_accounts,omitempty"`
// LegacyEmailAccountData is a place to temporarily store JSON exported from our old Mysql email database.
// Data should be removed after the user signs on for the first time and we rehash their password in Bcrypt.
LegacyEmailAccountData string `json:"legacy_email,omitempty"`
// IRCAccount represents a users IRC account (not impemented)
IRCAccount string `json:"irc_account,omitempty"`
// GlobalAdmin is a dangerous toggle which will pretty much bypass permissions checks everywhere.
GlobalAdmin bool `json:"global_admin"`
}