add .int to user-owned domains, allow internal records to have suffixes like .int
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Elizabeth 2024-04-12 11:26:27 -06:00
parent 1661c0d207
commit 68c45585b4
Signed by: simponic
GPG Key ID: 2909B9A7FF6213EE
1 changed files with 10 additions and 10 deletions

View File

@ -16,7 +16,7 @@ import (
const MaxUserRecords = 100
var UserOwnedInternalFmtDomains = []string{"%s", "%s.endpoints"}
var UserOwnedInternalFmtDomains = []string{"%s", "%s.int", "%s.endpoints", "%s.", "%s.endpoints.", "%s.int."}
func ListDNSRecordsContinuation(context *types.RequestContext, req *http.Request, resp http.ResponseWriter) types.ContinuationChain {
return func(success types.Continuation, failure types.Continuation) types.ContinuationChain {
@ -163,15 +163,16 @@ func userCanFuckWithDNSRecord(dbConn *sql.DB, user *database.User, record *datab
return false
}
if !record.Internal {
for _, format := range ownedInternalDomainFormats {
domain := fmt.Sprintf(format, user.Username)
for _, format := range ownedInternalDomainFormats {
domain := fmt.Sprintf(format, user.Username)
isInSubDomain := strings.HasSuffix(record.Name, "."+domain)
if domain == record.Name || isInSubDomain {
return true
}
isInSubDomain := strings.HasSuffix(record.Name, "."+domain)
if domain == record.Name || isInSubDomain {
return true
}
}
if !record.Internal {
return false
}
@ -181,6 +182,5 @@ func userCanFuckWithDNSRecord(dbConn *sql.DB, user *database.User, record *datab
return false
}
userIsOwnerOfDomain := owner == user.ID
return ownedByUser && userIsOwnerOfDomain
return owner == user.ID
}