Built-in mechanism to determine that a host belongs to a domain I trust?

I’ve seen similar questions on this, but not to the degree of specificity I’m hoping for, so… here goes.

I’ve got a couple of web applications that use a redirectUrl parameter in an endpoint to allow for navigating to a specific page when the endpoint is completed its processing. The redirectUrl parameter must be dynamic because I support multiple vanity URLs that want their own branding on things, for example:

  • https://myapp.glamorousclownmakeup.com
  • https://myapp.yomommasougly.com
  • https://myapp.sales.lefthandedwidgets.com
  • https://myapp.marketing.lefthandedwidgets.com

What I want to do is prevent a redirect URL from being hijacked to redirect someone towards a malicious website (like https://myapp.glamorousclownmakeup.com.malicioushost.com).

My idea is to have a well-defined list of domain names, like:

  • glamorousclownmakeup.com
  • yomommasougly.com
  • lefthandedwidgets.com

… and if the redirect URL belongs to these domains, allow the redirect, and if not, prevent the redirect.

Note the lefthandedwidgets.com domain however. I have several URLs that are not of a particular domain, but various multiple subdomains. The subdomains may be several levels deep, like https://myapp.eastcoast.sales.lefthandedwidgets.com or something similar. There are also cases where the domain might be something like https://myapp.canberra.sales.lefthandedwidgets.com.au. In this case, the allowed domain I would define would be lefthandedwidgets.com.au.

All solutions to address these kinds of cases that I’ve seen to this point involve direct string manipulation and evaluation, and that seems… odd to me. Kinda kludgy and hackish, especially when I see solutions using regex. Granted, DNS is an old technology with all sorts of weirdness, but still…

Is there a mechanism to quickly, confidently determine whether or not the hostname is a part of an approved domain, or subdomain of an approved domain, or sub-subdomain of an approved domain, etc. without doing pure string manipulation to count the periods from the end of the hostname and brute-force parsing it? I mean, I could, without a huge amount of effort, but it sure seems there should be a more elegant, built-in solution for this and I’d hate to write code for functionality that already exists.

TL;DR: I want to know if a hostname belongs to a certain domain or a subdomain of a domain, regardless of how many sub-domain levels deep it might be, using built-in .NET Core functionality.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật