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.

created guide article for okta saml

Steven Tey2f8b95306571
diff --git a/app/dub.sh/providers.tsx b/app/dub.sh/providers.tsx
index 56c441c2fc..ab3089b0ff 100644
--- a/app/dub.sh/providers.tsx
+++ b/app/dub.sh/providers.tsx
@@ -1,6 +1,5 @@
"use client";
-import { SessionProvider } from "next-auth/react";
import { useSelectedLayoutSegment } from "next/navigation";
import { ReactNode } from "react";
@@ -13,10 +12,10 @@ export default function MarketingProviders({
}) {
const segment = useSelectedLayoutSegment();
return (
- <SessionProvider>
+ <>
{/* Only show stats modal if it's on the home page */}
{!segment && modal}
{children}
- </SessionProvider>
+ </>
);
}
diff --git a/app/providers.tsx b/app/providers.tsx
index cb102274e6..018465c543 100644
--- a/app/providers.tsx
+++ b/app/providers.tsx
@@ -1,6 +1,7 @@
"use client";
import { Dispatch, ReactNode, SetStateAction, createContext } from "react";
+import { SessionProvider } from "next-auth/react";
import { Toaster } from "sonner";
import { Analytics } from "@vercel/analytics/react";
import useCMDK from "#/ui/cmdk";
@@ -15,15 +16,17 @@ export default function Providers({ children }: { children: ReactNode }) {
const { CMDK, setShowCMDK } = useCMDK();
return (
- <AppContext.Provider
- value={{
- setShowCMDK,
- }}
- >
- <CMDK />
- <Toaster closeButton />
- {children}
- <Analytics />
- </AppContext.Provider>
+ <SessionProvider>
+ <AppContext.Provider
+ value={{
+ setShowCMDK,
+ }}
+ >
+ <CMDK />
+ <Toaster closeButton />
+ {children}
+ <Analytics />
+ </AppContext.Provider>
+ </SessionProvider>
);
}
diff --git a/app/ui/cmdk.tsx b/app/ui/cmdk.tsx
index 13014c742e..b05d8f9f9a 100644
--- a/app/ui/cmdk.tsx
+++ b/app/ui/cmdk.tsx
@@ -92,14 +92,19 @@ const CommandResults = ({
description: post.summary,
})),
// get all table of contents headings too
- ...allHelpPosts.flatMap((post) =>
- post.tableOfContents.map((toc: { title: string; slug: string }) => ({
- slug: `${post.slug}#${toc.slug}`,
- title: toc.title,
- description: null, // omit description since we don't want to search it
- summary: `In: "${post.title}"`,
- })),
- ),
+ ...allHelpPosts.flatMap((post) => {
+ if (post.excludeHeadingsFromSearch) {
+ return [];
+ }
+ return post.tableOfContents.map(
+ (toc: { title: string; slug: string }) => ({
+ slug: `${post.slug}#${toc.slug}`,
+ title: toc.title,
+ description: null, // omit description since we don't want to search it
+ summary: `In: "${post.title}"`,
+ }),
+ );
+ }),
];
const fuse = useMemo(
diff --git a/app/ui/content/copy-box.tsx b/app/ui/content/copy-box.tsx
new file mode 100644
index 0000000000..2532f86dbb
--- /dev/null
+++ b/app/ui/content/copy-box.tsx
@@ -0,0 +1,37 @@
+"use client";
+
+import { useState } from "react";
+import { Copy, Tick } from "@/components/shared/icons";
+import { toast } from "sonner";
+
+export default function CopyBox(props) {
+ const [copied, setCopied] = useState(false);
+ return (
+ <div className="not-prose rounded-xl border border-gray-200 bg-white p-4">
+ <p>{props.title}</p>
+ <div className="mt-1 flex w-full items-center justify-between rounded-md bg-gray-100 px-3 py-2">
+ <div className="overflow-auto scrollbar-hide">
+ <p className="whitespace-nowrap text-gray-600 sm:text-sm">
+ {props.copy}
+ </p>
+ </div>
+ <button
+ type="button"
+ className="pl-2"
+ onClick={() => {
+ navigator.clipboard.writeText(props.copy);
+ setCopied(true);
+ toast.success("Copied to clipboard");
+ setTimeout(() => setCopied(false), 3000);
+ }}
+ >
+ {copied ? (
+ <Tick className="h-4 w-4 text-gray-500" />
+ ) : (
+ <Copy className="h-4 w-4 text-gray-500" />
+ )}
+ </button>
+ </div>
+ </div>
+ );
+}
diff --git a/app/ui/content/mdx.tsx b/app/ui/content/mdx.tsx
index 01b61a6b0c..8d730b27fd 100644
--- a/app/ui/content/mdx.tsx
+++ b/app/ui/content/mdx.tsx
@@ -5,16 +5,13 @@ import MDXTweet from "#/ui/tweet";
import { Tweet as TweetProps } from "react-tweet/api";
import { cn } from "#/lib/utils";
import "react-medium-image-zoom/dist/styles.css";
-import {
- HELP_CATEGORIES,
- POPULAR_ARTICLES,
- getPopularArticles,
-} from "#/lib/constants/content";
+import { HELP_CATEGORIES, POPULAR_ARTICLES } from "#/lib/constants/content";
import ArticleLink from "./article-link";
import CategoryCard from "./category-card";
import { ListChecks } from "lucide-react";
import ZoomImage from "./zoom-image";
import { allHelpPosts } from "contentlayer/generated";
+import CopyBox from "./copy-box";
const CustomLink = (props: any) => {
const href = props.href;
@@ -71,6 +68,7 @@ const components = {
{props.children}
</div>
),
+ CopyBox,
HelpArticles: (props: { articles: string[] }) => (
<div className="not-prose grid gap-2 rounded-xl border border-gray-200 bg-white p-4">
{(props.articles || POPULAR_ARTICLES).map((slug) => (
diff --git a/app/ui/content/zoom-image.tsx b/app/ui/content/zoom-image.tsx
index a41cd3c600..41ad53f2a4 100644
--- a/app/ui/content/zoom-image.tsx
+++ b/app/ui/content/zoom-image.tsx
@@ -7,7 +7,7 @@ import Zoom from "react-medium-image-zoom";
import "react-medium-image-zoom/dist/styles.css";
export default function ZoomImage(
- props: ImageProps & { blurDataURL?: string },
+ props: ImageProps & { blurDataURL?: string; hideCaption?: boolean },
) {
const { isDesktop } = useMediaQuery();
return (
@@ -23,9 +23,11 @@ export default function ZoomImage(
}
/>
</Zoom>
- <figcaption className="text-center text-sm italic text-gray-500">
- {props.alt}
- </figcaption>
+ {!props?.hideCaption && (
+ <figcaption className="text-center text-sm italic text-gray-500">
+ {props.alt}
+ </figcaption>
+ )}
</figure>
);
}
diff --git a/components/app/modals/saml-modal.tsx b/components/app/modals/saml-modal.tsx
index 187cf992bd..7f2eaae696 100644
--- a/components/app/modals/saml-modal.tsx
+++ b/components/app/modals/saml-modal.tsx
@@ -8,14 +8,12 @@ import {
import Modal from "#/ui/modal";
import Button from "#/ui/button";
import { toast } from "sonner";
-import { ArrowRight, Lock } from "lucide-react";
-import { Logo } from "#/ui/icons";
+import { Lock } from "lucide-react";
import useProject from "#/lib/swr/use-project";
import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip";
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,
@@ -29,7 +27,7 @@ function SAMLModal({
SAMLProviderProps["saml"] | undefined
>("okta");
const [submitting, setSubmitting] = useState(false);
- const { provider, configured, mutate } = useSAML();
+ const { mutate } = useSAML();
return (
<Modal showModal={showSAMLModal} setShowModal={setShowSAMLModal}>
@@ -78,9 +76,9 @@ function SAMLModal({
<InfoTooltip
content={
<SimpleTooltipContent
- title="Your directory provider is the IDP you use to manage your users."
+ title="Your SAML provider is the service you use to manage your users."
cta="Read the guide."
- href={`${HOME_DOMAIN}/help/article/configuring-scim`}
+ href={`${HOME_DOMAIN}/help/article/saml-sso`}
/>
}
/>
@@ -105,7 +103,7 @@ function SAMLModal({
</div>
{selectedProvider === "okta" && (
- <div>
+ <div className="border-t border-gray-200 pt-4">
<div className="flex items-center space-x-1">
<h2 className="text-sm font-medium text-gray-900">
Metadata URL
@@ -113,9 +111,9 @@ function SAMLModal({
<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`}
+ title="Your metadata URL is the URL to your SAML provider's metadata."
+ cta="Learn more."
+ href={`${HOME_DOMAIN}/help/article/saml-sso`}
/>
}
/>
diff --git a/content/help/okta-saml.mdx b/content/help/okta-saml.mdx
new file mode 100644
index 0000000000..e0fbb410f5
--- /dev/null
+++ b/content/help/okta-saml.mdx
@@ -0,0 +1,65 @@
+---
+title: Configuring SAML SSO with Okta
+updatedAt: 2023-08-09
+summary: For Dub Enterprise users, you can securely manage your team's access to Dub using Okta SAML SSO.
+author: steventey
+categories:
+ - saml-sso
+ - getting-started
+related:
+ # - okta-scim
+excludeHeadingsFromSearch: true
+---
+
+<Note variant="success">
+ This feature is only available on [Dub Enterprise](/pricing).
+</Note>
+
+For Dub Enterprise users, you can securely manage your team's access to Dub using [Okta SAML SSO](https://support.okta.com/help/s/article/okta-saml).
+
+## Step 1: Create SAML Integration
+
+In your Okta Dashboard, click on "Applications" in the sidebar.
+
+<Image
+ alt="Applications tab on the Okta Dashboard"
+ src="https://d2vwwcvoksz7ty.cloudfront.net/help/okta-saml-apps.png"
+ width={1491}
+ height={870}
+ hideCaption={true}
+/>
+
+Then, click on "Create App Integration".
+
+<Image
+ alt="Create App Integration button on the Okta Dashboard"
+ src="https://d2vwwcvoksz7ty.cloudfront.net/help/okta-saml-create-app.png"
+ width={1212}
+ height={746}
+ hideCaption={true}
+/>
+
+Select "SAML 2.0" as the sign on method, and click "Next".
+
+<Image
+ alt="Saml 2.0 option on the Okta Dashboard"
+ src="https://d2vwwcvoksz7ty.cloudfront.net/help/okta-saml-saml-2.png"
+ width={1009}
+ height={609}
+ hideCaption={true}
+/>
+
+In the "General Settings" page, enter "Dub" as the app name, and click "Next".
+
+<Image
+ alt="General Settings page on the Okta Dashboard"
+ src="https://d2vwwcvoksz7ty.cloudfront.net/help/okta-saml-app-name.png"
+ width={1103}
+ height={645}
+ hideCaption={true}
+/>
+
+<CopyBox
+ title="Copy this Single sign-on URL"
+ copy="https://api.dub.co/auth/saml/callback"
+/>
diff --git a/contentlayer.config.ts b/contentlayer.config.ts
index 16afcc318d..0e3c67d70e 100644
--- a/contentlayer.config.ts
+++ b/contentlayer.config.ts
@@ -124,6 +124,9 @@ export const HelpPost = defineDocumentType(() => ({
type: "string",
},
},
+ excludeHeadingsFromSearch: {
+ type: "boolean",
+ },
},
// @ts-ignore
computedFields: computedFields("help"),
diff --git a/lib/constants/content.tsx b/lib/constants/content.tsx
index d5dbe8261c..d8acfd98b8 100644
--- a/lib/constants/content.tsx
+++ b/lib/constants/content.tsx
@@ -1,6 +1,6 @@
import { Logo } from "#/ui/icons";
import { allHelpPosts } from "contentlayer/generated";
-import { Globe, Import, Link2, Settings, Webhook } from "lucide-react";
+import { Globe, Import, Link2, Lock, Settings, Webhook } from "lucide-react";
export const BLOG_CATEGORIES: {
title: string;
@@ -41,7 +41,8 @@ export const HELP_CATEGORIES: {
| "link-management"
| "custom-domains"
| "migrating"
- | "api";
+ | "api"
+ | "saml-sso";
description: string;
icon: JSX.Element;
}[] = [
@@ -81,6 +82,12 @@ export const HELP_CATEGORIES: {
description: "Learn how to use the Dub API.",
icon: <Webhook className="h-6 w-6 text-gray-500" />,
},
+ {
+ title: "SAML SSO",
+ slug: "saml-sso",
+ description: "Secure your Dub project with SAML SSO.",
+ icon: <Lock className="h-6 w-6 text-gray-500" />,
+ },
];
export const getPopularArticles = () => {
diff --git a/lib/constants/index.ts b/lib/constants/index.ts
index 9687b4f9b7..30af25bb54 100644
--- a/lib/constants/index.ts
+++ b/lib/constants/index.ts
@@ -31,25 +31,24 @@ export const FADE_IN_ANIMATION_SETTINGS = {
transition: { duration: 0.2 },
};
-export const HOME_HOSTNAMES = new Set([
- // comment for better diffs
- "dub.sh",
- "localhost",
- "localhost:3000",
-]);
+export const HOME_HOSTNAMES = new Set(["home.localhost:8888", "dub.sh"]);
+
+/*
+ NOTE: We're using home.localhost:8888 for HOME_DOMAIN and localhost:8888 for APP_DOMAIN
+ in local development because Google OAuth doesn't allow subdomain localhost (e.g. app.localhost:8888)
+ as the callback URL.
+*/
export const HOME_DOMAIN =
process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
? "https://dub.sh"
: process.env.NEXT_PUBLIC_VERCEL_ENV === "preview"
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
- : "http://localhost:3000";
+ : "http://home.localhost:8888";
export const APP_HOSTNAMES = new Set([
- "app.dub.sh",
- "app.localhost:3000",
- "app.localhost",
"localhost:8888",
+ "app.dub.sh",
"preview.dub.sh",
]);
diff --git a/lib/middleware/api.ts b/lib/middleware/api.ts
index a6a30aea20..6b068a4144 100644
--- a/lib/middleware/api.ts
+++ b/lib/middleware/api.ts
@@ -1,12 +1,15 @@
import { NextRequest, NextResponse } from "next/server";
import { parse } from "#/lib/middleware/utils";
+import { HOME_DOMAIN } from "../constants";
export default async function ApiMiddleware(req: NextRequest) {
const { path } = parse(req);
if (path.startsWith("/metatags")) {
const url = req.nextUrl.searchParams.get("url");
if (!url) {
- return NextResponse.rewrite(new URL("/metatags", req.url));
+ return NextResponse.redirect(`${HOME_DOMAIN}/metatags`, {
+ status: 301,
+ });
}
return NextResponse.rewrite(
new URL(`/api/edge/metatags?url=${url}`, req.url),
diff --git a/middleware.ts b/middleware.ts
index b5d248f240..e4e5761112 100644
--- a/middleware.ts
+++ b/middleware.ts
@@ -33,13 +33,17 @@ export default async function middleware(req: NextRequest, ev: NextFetchEvent) {
return AppMiddleware(req);
}
- // for API (api.dub.sh and api.localhost:3000)
- if (domain === "api.dub.sh" || domain === "api.localhost:3000") {
+ // for API (api.dub.co, api.dub.sh, and api.localhost:8888)
+ if (
+ domain === "api.dub.co" ||
+ domain === "api.dub.sh" ||
+ domain === "api.localhost:8888"
+ ) {
return ApiMiddleware(req);
}
- // for Admin (admin.dub.sh and admin.localhost:3000)
- if (domain === "admin.dub.sh" || domain === "admin.localhost:3000") {
+ // for Admin (admin.dub.sh and admin.localhost:8888)
+ if (domain === "admin.dub.sh" || domain === "admin.localhost:8888") {
return AdminMiddleware(req);
}