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.

account for different env

Steven Tey8cc2102ea106
diff --git a/lib/jackson.ts b/lib/jackson.ts
index d9b097992f..4db6d1989c 100644
--- a/lib/jackson.ts
+++ b/lib/jackson.ts
@@ -7,12 +7,17 @@ import type {
IDirectorySyncController,
} from "@boxyhq/saml-jackson";
-export const samlPath = "/api/auth/saml/callback";
export const samlAudience = "https://saml.dub.co";
const opts: JacksonOption = {
- externalUrl: process.env.NEXTAUTH_URL as string,
- samlPath,
+ externalUrl:
+ process.env.NODE_ENV === "production"
+ ? "https://api.dub.co"
+ : `${process.env.NEXTAUTH_URL}`,
+ samlPath:
+ process.env.NODE_ENV === "production"
+ ? "/auth/saml/callback"
+ : "/api/auth/saml/callback",
samlAudience,
db: {
engine: "planetscale",
@@ -23,7 +28,8 @@ const opts: JacksonOption = {
},
},
idpEnabled: true, // to allow folks to SSO directly from their IDP
- scimPath: "/api/scim/v2.0", // custom SCIM endpoint
+ scimPath:
+ process.env.NODE_ENV === "production" ? "/scim/v2.0" : "/api/scim/v2.0", // custom SCIM endpoint
clientSecretVerifier: process.env.NEXTAUTH_SECRET as string,
};
diff --git a/pages/api/auth/[...nextauth].tsx b/pages/api/auth/[...nextauth].tsx
index de6a6cbada..552bc2c26e 100644
--- a/pages/api/auth/[...nextauth].tsx
+++ b/pages/api/auth/[...nextauth].tsx
@@ -197,7 +197,6 @@ export const authOptions: NextAuthOptions = {
account?.provider === "saml" ||
account?.provider === "saml-idp"
) {
- console.log({ user, account, profile });
let samlProfile;
if (account?.provider === "saml-idp") {
diff --git a/pages/api/projects/[slug]/saml.ts b/pages/api/projects/[slug]/saml.ts
index 9b9399ad8f..5eb842aaa7 100644
--- a/pages/api/projects/[slug]/saml.ts
+++ b/pages/api/projects/[slug]/saml.ts
@@ -1,5 +1,6 @@
import { withProjectAuth } from "#/lib/auth";
-import jackson, { samlAudience, samlPath } from "#/lib/jackson";
+import { APP_DOMAIN_WITH_NGROK } from "#/lib/constants";
+import jackson, { samlAudience } from "#/lib/jackson";
export default withProjectAuth(
async (req, res, project) => {
@@ -15,7 +16,10 @@ export default withProjectAuth(
const response = {
connections,
issuer: samlAudience,
- acs: `${process.env.NEXTAUTH_URL}${samlPath}`,
+ acs:
+ process.env.NODE_ENV === "production"
+ ? "https://api.dub.co/auth/saml/callback"
+ : `${APP_DOMAIN_WITH_NGROK}/api/auth/saml/callback`,
};
return res.status(200).json(response);
@@ -30,7 +34,10 @@ export default withProjectAuth(
encodedRawMetadata: "",
metadataUrl,
defaultRedirectUrl: `${process.env.NEXTAUTH_URL}/auth/saml`,
- redirectUrl: process.env.NEXTAUTH_URL as string,
+ redirectUrl:
+ process.env.NODE_ENV === "production"
+ ? "https://api.dub.co"
+ : `${process.env.NEXTAUTH_URL}`,
tenant: project.id,
product: "Dub",
});