Add next-auth, direnv|flake.nix|.env.

Change-Id: I897a15f48ac61addfa27ca3d95e6c4849e73125a
Reviewed-on: https://git.clicks.codes/c/Caramels/Lotting/+/342
Tested-by: Samuel Shuert <coded@clicks.codes>
Reviewed-by: Samuel Shuert <coded@clicks.codes>
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..d37474a
--- /dev/null
+++ b/.envrc
@@ -0,0 +1,2 @@
+use flake . --impure
+dotenv .env
diff --git a/.gitignore b/.gitignore
index fd3dbb5..31cd26b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,8 @@
 # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
 
+.env
+.direnv/
+
 # dependencies
 /node_modules
 /.pnp
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..adc257e
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=ssh.clicks.codes
+port=29418
+defaultbranch=main
+project=Caramels/Lotting.git
diff --git "a/app/api/auth/\133...nextauth\135/route.ts" "b/app/api/auth/\133...nextauth\135/route.ts"
new file mode 100644
index 0000000..c3268de
--- /dev/null
+++ "b/app/api/auth/\133...nextauth\135/route.ts"
@@ -0,0 +1,23 @@
+import NextAuth from "next-auth"
+import KeycloakProvider from "next-auth/providers/keycloak";
+
+let getSecrets = () => {
+    let clientId = process.env.CLIENT_ID;
+    let clientSecret = process.env.CLIENT_SECRET;
+
+    if (!clientId || !clientSecret) throw new Error("Missing Client Environment Vars");
+    return {clientId, clientSecret}
+}
+
+export const authOptions = {
+    providers: [
+        KeycloakProvider(Object.assign(getSecrets(), {
+            issuer: "https://`login.clicks.codes/realms/master"
+        })),
+    ],
+}
+
+
+const handler = NextAuth(authOptions)
+
+export { handler as GET, handler as POST }
\ No newline at end of file
diff --git a/bun.lockb b/bun.lockb
index 1a0af69..5e832ab 100755
--- a/bun.lockb
+++ b/bun.lockb
Binary files differ
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..1f709e6
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,61 @@
+{
+  "nodes": {
+    "flake-utils": {
+      "inputs": {
+        "systems": "systems"
+      },
+      "locked": {
+        "lastModified": 1705309234,
+        "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1706925685,
+        "narHash": "sha256-hVInjWMmgH4yZgA4ZtbgJM1qEAel72SYhP5nOWX4UIM=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "79a13f1437e149dc7be2d1290c74d378dad60814",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixpkgs-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "nixpkgs": "nixpkgs"
+      }
+    },
+    "systems": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..22a861b
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,21 @@
+{
+  description = "A basic flake with a shell";
+  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+  inputs.flake-utils.url = "github:numtide/flake-utils";
+
+  outputs = { nixpkgs, flake-utils, ... }:
+    flake-utils.lib.eachDefaultSystem (system:
+      let
+        pkgs = import nixpkgs {
+          inherit system;
+        };
+      in
+      {
+        devShells.default = pkgs.mkShell {
+          packages = [
+            pkgs.bun
+            pkgs.nodejs_21
+          ];
+        };
+      });
+}
diff --git a/package.json b/package.json
index 20da318..cfd1a4f 100644
--- a/package.json
+++ b/package.json
@@ -9,9 +9,10 @@
     "lint": "next lint"
   },
   "dependencies": {
+    "next": "14.1.0",
+    "next-auth": "^4.24.5",
     "react": "^18",
-    "react-dom": "^18",
-    "next": "14.1.0"
+    "react-dom": "^18"
   },
   "devDependencies": {
     "typescript": "^5",