Skip to content

Commit 4dbf936

Browse files
committed
Enforce base domains since subdomain use cases are not currently defined
1 parent 40ff964 commit 4dbf936

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

pkg/code/server/grpc/messaging/message_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ func verifyThirdPartyDomain(ctx context.Context, verifier thirdparty.DomainVerif
606606

607607
ownsDomain, err := verifier(ctx, owner, domain.Value)
608608
if err != nil {
609-
return newMessageValidationErrorf("error veryfing domain ownership: %s", err.Error())
609+
return newMessageAuthenticationErrorf("error veryfing domain ownership: %s", err.Error())
610610
} else if !ownsDomain {
611611
return newMessageAuthorizationErrorf("%s does not own domain %s", owner.PublicKey().ToBase58(), asciiBaseDomain)
612612
}

pkg/code/thirdparty/domain.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,20 @@ func VerifyDomainNameOwnership(ctx context.Context, owner *common.Account, domai
3333
PublicKeys []string `json:"public_keys,omitempty"`
3434
}
3535

36-
asciiBaseDomain, err := GetAsciiBaseDomain(domain)
37-
if err != nil {
38-
return false, err
39-
}
36+
var asciiBaseDomain string
37+
var err error
4038
if domain == "app.getcode.com" {
4139
asciiBaseDomain = "app.getcode.com" // Temporary testing hack
40+
} else {
41+
// Subdomains are not currently used, so explicitly deny for now
42+
if len(strings.Split(domain, ".")) > 2 {
43+
return false, errors.New("subdomains cannot be verified")
44+
}
45+
46+
asciiBaseDomain, err = GetAsciiBaseDomain(domain)
47+
if err != nil {
48+
return false, err
49+
}
4250
}
4351

4452
wellKnownUrl := fmt.Sprintf("https://%s%s", asciiBaseDomain, "/.well-known/code-payments.json")

0 commit comments

Comments
 (0)