The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
finalize Email domain enforcement UI
Steven Tey425eab212739
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/security/saml.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/security/saml.tsxindex 3865a90412..4f5bec4c1e 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/security/saml.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/security/saml.tsx@@ -120,123 +120,133 @@ export function SAML() {</p></div>- <div className="mt-2 flex items-center justify-between rounded-md border border-neutral-200 px-4 py-3">- <div className="flex items-center space-x-4">- {data.logo || (- <div className="h-8 w-8 animate-pulse rounded-full bg-neutral-100" />- )}- <div className="flex flex-col">- {data.title ? (- <h3 className="font-medium">{data.title}</h3>- ) : (- <div className="h-5 w-20 animate-pulse rounded-md bg-neutral-100" />+ <div className="mt-2 rounded-md border border-neutral-200 px-4 py-3">+ <div className="flex items-center justify-between">+ <div className="flex items-center space-x-4">+ {data.logo || (+ <div className="h-8 w-8 animate-pulse rounded-full bg-neutral-100" />)}- {data.description ? (- <p className="text-sm text-neutral-500">{data.description}</p>+ <div className="flex flex-col">+ {data.title ? (+ <h3 className="font-medium">{data.title}</h3>+ ) : (+ <div className="h-5 w-20 animate-pulse rounded-md bg-neutral-100" />+ )}+ {data.description ? (+ <p className="text-sm text-neutral-500">+ {data.description}+ </p>+ ) : (+ <div className="mt-2 h-4 w-40 animate-pulse rounded-md bg-neutral-100" />+ )}+ </div>+ </div>+ <div>+ {loading ? (+ <div className="h-9 w-24 animate-pulse rounded-md bg-neutral-100" />+ ) : configured ? (+ <Popover+ content={+ <div className="grid w-full gap-1 p-2 sm:w-48">+ <button+ onClick={() => {+ setShowRemoveSAMLModal(true);+ setOpenPopover(false);+ }}+ className="rounded-md p-2 text-left text-sm font-medium text-red-600 transition-all duration-75 hover:bg-red-600 hover:text-white"+ >+ <IconMenu+ text="Remove"+ icon={<ShieldOff className="h-4 w-4" />}+ />+ </button>+ </div>+ }+ align="end"+ openPopover={openPopover}+ setOpenPopover={setOpenPopover}+ >+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ setOpenPopover(!openPopover);+ }}+ className="rounded-md px-1 py-2 transition-all duration-75 hover:bg-neutral-100 active:bg-neutral-200"+ >+ <span className="sr-only">Edit</span>+ <ThreeDots className="h-5 w-5 text-neutral-500" />+ </button>+ </Popover>) : (- <div className="mt-2 h-4 w-40 animate-pulse rounded-md bg-neutral-100" />+ <Button+ text="Configure"+ disabled={plan !== "enterprise"}+ {...(plan !== "enterprise" && {+ disabledTooltip: (+ <TooltipContent+ title="SAML SSO is only available on Enterprise plans. Upgrade to get started."+ cta="Contact sales"+ href="https://dub.co/enterprise"+ target="_blank"+ />+ ),+ })}+ onClick={() => setShowSAMLModal(true)}+ />)}</div></div>- <div>- {loading ? (- <div className="h-9 w-24 animate-pulse rounded-md bg-neutral-100" />- ) : configured ? (- <Popover- content={- <div className="grid w-full gap-1 p-2 sm:w-48">- <button- onClick={() => {- setShowRemoveSAMLModal(true);- setOpenPopover(false);- }}- className="rounded-md p-2 text-left text-sm font-medium text-red-600 transition-all duration-75 hover:bg-red-600 hover:text-white"- >- <IconMenu- text="Remove"- icon={<ShieldOff className="h-4 w-4" />}- />- </button>- </div>- }- align="end"- openPopover={openPopover}- setOpenPopover={setOpenPopover}- >- <button- type="button"- onClick={(e) => {- e.stopPropagation();- setOpenPopover(!openPopover);- }}- className="rounded-md px-1 py-2 transition-all duration-75 hover:bg-neutral-100 active:bg-neutral-200"++ {configured && (+ <form+ onSubmit={handleSubmit(onSubmit)}+ className="mt-4 border-t border-neutral-100 pt-4"+ >+ <div className="flex items-center space-x-2">+ <label+ htmlFor="ssoEmailDomain"+ className="text-sm font-medium text-neutral-700">- <span className="sr-only">Edit</span>- <ThreeDots className="h-5 w-5 text-neutral-500" />- </button>- </Popover>- ) : (- <Button- text="Configure"- disabled={plan !== "enterprise"}- {...(plan !== "enterprise" && {- disabledTooltip: (- <TooltipContent- title="SAML SSO is only available on Enterprise plans. Upgrade to get started."- cta="Contact sales"- href="https://dub.co/enterprise"- target="_blank"- />- ),- })}- onClick={() => setShowSAMLModal(true)}- />- )}- </div>+ Email domain enforcement+ </label>+ <InfoTooltip content="Users with email addresses from this domain will be required to authenticate via SAML SSO. Leave empty to allow all users to choose their authentication method." />+ </div>+ <div className="mt-2 flex items-center space-x-3">+ <input+ {...register("ssoEmailDomain")}+ id="ssoEmailDomain"+ type="text"+ placeholder="example.com"+ className="w-full rounded-md border border-neutral-300 px-3 py-1.5 text-sm placeholder-neutral-400 focus:border-black focus:outline-none focus:ring-black"+ disabled={plan !== "enterprise"}+ />+ <Button+ type="submit"+ text="Save changes"+ loading={isSubmitting}+ disabled={plan !== "enterprise" || !isDirty}+ className="h-9 w-fit px-6"+ />+ </div>+ <p className="mt-1.5 text-xs text-neutral-500">+ Enter your organization's email domain (e.g., company.com)+ </p>+ </form>+ )}</div></div><div className="rounded-b-lg border-t border-neutral-200 bg-neutral-50 px-3 py-5 sm:px-10">- {configured ? (- <form onSubmit={handleSubmit(onSubmit)} className="space-y-4">- <div className="flex items-center space-x-2">- <label- htmlFor="ssoEmailDomain"- className="text-sm font-medium text-neutral-700"- >- Email Domain for SAML Enforcement- </label>- <InfoTooltip content="Users with email addresses from this domain will be required to authenticate via SAML SSO. Leave empty to allow all users to choose their authentication method." />- </div>- <div className="flex items-center space-x-3">- <input- {...register("ssoEmailDomain")}- id="ssoEmailDomain"- type="text"- placeholder="example.com"- className="w-64 rounded-md border border-neutral-300 px-3 py-2 text-sm placeholder-neutral-400 focus:border-black focus:outline-none focus:ring-black"- disabled={plan !== "enterprise"}- />- <Button- type="submit"- text="Save"- loading={isSubmitting}- disabled={plan !== "enterprise" || !isDirty}- className="w-fit"- />- </div>- </form>- ) : (- <div className="flex items-center justify-between">- <a- href="https://dub.co/help/category/saml-sso"- target="_blank"- className="text-sm text-neutral-400 underline underline-offset-4 transition-colors hover:text-neutral-700"- >- Learn more about SAML SSO.- </a>- </div>- )}+ <div className="flex items-center justify-between">+ <a+ href="https://dub.co/help/category/saml-sso"+ target="_blank"+ className="text-sm text-neutral-400 underline underline-offset-4 transition-colors hover:text-neutral-700"+ >+ Learn more about SAML SSO.+ </a>+ </div></div></div></>diff --git a/apps/web/lib/api/workspaces/is-saml-enforced-for-email-domain.ts b/apps/web/lib/api/workspaces/is-saml-enforced-for-email-domain.tsindex 8c5b832108..0728b11345 100644--- a/apps/web/lib/api/workspaces/is-saml-enforced-for-email-domain.ts+++ b/apps/web/lib/api/workspaces/is-saml-enforced-for-email-domain.ts@@ -6,7 +6,7 @@ import { isGenericEmail } from "../../is-generic-email";// Checks if SAML SSO is enforced for a given email domainexport const isSamlEnforcedForEmailDomain = async (email: string) => {const hostname = (await headers()).get("host");- const emailDomain = email.split("@")[1];+ const emailDomain = email.split("@")[1].toLowerCase();if (!hostname ||