diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts index abe7b63..eae675c 100644 --- a/app/api/auth/[...nextauth]/route.ts +++ b/app/api/auth/[...nextauth]/route.ts @@ -1,116 +1,20 @@ -// import { handlers } from "@/auth"; // Referring to the auth.ts we just created - -// export const { GET, POST } = handlers; - -import NextAuth, { NextAuthOptions } from "next-auth"; -import BoxyHQSAMLProvider from "next-auth/providers/boxyhq-saml"; +import NextAuth from "next-auth"; +import BoxyHQ from "next-auth/providers/boxyhq-saml"; const samlLoginUrl = process.env.AUTH_BOXYHQ_SAML_ISSUER; // For more information on each option (and a full list of options) go to // https://next-auth.js.org/configuration/options - -export const authOptions: NextAuthOptions = { +const handler = NextAuth({ // https://next-auth.js.org/configuration/providers/oauth providers: [ - // OAuth flow - BoxyHQSAMLProvider({ + BoxyHQ({ authorization: { params: { scope: "" } }, issuer: samlLoginUrl, clientId: process.env.AUTH_BOXYHQ_SAML_ID || "dummy", clientSecret: process.env.AUTH_BOXYHQ_SAML_SECRET || "dummy", }), - // // Open Id connect flow - // BoxyHQSAMLProvider({ - // name: "BoxyHQ OIDC", - // id: "boxyhq-saml-oidc", - // issuer: samlLoginUrl, - // wellKnown: `${samlLoginUrl}/.well-known/openid-configuration`, - // authorization: { params: { scope: "openid email" } }, - // clientId: process.env.AUTH_BOXYHQ_SAML_ID || "dummy", - // clientSecret: process.env.AUTH_BOXYHQ_SAML_SECRET || "dummy", - // }), - // CredentialsProvider({ - // id: "boxyhq-idp", - // // The name to display on the sign in form (e.g. 'Sign in with...') - // name: "IdP Login", - // // The credentials is used to generate a suitable form on the sign in page. - // // You can specify whatever fields you are expecting to be submitted. - // // e.g. domain, username, password, 2FA token, etc. - // // You can pass any HTML attribute to the tag through the object. - // credentials: { - // code: { - // label: - // "Code: Go to https://mocksaml.com/saml/login to initiate SAML IdP login", - // type: "text", - // placeholder: "Enter code", - // }, - // }, - // async authorize(credentials) { - // const { code } = credentials || {}; - - // if (!code) { - // return null; - // } - - // const res = await fetch(`${samlLoginUrl}/api/oauth/token`, { - // method: "POST", - // body: JSON.stringify({ - // grant_type: "authorization_code", - // client_id: process.env.AUTH_BOXYHQ_SAML_ID || "dummy", - // client_secret: process.env.AUTH_BOXYHQ_SAML_SECRET || "dummy", - // redirect_uri: process.env.NEXTAUTH_URL + "/games", - // code, - // }), - // headers: { - // "Content-Type": "application/json", - // }, - // }); - - // if (res.status !== 200) { - // return null; - // } - - // const json = await res.json(); - // if (!json?.access_token) { - // return null; - // } - - // const resUserInfo = await fetch(`${samlLoginUrl}/api/oauth/userinfo`, { - // headers: { - // Authorization: `Bearer ${json.access_token}`, - // }, - // }); - - // if (resUserInfo.status !== 200) { - // return null; - // } - // const profile = await resUserInfo.json(); - - // console.log(profile); - - // if (profile?.id && profile?.email) { - // return { - // id: profile.id, - // email: profile.email, - // name: [profile.firstName, profile.lastName] - // .filter(Boolean) - // .join(" "), - // image: null, - // }; - // } - - // return null; - // }, - // }), ], - // callbacks: { - // async jwt({ token }) { - // token.userRole = "admin"; - // return token; - // }, - // }, -}; +}); -const handler = NextAuth(authOptions); export { handler as GET, handler as POST }; diff --git a/app/components/login-button.tsx b/app/components/login-button.tsx new file mode 100644 index 0000000..b5bf904 --- /dev/null +++ b/app/components/login-button.tsx @@ -0,0 +1,34 @@ +"use client"; + +import { signIn } from "next-auth/react"; + +export function LoginButton() { + const tenant = "boxyhq.com"; + const product = "saml-demo.boxyhq.com"; + + return ( + + ); +} diff --git a/app/components/logout-button.tsx b/app/components/logout-button.tsx new file mode 100644 index 0000000..df5e944 --- /dev/null +++ b/app/components/logout-button.tsx @@ -0,0 +1,25 @@ +"use client"; + +import { signOut } from "next-auth/react"; + +export function LogoutButton() { + return ( + + ); +} diff --git a/app/games/page.tsx b/app/games/page.tsx index 48233c5..b717684 100644 --- a/app/games/page.tsx +++ b/app/games/page.tsx @@ -1,3 +1,36 @@ +import Link from "next/link"; + +import { LogoutButton } from "../components/logout-button"; + export default function Page() { - return

Games

; + return ( + <> +
+

Games

+ +
+ +
+

+ Find the games you want to play in the list below. Some games needs + your playername for whitelist. You can always come back to this page + by login in again. +

+
+ Minecraft +

+ To connect to minecraft visit{" "} + mc.chs.se. +

+
+ + +
+ + ); } diff --git a/app/lib/cn.ts b/app/lib/cn.ts new file mode 100644 index 0000000..54da2c1 --- /dev/null +++ b/app/lib/cn.ts @@ -0,0 +1,6 @@ +import { ClassValue, clsx } from "clsx"; +import { twMerge } from "tailwind-merge"; + +export function cn(...inputs: ClassValue[]) { + return twMerge(clsx(inputs)); +} \ No newline at end of file diff --git a/app/page.tsx b/app/page.tsx index 4845eab..a12b725 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,6 +1,4 @@ -"use client"; - -import { signIn } from "next-auth/react"; +import { LoginButton } from "@/app/components/login-button"; import Image from "next/image"; import Link from "next/link"; @@ -8,9 +6,6 @@ import chs from "../public/chs.png"; import minecraft from "../public/games/minecraft.png"; import gud from "../public/gud-clean.png"; -const tenant = "boxyhq.com"; -const product = "saml-demo.boxyhq.com"; - export default function Home() { return ( <> @@ -27,29 +22,7 @@ export default function Home() { A part of Chalmers student union

- +
- +