Documentation ¶
Index ¶
- Constants
- Variables
- func CreatePasswordHash(password string) ([]byte, error)
- type Authentication
- type AuthenticationConfig
- type DashboardAuthentication
- type DbConnectionConfig
- type DbConnectionsConfig
- type IpsAllowList
- type MessageSharing
- type MessagesRepo
- type MessagesStorage
- type MessagesStorageConfiguration
- type Room
- type RoomsRepo
- type SearchParam
- type SearchQuery
- type SharedMessageRecord
- type SmtpAuthentication
- type UserResource
- type UsersStorage
- type ViaEmailAuthentication
- type ViaIpAuthentication
- type ViaPasswordAuthentication
Constants ¶
const ( SearchParamFrom SearchParam = "from" SearchParamTo = "to" SearchParamContent = "content" )
Variables ¶
var MessageSharingExpiredAtFormat = "2006-01-02 15:04:05"
MessageSharingExpiredAtFormat consider always be in UTC
Functions ¶
func CreatePasswordHash ¶
Types ¶
type Authentication ¶
type Authentication interface { // SMTP returns object what process authentication for SMTP protocol. SMTP() SmtpAuthentication // Dashboard returns object what process authentication for UI dashboard. Dashboard() DashboardAuthentication // UsersStorage returns object what manipulate users in application. UsersStorage() UsersStorage }
Authentication interface represents a backend flow authenticate user to SMTP for store message, or to dashboard for manage stored messages.
type AuthenticationConfig ¶
type AuthenticationConfig struct { Smtp struct { IpsAllowList struct { Enabled bool `yaml:"enabled"` } `yaml:"ips_allowlist"` ViaIpAuthentication struct { Enabled bool `yaml:"enabled"` } `yaml:"via_ip"` ViaPasswordAuthentication struct { Enabled bool `yaml:"enabled"` } `yaml:"via_password"` } `yaml:"smtp"` Dashboard struct { ViaEmailAuthentication struct { Enabled bool `yaml:"enabled"` } `yaml:"via_email"` ViaPasswordAuthentication struct { Enabled bool `yaml:"enabled"` } `yaml:"via_password"` } `yaml:"dashboard"` }
type DashboardAuthentication ¶
type DashboardAuthentication interface { // RequiresAuthentication define is need authentication for dashboard. RequiresAuthentication() bool // ViaPasswordAuthentication returns object what can manage password for authentication. ViaPasswordAuthentication() ViaPasswordAuthentication // ViaEmailAuthentication returns object what can manage emails what can be authenticated without password. ViaEmailAuthentication() ViaEmailAuthentication }
type DbConnectionConfig ¶ added in v1.0.3
type DbConnectionConfig map[string]interface{}
type DbConnectionsConfig ¶ added in v1.0.3
type DbConnectionsConfig struct {
Connections map[string]DbConnectionConfig `yaml:"connections"`
}
type IpsAllowList ¶
type IpsAllowList interface { // Enabled shows is allowlist flow enabled. Enabled() bool // Allowed check is IP in allowlist for specific user. Allowed(username string, ip string) bool // AddIp to auth allowlist storage related to specific user. AddIp(username string, ip string) error // DeleteIp from auth allowlist storage related to specific user. DeleteIp(username string, ip string) error // ClearAllIps from auth allowlist storage related to specific user. ClearAllIps(username string) error }
IpsAllowList allow application while authentication checks IP before authenticate client and if IP not in allowed list then application will return unauthenticated response.
type MessageSharing ¶ added in v1.0.2
type MessageSharing interface { // Add new sharing record to storage. Add(emailSharingRecord *SharedMessageRecord) (*SharedMessageRecord, error) // Find single record by ID. Find(id string) (*SharedMessageRecord, error) // DeleteExpired will iterate over all shared records and delete all expired records. DeleteExpired() (bool, error) }
MessageSharing represents interface of manipulation of shared messages
type MessagesRepo ¶ added in v1.0.1
type MessagesRepo interface { // Store `message` to specific `room`. Store(message *smtpMessage.SmtpMessage) (smtpMessage.MessageID, error) // List retrieve list of messages based on `query` starting with `offset` index and count limited by `limit`. // `query` - represents of key->value map, where key is search parameter. List(query SearchQuery, offset, limit int) ([]smtpMessage.SmtpMessage, int, error) // Count total messages in storage. Count() int // Delete delete specific message from storage by `messageId`. Delete(messageId smtpMessage.MessageID) error // Load find specific message from storage by `messageId`. Load(messageId smtpMessage.MessageID) (*smtpMessage.SmtpMessage, error) }
MessagesRepo represents repository to manipulate messages related to specific room.
type MessagesStorage ¶ added in v1.0.1
type MessagesStorage interface { // RoomsRepo returns room repository RoomsRepo() RoomsRepo // MessagesRepo returns messages repository related to specific room MessagesRepo(room Room) MessagesRepo }
MessagesStorage interface represents a backend flow to store or retrieve messages
type MessagesStorageConfiguration ¶ added in v1.0.1
type MessagesStorageConfiguration struct {
PerRoomLimit int `yaml:"per_room_limit"`
}
type Room ¶ added in v1.0.1
type Room string
Room name. Each room contains set of emails. By room application diverge what emails should be displayed for login user. Now application expects have room name same as logged username (in case auth disabled - will be used name "default").
type RoomsRepo ¶ added in v1.0.1
type RoomsRepo interface { // List of rooms in system. List(offset, limit int) ([]Room, error) // Count total count rooms in storage. Count() int // Delete all messages in room from storage. Delete(room Room) error }
RoomsRepo represents repository to manipulate rooms.
type SearchQuery ¶ added in v1.0.1
SearchQuery represents key->value map what describe search params.
type SharedMessageRecord ¶ added in v1.0.2
type SharedMessageRecord struct {}
SharedMessageRecord represents one record of shared message.
func NewSharedMessageRecord ¶ added in v1.0.2
func NewSharedMessageRecord(room Room, messageID smtpMessage.MessageID) *SharedMessageRecord
NewSharedMessageRecord creates new object of SharedMessageRecord
func (*SharedMessageRecord) Exists ¶ added in v1.0.2
func (record *SharedMessageRecord) Exists() bool
Exists checks is record exists in storage ()is created identification.
func (*SharedMessageRecord) GetExpiredAtString ¶ added in v1.0.2
func (record *SharedMessageRecord) GetExpiredAtString() string
GetExpiredAtString string representation of expired at time.
func (*SharedMessageRecord) IsExpired ¶ added in v1.0.2
func (record *SharedMessageRecord) IsExpired() bool
IsExpired checks is record expired
func (*SharedMessageRecord) SetExpirationInHours ¶ added in v1.0.2
func (record *SharedMessageRecord) SetExpirationInHours(hours int) *SharedMessageRecord
SetExpirationInHours setting expiration time future from now in passed hours.
type SmtpAuthentication ¶
type SmtpAuthentication interface { // RequiresAuthentication define is need authentication for SMTP RequiresAuthentication() bool // IpsAllowList returns object what can manage IPs allowlist. IpsAllowList() IpsAllowList // ViaPasswordAuthentication returns object what can manage password for authentication. ViaPasswordAuthentication() ViaPasswordAuthentication // ViaIpAuthentication returns object what can manage IPs what can be authenticated without password. ViaIpAuthentication() ViaIpAuthentication }
SmtpAuthentication contains methods related to SMTP authentication to send email messages to application.
type UserResource ¶
type UsersStorage ¶
type UsersStorage interface { // Exists check is username exists in storage. Exists(username string) bool // Add to auth storage. Add(username string) error // Delete from auth storage. Delete(username string) error // List from auth storage. List(searchQuery string, offset, limit int) ([]UserResource, int, error) }
type ViaEmailAuthentication ¶
type ViaEmailAuthentication interface { // Enabled shows is authentication via email flow enabled. Enabled() bool // SendToken to email. SendToken(username string, email string) error // Authenticate user by token sent to email. Authenticate(username string, email string, token string) bool // AddEmail for login to auth storage related to user AddEmail(username string, email string) error // DeleteEmail for login from auth storage related to user DeleteEmail(username string, email string) error // ClearAllEmails for login from auth storage related to user ClearAllEmails(username string) error }
ViaEmailAuthentication allow login by token sent to email.
type ViaIpAuthentication ¶
type ViaIpAuthentication interface { // Enabled shows is authentication via IP flow enabled. Enabled() bool // Authenticate check is application can bypass password and authenticate client just by username and IP. Authenticate(username string, ip string) bool // AddIp for "IP auth" to auth storage related to user. AddIp(username string, ip string) error // DeleteIp for "IP auth" from auth storage related to user. DeleteIp(username string, ip string) error // ClearAllIps for "IP auth" from auth storage related to user. ClearAllIps(username string) error }
ViaIpAuthentication allow application authenticate client by username and IP without checking password.
type ViaPasswordAuthentication ¶
type ViaPasswordAuthentication interface { // Enabled shows is authentication via email flow enabled. Enabled() bool // Authenticate check is credentials (login/password) are valid. Authenticate(username string, password string) bool // SetPassword to auth storage related to user. SetPassword(username string, password string) error }
ViaPasswordAuthentication allow login by password.