This repository has been archived by the owner on Dec 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdaeaa6
commit ea716b3
Showing
8 changed files
with
87 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import NextAuth from "next-auth"; | ||
import { custom } from "openid-client"; | ||
import { authOptions } from "./options"; | ||
|
||
custom.setHttpOptionsDefaults({ | ||
timeout: 10000, | ||
}); | ||
|
||
const handler = NextAuth(authOptions); | ||
|
||
export { handler as GET, handler as POST }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { getCsrfToken, getProviders } from "next-auth/react"; | ||
|
||
export default async function ZitadelForm({ | ||
callbackUrl, | ||
}: { | ||
callbackUrl: string | string[] | undefined; | ||
}) { | ||
const csrfToken = await getCsrfToken(); | ||
const providers = await getProviders(); | ||
var signinUrl = ""; | ||
var hasZitadel = providers?.hasOwnProperty("zitadel") ?? providers !== null; | ||
if (providers !== null && hasZitadel) { | ||
signinUrl = providers.zitadel.signinUrl; | ||
} | ||
|
||
return ( | ||
<> | ||
{callbackUrl !== null && csrfToken !== undefined && hasZitadel ? ( | ||
<form action={signinUrl} method="POST"> | ||
<input type="hidden" name="csrfToken" value={csrfToken} /> | ||
<input type="hidden" name="callbackUrl" value={callbackUrl} /> | ||
<button type="submit" className="button"> | ||
<span>Sign in with ZITADEL</span> | ||
</button> | ||
</form> | ||
) : ( | ||
<div>no zitadel</div> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
import { LoginButton, LogoutButton } from "../authbuttons"; | ||
"use client"; | ||
import ZitadelForm from "./Zitadelform"; | ||
|
||
export default function Page({ | ||
searchParams, | ||
}: { | ||
searchParams: { [key: string]: string | string[] | undefined }; | ||
}) { | ||
const callbackUrl = searchParams.callbackUrl; | ||
|
||
export default async function Home() { | ||
return ( | ||
<main | ||
style={{ | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
height: "70vh", | ||
}} | ||
> | ||
<div> | ||
<LoginButton /> | ||
<LogoutButton /> | ||
<div className="page h-screen text-black bg-white flex flex-col"> | ||
<div className="header-space h-20" /> | ||
<div className="signin"> | ||
<div className="card"> | ||
<div className="provider"> | ||
<ZitadelForm callbackUrl={callbackUrl} /> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { default } from "next-auth/middleware"; | ||
|
||
export const config = { | ||
matcher: ["/test"], | ||
}; |