feat: multiple tokens

master
Paul Makles 2023-12-12 21:05:02 +01:00
parent a79de56d32
commit c970f20bc5
2 changed files with 7 additions and 2 deletions

View File

@ -46,8 +46,13 @@ app.get("/jwt", async (req, res) => {
} }
}); });
if (typeof process.env.SERVER_TOKEN !== "string")
throw "Must specify server tokens";
const tokens = process.env.SERVER_TOKEN.split(",");
app.post("/info", async (req, res) => { app.post("/info", async (req, res) => {
if (req.headers["x-server"] !== process.env.SERVER_TOKEN) { if (!tokens.includes(req.headers["x-server"])) {
return res.status(403).send("Not server."); return res.status(403).send("Not server.");
} }

2
package-lock.json generated
View File

@ -1,5 +1,5 @@
{ {
"name": "mini-auth-server", "name": "social-login-api",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {