Way to bypass auth for some subdomains in wildcard resource? #3698
|
I'm migrating from Cloudflare Tunnels, where I basically have a wildcard subdomain pointed to my homeserver with auth enabled, and then I add some subdomains to a bypass policy to allow public access. |
Replies: 1 comment
|
Not possible today, and the conflict you hit is a deliberate refusal rather than a validation quirk, so it is worth knowing exactly what it blocks before you design around it. The check is const suffix = fullDomain.slice(dotIndex); // ".example.com"
const wildcardPattern = `*.${fullDomain.slice(dotIndex + 1)}`; // "*.example.com"So there is no "more specific resource wins" precedence to reach for. The two resources cannot coexist at all, which is why the wildcard plus exception layout you had in Cloudflare has no direct translation. The bypass mechanism exists, but not keyed on the hostnamePangolin does have the equivalent of a bypass policy. Resource rules are evaluated before authentication, and an if (action == "ACCEPT") {
logger.debug("Resource allowed by rule");
...
return allowed(res, undefined, dontStripSession);
}The problem is what a rule can match on. The full set is One trap worth naming, because it looks like a workaround and is not: What to do insteadEnumerate. Create a resource per subdomain that needs its own auth treatment, with authentication off on the public ones, and use the wildcard only for a set where a single auth policy is correct for everything under it. It is more objects to manage than the Cloudflare setup, but it is the only layout the model expresses, and the conflict check means you cannot half-do it. I could not find an open issue tracking wildcard exceptions or a hostname rule match, so if you want this it is probably worth filing: the two pieces already exist separately, and what is missing is a rule match type keyed on the request host, which would let a single wildcard resource carry per-subdomain exceptions without touching the conflict rule at all. |
Not possible today, and the conflict you hit is a deliberate refusal rather than a validation quirk, so it is worth knowing exactly what it blocks before you design around it.
The check is
checkWildcardDomainConflict, and it runs on both create and update. It refuses in both directions at the immediate parent level: creating*.example.comwhen any specificfoo.example.comresource exists, and creatingpublic.example.comwhen*.example.comexists. For the specific-domain case it builds the parent pattern from the first label and looks for an exact match: