Add authentik
This commit is contained in:
		
							
								
								
									
										0
									
								
								next.config.js
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										0
									
								
								next.config.js
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| @@ -10,4 +10,41 @@ const config = { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| export default config; | export default config; | ||||||
|  | /** | ||||||
|  |  * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful | ||||||
|  |  * for Docker builds. | ||||||
|  |  */ | ||||||
|  | //await import("./src/env.js"); | ||||||
|  |  | ||||||
|  | //const cspHeader = ` | ||||||
|  |     //default-src 'self'; | ||||||
|  |     //script-src 'self' 'unsafe-eval' 'unsafe-inline'; | ||||||
|  |     //style-src 'self' 'unsafe-inline'; | ||||||
|  |     //img-src 'self' blob: data:; | ||||||
|  |     //font-src 'self'; | ||||||
|  |     //object-src 'none'; | ||||||
|  |     //base-uri 'self'; | ||||||
|  |     //form-action 'self'; | ||||||
|  |     //frame-ancestors 'none'; | ||||||
|  |     //upgrade-insecure-requests; | ||||||
|  | //` | ||||||
|  |  | ||||||
|  | //[>* @type {import("next").NextConfig} <] | ||||||
|  | //const config = { | ||||||
|  |   //async headers() { | ||||||
|  |     //return [ | ||||||
|  |       //{ | ||||||
|  |         //source: "/(.*)", | ||||||
|  |         //headers: [ | ||||||
|  |           //{ | ||||||
|  |             //key: "Content-Security-Policy", | ||||||
|  |             //value: cspHeader.replace(/\n/g, ''), | ||||||
|  |           //}, | ||||||
|  |         //], | ||||||
|  |       //}, | ||||||
|  |     //]; | ||||||
|  |   //}, | ||||||
|  | //}; | ||||||
|  |  | ||||||
|  | //export default config; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| import NextAuth from "next-auth" | import NextAuth from "next-auth" | ||||||
| import Entra from "next-auth/providers/microsoft-entra-id" | import Entra from "next-auth/providers/microsoft-entra-id" | ||||||
|  | import Authentik from "next-auth/providers/authentik" | ||||||
|   |   | ||||||
| export const { handlers, auth, signIn, signOut } = NextAuth({ | export const { handlers, auth, signIn, signOut } = NextAuth({ | ||||||
|   providers: [ |   providers: [ | ||||||
| @@ -8,5 +9,10 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ | |||||||
|       clientSecret: process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET, |       clientSecret: process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET, | ||||||
|       tenantId: process.env.AUTH_MICROSOFT_ENTRA_ID_TENANT_ID, |       tenantId: process.env.AUTH_MICROSOFT_ENTRA_ID_TENANT_ID, | ||||||
|     }), |     }), | ||||||
|  |     Authentik({ | ||||||
|  |       clientId: process.env.AUTH_AUTHENTIK_CLIENT_ID, | ||||||
|  |       clientSecret: process.env.AUTH_AUTHENTIK_CLIENT_SECRET, | ||||||
|  |       issuer: process.env.AUTH_AUTHENTIK_ISSUER, | ||||||
|  |     }), | ||||||
|   ], |   ], | ||||||
| }) | }) | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| import { signIn } from "next-auth/react"; | import { signIn } from "next-auth/react"; | ||||||
| import { Button } from "~/components/ui/shadcn/button"; | import { Button } from "~/components/ui/shadcn/button"; | ||||||
| 
 | 
 | ||||||
| export default function Sign_In() { | export default function Sign_In_Authentik() { | ||||||
|   return ( |   return ( | ||||||
|     <Button |     <Button | ||||||
|       onClick={() => signIn()} |       onClick={() => signIn('authentik')} | ||||||
|       className="bg-gradient-to-tl from-[#35363F] to=[#24191A] rounded-xl |       className="bg-gradient-to-tl from-[#35363F] to=[#24191A] rounded-xl | ||||||
|         px-4 py-2 md:py-2.5 font-semibold text-white hover:bg-gradient-to-tr |         px-4 py-2 md:py-2.5 font-semibold text-white hover:bg-gradient-to-tr | ||||||
|         hover:from-[#35363F] hover:to-[#23242F]" |         hover:from-[#35363F] hover:to-[#23242F]" | ||||||
							
								
								
									
										15
									
								
								src/components/auth/client/microsoft/Sign_In.tsx
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										15
									
								
								src/components/auth/client/microsoft/Sign_In.tsx
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | import { signIn } from "next-auth/react"; | ||||||
|  | import { Button } from "~/components/ui/shadcn/button"; | ||||||
|  |  | ||||||
|  | export default function Sign_In_Microsoft() { | ||||||
|  |   return ( | ||||||
|  |     <Button | ||||||
|  |       onClick={() => signIn('microsoft-entra-id')} | ||||||
|  |       className="bg-gradient-to-tl from-[#35363F] to=[#24191A] rounded-xl | ||||||
|  |         px-4 py-2 md:py-2.5 font-semibold text-white hover:bg-gradient-to-tr | ||||||
|  |         hover:from-[#35363F] hover:to-[#23242F]" | ||||||
|  |     > | ||||||
|  |       <h1 className="md:text-2xl my-auto font-semibold">Sign In</h1> | ||||||
|  |     </Button> | ||||||
|  |   ); | ||||||
|  | }; | ||||||
							
								
								
									
										21
									
								
								src/components/auth/server/authentik/Sign_In.tsx
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										21
									
								
								src/components/auth/server/authentik/Sign_In.tsx
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,21 @@ | |||||||
|  | import Image from "next/image"; | ||||||
|  | import { signIn } from "~/auth"; | ||||||
|  |  | ||||||
|  | export default async function Sign_In_Authentik() { | ||||||
|  |   return ( | ||||||
|  |     <form className="items-center justify-center mx-auto" | ||||||
|  |       action={async () => { | ||||||
|  |         "use server"; | ||||||
|  |         await signIn("authentik"); | ||||||
|  |       }}> | ||||||
|  |       <button type="submit" className="flex flex-row mx-auto | ||||||
|  |         bg-gradient-to-tl from-[#35363F] to=[#24191A] rounded-xl px-4 py-2 md:py-2.5 | ||||||
|  |         font-semibold text-white hover:bg-gradient-to-tr hover:from-[#35363F] hover:to-[#23242F]"> | ||||||
|  |         <Image src="/images/microsoft_logo.png" alt="Microsoft" width={35} height={35} | ||||||
|  |           className="mr-2" | ||||||
|  |         /> | ||||||
|  |         <h1 className="md:text-2xl my-auto font-semibold">Sign In with Authentik</h1> | ||||||
|  |       </button> | ||||||
|  |     </form> | ||||||
|  |   ); | ||||||
|  | } | ||||||
| @@ -1,7 +1,7 @@ | |||||||
| import Image from "next/image"; | import Image from "next/image"; | ||||||
| import { signIn } from "~/auth"; | import { signIn } from "~/auth"; | ||||||
| 
 | 
 | ||||||
| export default async function Sign_In() { | export default async function Sign_In_Microsoft() { | ||||||
|   return ( |   return ( | ||||||
|     <form className="items-center justify-center mx-auto" |     <form className="items-center justify-center mx-auto" | ||||||
|       action={async () => { |       action={async () => { | ||||||
| @@ -1,6 +1,7 @@ | |||||||
| import Link from "next/link"; | import Link from "next/link"; | ||||||
| import Image from "next/image"; | import Image from "next/image"; | ||||||
| import Sign_In from "~/components/auth/server/Sign_In"; | import Sign_In_Microsoft from "~/components/auth/server/microsoft/Sign_In"; | ||||||
|  | import Sign_In_Authentik from "~/components/auth/server/authentik/Sign_In"; | ||||||
| import Header from "~/components/ui/Header"; | import Header from "~/components/ui/Header"; | ||||||
|  |  | ||||||
| export default function No_Session() { | export default function No_Session() { | ||||||
| @@ -12,7 +13,10 @@ export default function No_Session() { | |||||||
|       </div> |       </div> | ||||||
|       <div className="mx-auto flex flex-col"> |       <div className="mx-auto flex flex-col"> | ||||||
|         <div className="py-4"> |         <div className="py-4"> | ||||||
|           < Sign_In /> |           < Sign_In_Microsoft /> | ||||||
|  |         </div> | ||||||
|  |         <div className="py-4"> | ||||||
|  |           < Sign_In_Authentik /> | ||||||
|         </div> |         </div> | ||||||
|         <Link href="https://git.gibbyb.com/gib/Tech_Tracker_Web" |         <Link href="https://git.gibbyb.com/gib/Tech_Tracker_Web" | ||||||
|           className="text-center text-[16px] md:text-lg px-4 py-2 md:py-2.5 font-semibold |           className="text-center text-[16px] md:text-lg px-4 py-2 md:py-2.5 font-semibold | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user