mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 07:16:38 +00:00
check for domain ownership via subdomain rather than naked domain
This commit is contained in:
@@ -25,8 +25,8 @@ func NewValidator(resolver resolver) *Validator {
|
||||
}
|
||||
}
|
||||
|
||||
// IsValid looks up the CNAME record for the passed domain and compares it
|
||||
// against the acceptable domains.
|
||||
// IsValid looks up the CNAME record for the passed domain with a prefix
|
||||
// and compares it against the acceptable domains.
|
||||
// If the returned CNAME matches any accepted domain, it will return true,
|
||||
// otherwise, including in the event of a DNS error, it will return false.
|
||||
// The comparison is very simple, so wildcards will not match if included
|
||||
@@ -36,7 +36,10 @@ func (v *Validator) IsValid(ctx context.Context, domain string, accept []string)
|
||||
v.resolver = net.DefaultResolver
|
||||
}
|
||||
|
||||
cname, err := v.resolver.LookupCNAME(ctx, domain)
|
||||
// Prepend subdomain for ownership validation because we want to check
|
||||
// for the record being a wildcard ("*.example.com"), but you cannot
|
||||
// look up a wildcard so we have to add a subdomain for the check.
|
||||
cname, err := v.resolver.LookupCNAME(ctx, "validation."+domain)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"domain": domain,
|
||||
|
||||
Reference in New Issue
Block a user