Skip to content

Commit

Permalink
Enforce base domains since subdomain use cases are not currently defined
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffyanta committed Jan 11, 2024
1 parent 40ff964 commit 4dbf936
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/code/server/grpc/messaging/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ func verifyThirdPartyDomain(ctx context.Context, verifier thirdparty.DomainVerif

ownsDomain, err := verifier(ctx, owner, domain.Value)
if err != nil {
return newMessageValidationErrorf("error veryfing domain ownership: %s", err.Error())
return newMessageAuthenticationErrorf("error veryfing domain ownership: %s", err.Error())
} else if !ownsDomain {
return newMessageAuthorizationErrorf("%s does not own domain %s", owner.PublicKey().ToBase58(), asciiBaseDomain)
}
Expand Down
16 changes: 12 additions & 4 deletions pkg/code/thirdparty/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@ func VerifyDomainNameOwnership(ctx context.Context, owner *common.Account, domai
PublicKeys []string `json:"public_keys,omitempty"`
}

asciiBaseDomain, err := GetAsciiBaseDomain(domain)
if err != nil {
return false, err
}
var asciiBaseDomain string
var err error
if domain == "app.getcode.com" {
asciiBaseDomain = "app.getcode.com" // Temporary testing hack
} else {
// Subdomains are not currently used, so explicitly deny for now
if len(strings.Split(domain, ".")) > 2 {
return false, errors.New("subdomains cannot be verified")
}

asciiBaseDomain, err = GetAsciiBaseDomain(domain)
if err != nil {
return false, err
}
}

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

0 comments on commit 4dbf936

Please sign in to comment.