Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

made saml and scim multiprovider

Steven Teyadce7dd0b570
diff --git a/components/app/modals/saml-modal.tsx b/components/app/modals/saml-modal.tsx
index 66eda35b88..187cf992bd 100644
--- a/components/app/modals/saml-modal.tsx
+++ b/components/app/modals/saml-modal.tsx
@@ -12,8 +12,10 @@ import { ArrowRight, Lock } from "lucide-react";
import { Logo } from "#/ui/icons";
import useProject from "#/lib/swr/use-project";
import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip";
-import { HOME_DOMAIN } from "#/lib/constants";
+import { HOME_DOMAIN, SAML_PROVIDERS } from "#/lib/constants";
import useSAML from "#/lib/swr/use-saml";
+import { SAMLProviderProps } from "#/lib/types";
+import { cn } from "#/lib/utils";
function SAMLModal({
showSAMLModal,
@@ -23,18 +25,21 @@ function SAMLModal({
setShowSAMLModal: Dispatch<SetStateAction<boolean>>;
}) {
const { slug } = useProject();
+ const [selectedProvider, setSelectedProvider] = useState<
+ SAMLProviderProps["saml"] | undefined
+ >("okta");
const [submitting, setSubmitting] = useState(false);
- const { mutate } = useSAML();
+ const { provider, configured, mutate } = useSAML();
return (
<Modal showModal={showSAMLModal} setShowModal={setShowSAMLModal}>
<div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-8 sm:px-16">
- <div className="rounded-full border border-gray-200 p-2">
- <Lock className="h-4 w-4 text-gray-600" />
+ <div className="rounded-full border border-gray-200 p-3">
+ <Lock className="h-5 w-5 text-gray-600" />
</div>
<h3 className="text-lg font-medium">Configure SAML</h3>
<p className="text-center text-sm text-gray-500">
- Configure SAML for your Dub account.
+ Select a provider to configure SAML for your Dub project.
</p>
</div>
@@ -68,30 +73,70 @@ function SAMLModal({
<div>
<div className="flex items-center space-x-1">
<h2 className="text-sm font-medium text-gray-900">
- Metadata URL
+ SAML Provider
</h2>
<InfoTooltip
content={
<SimpleTooltipContent
- title={`Your Short.io API Key can be found in your Short.io account under "Integrations & API".`}
+ title="Your directory provider is the IDP you use to manage your users."
cta="Read the guide."
- href={`${HOME_DOMAIN}/help/article/migrating-from-short`}
+ href={`${HOME_DOMAIN}/help/article/configuring-scim`}
/>
}
/>
</div>
- <input
- id="metadataUrl"
- name="metadataUrl"
- autoFocus
- type="url"
- placeholder="https://"
- autoComplete="off"
+ <select
+ id="provider"
+ name="provider"
required
- className="mt-1 block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 placeholder-gray-400 shadow-sm focus:border-black focus:outline-none focus:ring-black sm:text-sm"
- />
+ value={selectedProvider}
+ onChange={(e) =>
+ setSelectedProvider(e.target.value as SAMLProviderProps["saml"])
+ }
+ className="mt-1 block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-black focus:outline-none focus:ring-black sm:text-sm"
+ >
+ <option disabled>Select a provider</option>
+ {SAML_PROVIDERS.map((provider) => (
+ <option key={provider.saml} value={provider.saml}>
+ {provider.name}
+ </option>
+ ))}
+ </select>
</div>
- <Button text="Save changes" loading={submitting} />
+
+ {selectedProvider === "okta" && (
+ <div>
+ <div className="flex items-center space-x-1">
+ <h2 className="text-sm font-medium text-gray-900">
+ Metadata URL
+ </h2>
+ <InfoTooltip
+ content={
+ <SimpleTooltipContent
+ title={`Your Short.io API Key can be found in your Short.io account under "Integrations & API".`}
+ cta="Read the guide."
+ href={`${HOME_DOMAIN}/help/article/migrating-from-short`}
+ />
+ }
+ />
+ </div>
+ <input
+ id="metadataUrl"
+ name="metadataUrl"
+ autoFocus
+ type="url"
+ placeholder="https://"
+ autoComplete="off"
+ required
+ className="mt-1 block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 placeholder-gray-400 shadow-sm focus:border-black focus:outline-none focus:ring-black sm:text-sm"
+ />
+ </div>
+ )}
+ <Button
+ text="Save changes"
+ disabled={!selectedProvider}
+ loading={submitting}
+ />
</form>
</div>
</Modal>
diff --git a/components/app/modals/scim-modal.tsx b/components/app/modals/scim-modal.tsx
index 5a2d6ff74e..dde9afe1cc 100644
--- a/components/app/modals/scim-modal.tsx
+++ b/components/app/modals/scim-modal.tsx
@@ -3,7 +3,6 @@ import {
SetStateAction,
useCallback,
useMemo,
- useRef,
useState,
} from "react";
import Modal from "#/ui/modal";
diff --git a/lib/constants/index.ts b/lib/constants/index.ts
index 7142b921d1..9687b4f9b7 100644
--- a/lib/constants/index.ts
+++ b/lib/constants/index.ts
@@ -161,16 +161,19 @@ export const SAML_PROVIDERS = [
{
name: "Okta",
logo: "/_static/icons/okta.svg",
+ saml: "okta",
scim: "okta-scim-v2",
},
{
name: "Azure AD",
logo: "/_static/icons/azure.svg",
+ saml: "azure",
scim: "azure-scim-v2",
},
{
name: "Google Workspace",
logo: "/_static/icons/google.svg",
+ saml: "google",
scim: "google",
},
];
diff --git a/lib/types.ts b/lib/types.ts
index 777cb4361e..47199127c7 100644
--- a/lib/types.ts
+++ b/lib/types.ts
@@ -119,5 +119,6 @@ export interface ShortioDomainProps {
export interface SAMLProviderProps {
name: string;
logo: string;
+ saml: "okta" | "azure" | "google";
scim: keyof typeof DirectorySyncProviders;
}