Merge commit from fork

* fix: Improve host header handling and deployment mode detection

* ZITADEL_CLOUD env

* refactor service config

* service config

* cleanup

* cleanup

* util for original and public host

* instanceHost, publicHost

* cleanup constructUrl

* cleanup middleware

* add x-zitadel-forward-host as fallback for current cloud setup

* fix build

* fix: lint

* fix: update test mocks

* fix: provide basepath to unit tests

* host handling

* unit tests

* imports

* fix: getPublicHost instead of getInstanceHost

* unit tests

* update nextjs, implement jwt verify for logout_token

* pass logout information in jwt to login v2

* handle hosts in jwks url

* point idp callbacks to the api and not the login UI

* logout_hint out of logout token, typecheck

* rm unused imports

* fix oidc integration test

---------

Co-authored-by: Livio Spring <[email protected]>
This commit is contained in:
Max Peintner
2025-12-08 10:01:49 +01:00
committed by GitHub
co-authored by Livio Spring
parent f9e3871bb3
commit df75be96ff
75 changed files with 2075 additions and 1817 deletions
+7 -13
View File
@@ -3,9 +3,9 @@ import { DynamicTheme } from "@/components/dynamic-theme";
import { Translated } from "@/components/translated";
import { UserAvatar } from "@/components/user-avatar";
import { VerifyForm } from "@/components/verify-form";
import { getPublicHostWithProtocol } from "@/lib/server/host";
import { sendEmailCode, sendInviteEmailCode } from "@/lib/server/verify";
import { getOriginalHostWithProtocol } from "@/lib/server/host";
import { getServiceUrlFromHeaders } from "@/lib/service-url";
import { getServiceConfig } from "@/lib/service-url";
import { loadMostRecentSession } from "@/lib/session";
import { getBrandingSettings, getUserByID } from "@/lib/zitadel";
import { HumanUser, User } from "@zitadel/proto/zitadel/user/v2/user_pb";
@@ -24,12 +24,9 @@ export default async function Page(props: { searchParams: Promise<any> }) {
const { userId, loginName, code, organization, requestId, invite, send } = searchParams;
const _headers = await headers();
const { serviceUrl } = getServiceUrlFromHeaders(_headers);
const { serviceConfig } = getServiceConfig(_headers);
const branding = await getBrandingSettings({
serviceUrl,
organization,
});
const branding = await getBrandingSettings({ serviceConfig, organization });
let sessionFactors;
let user: User | undefined;
@@ -43,7 +40,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
const basePath = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
async function sendEmail(userId: string) {
const hostWithProtocol = await getOriginalHostWithProtocol();
const hostWithProtocol = await getPublicHostWithProtocol(_headers);
if (invite === "true") {
await sendInviteEmailCode({
@@ -70,7 +67,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
if ("loginName" in searchParams) {
sessionFactors = await loadMostRecentSession({
serviceUrl,
serviceConfig,
sessionParams: {
loginName,
organization,
@@ -85,10 +82,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
await sendEmail(userId);
}
const userResponse = await getUserByID({
serviceUrl,
userId,
});
const userResponse = await getUserByID({ serviceConfig, userId });
if (userResponse) {
user = userResponse.user;
if (user?.type.case === "human") {
@@ -1,7 +1,7 @@
import { DynamicTheme } from "@/components/dynamic-theme";
import { Translated } from "@/components/translated";
import { UserAvatar } from "@/components/user-avatar";
import { getServiceUrlFromHeaders } from "@/lib/service-url";
import { getServiceConfig } from "@/lib/service-url";
import { loadMostRecentSession } from "@/lib/session";
import { getBrandingSettings, getUserByID } from "@/lib/zitadel";
import { HumanUser, User } from "@zitadel/proto/zitadel/user/v2/user_pb";
@@ -11,18 +11,14 @@ export default async function Page(props: { searchParams: Promise<any> }) {
const searchParams = await props.searchParams;
const _headers = await headers();
const { serviceUrl } = getServiceUrlFromHeaders(_headers);
const { serviceConfig } = getServiceConfig(_headers);
const { loginName, organization, userId } = searchParams;
const branding = await getBrandingSettings({
serviceUrl,
organization,
const branding = await getBrandingSettings({ serviceConfig, organization,
});
const sessionFactors = await loadMostRecentSession({
serviceUrl,
sessionParams: { loginName, organization },
const sessionFactors = await loadMostRecentSession({ serviceConfig, sessionParams: { loginName, organization },
}).catch((error) => {
console.warn("Error loading session:", error);
});
@@ -33,9 +29,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
throw Error("Failed to get user id");
}
const userResponse = await getUserByID({
serviceUrl,
userId: id,
const userResponse = await getUserByID({ serviceConfig, userId: id,
});
let user: User | undefined;