-
Notifications
You must be signed in to change notification settings - Fork 10
/
domain.go
36 lines (30 loc) · 1.7 KB
/
domain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package config
import (
"github.com/EmissarySocial/emissary/tools/random"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// Domain contains all of the configuration data required to operate a single domain.
type Domain struct {
DomainID string `json:"domainId" bson:"domainId"` // Unique ID for this domain
Label string `json:"label" bson:"label"` // Human-friendly label for administrators
Hostname string `json:"hostname" bson:"hostname"` // Domain name of a virtual server
ConnectString string `json:"connectString" bson:"connectString"` // MongoDB connect string
DatabaseName string `json:"databaseName" bson:"databaseName"` // Name of the MongoDB Database (can be empty string to use default db for the connect string)
SMTPConnection SMTPConnection `json:"smtp" bson:"smtp"` // Information for connecting to an SMTP server to send email on behalf of the domain.
Owner Owner `json:"owner" bson:"owner"` // Information about the owner of this domain
KeyEncryptingKey string `json:"keyEncryptingKey" bson:"keyEncryptingKey"` // Key used to encrypt/decrypt JWT keys stored in the database
}
// NewDomain returns a fully initialized Domain object.
func NewDomain() Domain {
// Default KEK is a slice of 32 random bytes
keyEncryptingKey, _ := random.GenerateString(32)
return Domain{
DomainID: primitive.NewObjectID().Hex(),
SMTPConnection: SMTPConnection{},
KeyEncryptingKey: keyEncryptingKey,
}
}
// ID returns the domain ID.
func (domain Domain) ID() string {
return domain.DomainID
}