first commit

This commit is contained in:
ChK
2026-02-02 18:38:32 +01:00
commit 6cef59775a
637 changed files with 68562 additions and 0 deletions

42
auth/auth.js Executable file
View File

@@ -0,0 +1,42 @@
const express = require("express");
const cookieParser = require("cookie-parser");
const app = express();
app.use(express.json());
app.use(cookieParser());
const PORT = 3000;
// Test-User
const USER = {
username: "admin",
password: "test123"
};
// Login
app.post("/api/login", (req, res) => {
const { username, password } = req.body;
if (username === USER.username && password === USER.password) {
res.cookie("session", "valid", {
httpOnly: true,
sameSite: "Lax",
path: "/"
});
return res.json({ success: true });
}
res.status(401).json({ success: false });
});
// Auth-Check für späteres Nginx auth_request
app.get("/internal/auth", (req, res) => {
if (req.cookies.session === "valid") {
return res.sendStatus(200);
}
res.sendStatus(401);
});
app.listen(PORT, () => {
console.log(`Auth service listening on ${PORT}`);
});