Documentation ¶
Index ¶
- Constants
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDigest(name string) ([sha256.Size]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func AssetString(name string) (string, error)
- func AttachJSON(message *mail.SGMailV3, data []byte, filename string) (err error)
- func DeliverCertsEmail(sender, senderEmail, recipient, recipientEmail, attachmentPath string, ...) (message *mail.SGMailV3, err error)
- func Digests() (map[string][sha256.Size]byte, error)
- func ExpiresAdminNotificationEmail(sender, senderEmail, recipient, recipientEmail string, ...) (message *mail.SGMailV3, err error)
- func GetRecipient(msg *sgmail.SGMailV3) (recipient string, err error)
- func LoadAttachment(message *mail.SGMailV3, attachmentPath string) (err error)
- func MustAsset(name string) []byte
- func MustAssetString(name string) string
- func PurgeMockEmails()
- func ReissuanceReminderEmail(sender, senderEmail, recipient, recipientEmail string, ...) (message *mail.SGMailV3, err error)
- func ReissuanceStartedEmail(sender, senderEmail, recipient, recipientEmail string, ...) (message *mail.SGMailV3, err error)
- func RejectRegistrationEmail(sender, senderEmail, recipient, recipientEmail string, ...) (message *mail.SGMailV3, err error)
- func Render(name string, data interface{}) (text, html string, err error)
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func ReviewRequestEmail(sender, senderEmail, recipient, recipientEmail string, data ReviewRequestData) (message *mail.SGMailV3, err error)
- func VerifyContactEmail(sender, senderEmail, recipient, recipientEmail string, data VerifyContactData) (message *mail.SGMailV3, err error)
- func WriteMIME(msg *sgmail.SGMailV3, path string) (err error)
- type AdminReview
- type DeliverCertsData
- type EmailClient
- type EmailManager
- func (m *EmailManager) Send(message *sgmail.SGMailV3) (err error)
- func (m *EmailManager) SendDeliverCertificates(vasp *pb.VASP, path string) (sent int, err error)
- func (m *EmailManager) SendExpiresAdminNotification(vasp *pb.VASP, reissueDate time.Time) (sent int, err error)
- func (m *EmailManager) SendReissuanceReminder(vasp *pb.VASP, reissueDate time.Time) (sent int, err error)
- func (m *EmailManager) SendReissuanceStarted(vasp *pb.VASP, whisperLink string) (sent int, err error)
- func (m *EmailManager) SendRejectRegistration(vasp *pb.VASP, reason string) (sent int, err error)
- func (m *EmailManager) SendReviewRequest(vasp *pb.VASP) (sent int, err error)
- func (m *EmailManager) SendVerifyContact(vasp *pb.VASP, contact *pb.Contact) (err error)
- func (m *EmailManager) SendVerifyContacts(vasp *pb.VASP) (sent int, err error)
- type ExpiresAdminNotificationData
- type FutureReissuer
- type ReissuanceReminderData
- type ReissuanceStartedData
- type RejectRegistrationData
- type ReviewRequestData
- type VerifyContactData
Constants ¶
const ( UnknownDate = "unknown date" DateFormat = "Monday, January 2, 2006" )
const ( VerifyContactRE = "TRISA: Please verify your email address" ReviewRequestRE = "New TRISA Global Directory Registration Request" RejectRegistrationRE = "TRISA Global Directory Registration Update" DeliverCertsRE = "Welcome to the TRISA network!" ExpiresAdminNotificationRE = "A TRISA Identity Certificate is Expiring Soon" ReissuanceReminderRE = "TRISA Identity Certificate Expiration" ReissuanceStartedRE = "TRISA PKCS12 Password for Certificate Reissuance" )
Subjects for creating emails on demand.
const AssetDebug = false
AssetDebug is true if the assets were built with the debug flag enabled.
Variables ¶
var MockEmails [][]byte
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDigest ¶
AssetDigest returns the digest of the file with the given name. It returns an error if the asset could not be found or the digest could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"}, AssetDir("data/img") would return []string{"a.png", "b.png"}, AssetDir("foo.txt") and AssetDir("notexist") would return an error, and AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetString ¶
AssetString returns the asset contents as a string (instead of a []byte).
func AttachJSON ¶
AttachJSON by marshaling the specified data into human-readable data and encode and attach it to the email as a file.
func DeliverCertsEmail ¶
func DeliverCertsEmail(sender, senderEmail, recipient, recipientEmail, attachmentPath string, data DeliverCertsData) (message *mail.SGMailV3, err error)
DeliverCertsEmail creates a new deliver certs email, ready for sending by rendering the text and html templates with the supplied data, loading the attachment from disk then constructing a sendgrid email.
func ExpiresAdminNotificationEmail ¶ added in v1.5.0
func ExpiresAdminNotificationEmail(sender, senderEmail, recipient, recipientEmail string, data ExpiresAdminNotificationData) (message *mail.SGMailV3, err error)
ExpiresAdminNotificationEmail creates a new certs expired admin notification email, ready for sending by rendering the text and html templates with the supplied data.
func LoadAttachment ¶
LoadAttachment onto email from a file on disk.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func MustAssetString ¶
MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables.
func PurgeMockEmails ¶
func PurgeMockEmails()
func ReissuanceReminderEmail ¶ added in v1.5.0
func ReissuanceReminderEmail(sender, senderEmail, recipient, recipientEmail string, data ReissuanceReminderData) (message *mail.SGMailV3, err error)
ReissuanceReminderEmail creates a new reissuance reminder email, ready for sending by rendering the text and html templates with the supplied data.
func ReissuanceStartedEmail ¶ added in v1.5.0
func ReissuanceStartedEmail(sender, senderEmail, recipient, recipientEmail string, data ReissuanceStartedData) (message *mail.SGMailV3, err error)
ReissuanceStartedEmail creates a new reissuance started email, ready for sending by rendering the text and html templates with the supplied data.
func RejectRegistrationEmail ¶
func RejectRegistrationEmail(sender, senderEmail, recipient, recipientEmail string, data RejectRegistrationData) (message *mail.SGMailV3, err error)
RejectRegistrationEmail creates a new reject registration email, ready for sending by rendering the text and html templates with the supplied data then constructing a sendgrid email.
func Render ¶
Render returns the text and html executed templates for the specified name and data. Ensure that the extension is not supplied to the render method.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory.
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively.
func ReviewRequestEmail ¶
func ReviewRequestEmail(sender, senderEmail, recipient, recipientEmail string, data ReviewRequestData) (message *mail.SGMailV3, err error)
ReviewRequestEmail creates a new review request email, ready for sending by rendering the text and html templates with the supplied data then constructing a sendgrid email.
func VerifyContactEmail ¶
func VerifyContactEmail(sender, senderEmail, recipient, recipientEmail string, data VerifyContactData) (message *mail.SGMailV3, err error)
VerifyContactEmail creates a new verify contact email, ready for sending by rendering the text and html templates with the supplied data then constructing a sendgrid email.
Types ¶
type AdminReview ¶ added in v1.5.0
type AdminReview interface {
AdminReviewURL() string
}
type DeliverCertsData ¶
type DeliverCertsData struct { Name string // Used to address the email VID string // The ID of the VASP/Registration CommonName string // The common name assigned to the cert SerialNumber string // The serial number of the certificate Endpoint string // The expected endpoint for the TRISA service RegisteredDirectory string // The directory name for the certificates being issued }
DeliverCertsData to complete deliver certs email templates.
type EmailClient ¶
EmailClient is an interface that can be implemented by SendGrid email clients.
type EmailManager ¶
type EmailManager struct {
// contains filtered or unexported fields
}
EmailManager allows the server to send rich emails using the SendGrid service.
func New ¶
func New(conf config.EmailConfig) (m *EmailManager, err error)
New email manager with the specified configuration.
func (*EmailManager) SendDeliverCertificates ¶
SendDeliverCertificates sends the PKCS12 encrypted certificate files to the VASP contacts as an attachment, completing the certificate issuance process. This method only sends the certificate attachment to one email (to limit the delivery of a secure email), ranking the contact emails by priority. Caller must update the VASP record on the data store after calling this function.
func (*EmailManager) SendExpiresAdminNotification ¶ added in v1.5.0
func (m *EmailManager) SendExpiresAdminNotification(vasp *pb.VASP, reissueDate time.Time) (sent int, err error)
SendExpiresAdminNotification sends the admins a notice that an identity certificate will be expiring soon. This allows the admins to determine if a new review of the TRISA member is necessary before the reissuance process begins.
func (*EmailManager) SendReissuanceReminder ¶ added in v1.5.0
func (m *EmailManager) SendReissuanceReminder(vasp *pb.VASP, reissueDate time.Time) (sent int, err error)
SendReissuanceReminder sends a reminder to all verified contacts that their identity certificates will be expiring soon and that the system will automatically reissue the certs on a particular date.
func (*EmailManager) SendReissuanceStarted ¶ added in v1.5.0
func (m *EmailManager) SendReissuanceStarted(vasp *pb.VASP, whisperLink string) (sent int, err error)
SendReissuanceStarted sends the PKCS12 password via a secure one time link. This method only sends the PKCS12 password to one email (to limit the delivery of secure emails), ranking the contact emails by priority.
func (*EmailManager) SendRejectRegistration ¶
SendRejectRegistration sends a notification to all VASP contacts that their registration status is rejected without certificate issuance and explains why. Caller must update the VASP record on the data store after calling this function.
func (*EmailManager) SendReviewRequest ¶
func (m *EmailManager) SendReviewRequest(vasp *pb.VASP) (sent int, err error)
SendReviewRequest is a shortcut for iComply verification in which we simply send an email to the TRISA admins and have them manually verify registrations.
func (*EmailManager) SendVerifyContact ¶ added in v1.3.1
SendVerifyContact sends a verification email to a contact.
func (*EmailManager) SendVerifyContacts ¶
func (m *EmailManager) SendVerifyContacts(vasp *pb.VASP) (sent int, err error)
SendVerifyContacts creates a verification token for each contact in the VASP contact list and sends them the verification email with instructions on how to verify their email address. Caller must update the VASP record on the data store after calling this function.
type ExpiresAdminNotificationData ¶ added in v1.5.0
type ExpiresAdminNotificationData struct { VID string // The ID of the VASP/Registration CommonName string // The common name assigned to the cert SerialNumber string // The serial number of the certificate Endpoint string // The expected endpoint for the TRISA service RegisteredDirectory string // The directory name for the certificates being issued Expiration time.Time // The timestamp that the certificates expire Reissuance time.Time // The timestamp the certificates will be reissued BaseURL string // The URL of the admin review endpoint to build the AdminReviewURL }
ExpiresAdminNotificationData to complete expires admin notification email templates.
func (ExpiresAdminNotificationData) AdminReviewURL ¶ added in v1.5.0
func (d ExpiresAdminNotificationData) AdminReviewURL() string
AdminReviewURL composes a link to the VASP detail in the admin UI. If the base url is missing or can't be parsed, it logs an warning and returns empty string. The AdminReviewURL is useful, but it is not a critical error.
func (ExpiresAdminNotificationData) ExpirationDate ¶ added in v1.5.0
func (d ExpiresAdminNotificationData) ExpirationDate() string
ExpirationDate formats the expiration date for rendering in the email.
func (ExpiresAdminNotificationData) ReissueDate ¶ added in v1.5.0
func (d ExpiresAdminNotificationData) ReissueDate() string
ReissueDate formats the reissuance date for rendering in the email.
type FutureReissuer ¶ added in v1.5.0
type ReissuanceReminderData ¶ added in v1.5.0
type ReissuanceReminderData struct { Name string // Used to address the email VID string // The ID of the VASP/Registration CommonName string // The common name assigned to the cert SerialNumber string // The serial number of the certificate Endpoint string // The expected endpoint for the TRISA service RegisteredDirectory string // The directory name for the certificates being issued Expiration time.Time // The timestamp that the certificates expire Reissuance time.Time // The timestamp the certificates will be reissued }
ReissuanceReminderData to complete reissue reminder email templates.
func (ReissuanceReminderData) ExpirationDate ¶ added in v1.5.0
func (d ReissuanceReminderData) ExpirationDate() string
ExpirationDate formats the expiration date for rendering in the email.
func (ReissuanceReminderData) ReissueDate ¶ added in v1.5.0
func (d ReissuanceReminderData) ReissueDate() string
ReissueDate formats the reissuance date for rendering in the email.
type ReissuanceStartedData ¶ added in v1.5.0
type ReissuanceStartedData struct { Name string // Used to address the email VID string // The ID of the VASP/Registration CommonName string // The common name assigned to the cert Endpoint string // The expected endpoint for the TRISA service RegisteredDirectory string // The directory name for the certificates being issued WhisperURL string // Secure one-time whisper link for password retrieval }
ReissuanceStartedData to complete reissue reminder email templates.
type RejectRegistrationData ¶
type RejectRegistrationData struct { Name string // Used to address the email VID string // The ID of the VASP/Registration Reason string // A description of why the registration request was rejected }
RejectRegistrationData to complete reject registration email templates.
type ReviewRequestData ¶
type ReviewRequestData struct { VID string // The ID of the VASP/Registration Token string // The unique token needed to review the registration Request string // The review request data as a nicely formatted JSON or YAML string RegisteredDirectory string // The directory name for the review request Attachment []byte // Data to attach to the email BaseURL string // The URL of the admin review endpoint to build the AdminReviewURL }
ReviewRequestData to complete review request email templates.
func (ReviewRequestData) AdminReviewURL ¶
func (d ReviewRequestData) AdminReviewURL() string
AdminReviewURL composes a link to the VASP detail in the admin UI. If the base url is missing or can't be parsed, it logs an warning and returns empty string. The AdminReviewURL is useful, but it is not a critical error.
type VerifyContactData ¶
type VerifyContactData struct { Name string // Used to address the email Token string // The unique token needed to verify the email VID string // The ID of the VASP/Registration BaseURL string // The URL of the verify contact endpoint to build the VerifyContactURL DirectoryID string // The registered directory to build a URL accessible by the BFF }
VerifyContactData to complete the verify contact email templates.
func (VerifyContactData) VerifyContactURL ¶
func (d VerifyContactData) VerifyContactURL() string
VerifyContactURL composes the link to verify the contact from the context. If the link is not able to be composed, the function returns an empty string and logs an error because without the link the email is fairly useless.