File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ type EmailAddressValidator struct {
18
18
AllowedEmails []string
19
19
}
20
20
21
+ // NewEmailAddressValidator takes in a list of email addresses and returns a Validator object.
22
+ // The validator can be used to validate that the session.Email:
23
+ // - is non-empty
24
+ // - matches one of the originally passed in email addresses
25
+ // (case insensitive)
26
+ // - if the originally passed in list of emails consists only of "*", then all emails
27
+ // are considered valid based on their domain.
28
+ // If valid, nil is returned in place of an error.
21
29
func NewEmailAddressValidator (allowedEmails []string ) EmailAddressValidator {
22
30
var emailAddresses []string
23
31
Original file line number Diff line number Diff line change @@ -16,6 +16,14 @@ type EmailDomainValidator struct {
16
16
AllowedDomains []string
17
17
}
18
18
19
+ // NewEmailDomainValidator takes in a list of domains and returns a Validator object.
20
+ // The validator can be used to validate that the session.Email:
21
+ // - is non-empty
22
+ // - the domain of the email address matches one of the originally passed in domains.
23
+ // (case insensitive)
24
+ // - if the originally passed in list of domains consists only of "*", then all emails
25
+ // are considered valid based on their domain.
26
+ // If valid, nil is returned in place of an error.
19
27
func NewEmailDomainValidator (allowedDomains []string ) * EmailDomainValidator {
20
28
emailDomains := make ([]string , 0 , len (allowedDomains ))
21
29
Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ type EmailGroupValidator struct {
18
18
AllowedGroups []string
19
19
}
20
20
21
+ // NewEmailGroupValidator takes in a Provider object and a list of groups, and returns a Validator object.
22
+ // The validator can be used to validate that the session.Email:
23
+ // - if an empty list is passed in in place of a list of groups, all session.Emails will be considered valid
24
+ // regardless of group membership with that particular Provider.
25
+ // - according to the Provider that was passed in, is a member of one of the originally passed in groups.
26
+ // If valid, nil is returned in place of an error.
21
27
func NewEmailGroupValidator (provider providers.Provider , allowedGroups []string ) EmailGroupValidator {
22
28
return EmailGroupValidator {
23
29
Provider : provider ,
You can’t perform that action at this time.
0 commit comments