allow multi level sudomains in domain picker

This commit is contained in:
miloschwartz
2025-07-18 15:48:23 -07:00
parent 7a59e3acf7
commit 2ddb4ec905
7 changed files with 53 additions and 71 deletions

View File

@@ -1162,7 +1162,7 @@
"selectDomainTypeCnameName": "Single Domain (CNAME)", "selectDomainTypeCnameName": "Single Domain (CNAME)",
"selectDomainTypeCnameDescription": "Just this specific domain. Use this for individual subdomains or specific domain entries.", "selectDomainTypeCnameDescription": "Just this specific domain. Use this for individual subdomains or specific domain entries.",
"selectDomainTypeWildcardName": "Wildcard Domain", "selectDomainTypeWildcardName": "Wildcard Domain",
"selectDomainTypeWildcardDescription": "This domain and its first level of subdomains.", "selectDomainTypeWildcardDescription": "This domain and its subdomains.",
"domainDelegation": "Single Domain", "domainDelegation": "Single Domain",
"selectType": "Select a type", "selectType": "Select a type",
"actions": "Actions", "actions": "Actions",

View File

@@ -620,8 +620,6 @@ authenticated.post(
authenticated.delete("/idp/:idpId", verifyUserIsServerAdmin, idp.deleteIdp); authenticated.delete("/idp/:idpId", verifyUserIsServerAdmin, idp.deleteIdp);
authenticated.get("/idp", verifyUserIsServerAdmin, idp.listIdps);
authenticated.get("/idp/:idpId", verifyUserIsServerAdmin, idp.getIdp); authenticated.get("/idp/:idpId", verifyUserIsServerAdmin, idp.getIdp);
authenticated.put( authenticated.put(

View File

@@ -261,14 +261,6 @@ async function createHttpResource(
) )
); );
} }
if (parsedSubdomain.data.includes(".")) {
return next(
createHttpError(
HttpCode.BAD_REQUEST,
"Subdomain cannot contain a dot when using wildcard domains"
)
);
}
fullDomain = `${subdomain}.${domainRes.domains.baseDomain}`; fullDomain = `${subdomain}.${domainRes.domains.baseDomain}`;
} else { } else {
fullDomain = domainRes.domains.baseDomain; fullDomain = domainRes.domains.baseDomain;

View File

@@ -297,14 +297,6 @@ async function updateHttpResource(
) )
); );
} }
if (parsedSubdomain.data.includes(".")) {
return next(
createHttpError(
HttpCode.BAD_REQUEST,
"Subdomain cannot contain a dot when using wildcard domains"
)
);
}
fullDomain = `${updateData.subdomain}.${domainRes.domains.baseDomain}`; fullDomain = `${updateData.subdomain}.${domainRes.domains.baseDomain}`;
} else { } else {
fullDomain = domainRes.domains.baseDomain; fullDomain = domainRes.domains.baseDomain;

View File

@@ -617,7 +617,7 @@ export default function Page() {
idp || null idp || null
); );
}} }}
cols={3} cols={2}
/> />
<FormMessage /> <FormMessage />
</FormItem> </FormItem>

View File

@@ -179,7 +179,7 @@ export default function DomainPicker({
}); });
} }
} else if (orgDomain.type === "wildcard") { } else if (orgDomain.type === "wildcard") {
// For wildcard domains, allow the base domain or one level up // For wildcard domains, allow the base domain or multiple levels up
const userInputLower = userInput.toLowerCase(); const userInputLower = userInput.toLowerCase();
const baseDomainLower = orgDomain.baseDomain.toLowerCase(); const baseDomainLower = orgDomain.baseDomain.toLowerCase();
@@ -194,14 +194,13 @@ export default function DomainPicker({
domainId: orgDomain.domainId domainId: orgDomain.domainId
}); });
} }
// Check if user input is one level up (subdomain.baseDomain) // Check if user input ends with the base domain (allows multiple level subdomains)
else if (userInputLower.endsWith(`.${baseDomainLower}`)) { else if (userInputLower.endsWith(`.${baseDomainLower}`)) {
const subdomain = userInputLower.slice( const subdomain = userInputLower.slice(
0, 0,
-(baseDomainLower.length + 1) -(baseDomainLower.length + 1)
); );
// Only allow one level up (no dots in subdomain) // Allow multiple levels (subdomain can contain dots)
if (!subdomain.includes(".")) {
options.push({ options.push({
id: `org-${orgDomain.domainId}`, id: `org-${orgDomain.domainId}`,
domain: userInput, domain: userInput,
@@ -213,7 +212,6 @@ export default function DomainPicker({
}); });
} }
} }
}
}); });
// Add provided domain options (always try to match provided domains) // Add provided domain options (always try to match provided domains)
@@ -320,7 +318,7 @@ export default function DomainPicker({
setUserInput(validInput); setUserInput(validInput);
}} }}
/> />
<p className="text-xs text-muted-foreground"> <p className="text-sm text-muted-foreground">
{build === "saas" {build === "saas"
? t("domainPickerDescriptionSaas") ? t("domainPickerDescriptionSaas")
: t("domainPickerDescription")} : t("domainPickerDescription")}
@@ -328,6 +326,7 @@ export default function DomainPicker({
</div> </div>
{/* Tabs and Sort Toggle */} {/* Tabs and Sort Toggle */}
{build === "saas" && (
<div className="flex justify-between items-center"> <div className="flex justify-between items-center">
<Tabs <Tabs
value={activeTab} value={activeTab}
@@ -364,6 +363,7 @@ export default function DomainPicker({
: t("domainPickerSortDesc")} : t("domainPickerSortDesc")}
</Button> </Button>
</div> </div>
)}
{/* Loading State */} {/* Loading State */}
{isChecking && ( {isChecking && (

View File

@@ -18,7 +18,7 @@ function PopoverTrigger({
function PopoverContent({ function PopoverContent({
className, className,
align = "center", align = "start",
sideOffset = 4, sideOffset = 4,
...props ...props
}: React.ComponentProps<typeof PopoverPrimitive.Content>) { }: React.ComponentProps<typeof PopoverPrimitive.Content>) {