store fingerprint data on auth
Some checks failed
Build and push image for doorman / docker (push) Has been cancelled
Some checks failed
Build and push image for doorman / docker (push) Has been cancelled
This commit is contained in:
parent
f8b39c77c0
commit
688d78df92
@ -8,5 +8,8 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"express-fingerprint": "^1.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,10 +17,15 @@ router.get('/:id/status', async(req, res) => {
|
|||||||
res.status(401).json({ status: 'closed' });
|
res.status(401).json({ status: 'closed' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.delete('/:id/status', async(req, res) => {
|
||||||
|
await client.remove(doorStatusKey(req.params.id));
|
||||||
|
res.status(200).json({ msg: 'Cleared status' });
|
||||||
|
});
|
||||||
|
|
||||||
router.all('/:id/auth', ValidQueryParamAuth, async(req, res) => {
|
router.all('/:id/auth', ValidQueryParamAuth, async(req, res) => {
|
||||||
const statusKey = doorStatusKey(req.params.id);
|
const statusKey = doorStatusKey(req.params.id);
|
||||||
|
|
||||||
await client.put(statusKey, 'true');
|
await client.put(statusKey, JSON.stringify((req as any).fingerprint));
|
||||||
await client.getClient().expire(statusKey, Bun.env.DOOR_OPEN_TIMEOUT);
|
await client.getClient().expire(statusKey, Bun.env.DOOR_OPEN_TIMEOUT);
|
||||||
res.status(200).json({ msg: `Opened the door "${req.params.id}" for ${Bun.env.DOOR_OPEN_TIMEOUT}s` });
|
res.status(200).json({ msg: `Opened the door "${req.params.id}" for ${Bun.env.DOOR_OPEN_TIMEOUT}s` });
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,27 +1,24 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import fileUpload from "express-fileupload";
|
|
||||||
import { challengeLimiter, uploadDownloadLimiter } from "./util/RateLimits";
|
|
||||||
import LnurlRouter from "./routers/LnurlRouter";
|
|
||||||
import ActionRouter from "./routers/ActionRouter";
|
|
||||||
import DoorRouter from "./routers/DoorRouter";
|
import DoorRouter from "./routers/DoorRouter";
|
||||||
|
|
||||||
|
const Fingerprint = require('express-fingerprint');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.set('trust proxy', 1);
|
app.set('trust proxy', 1);
|
||||||
|
|
||||||
app.use('/api/actions/download', uploadDownloadLimiter);
|
|
||||||
app.use('/api/actions/upload', uploadDownloadLimiter);
|
Fingerprint.default
|
||||||
app.use('/api/lnurl/login', challengeLimiter);
|
|
||||||
|
app.use(Fingerprint({
|
||||||
|
parameters: [
|
||||||
|
Fingerprint.useragent,
|
||||||
|
Fingerprint.geoip
|
||||||
|
]
|
||||||
|
}));
|
||||||
|
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(fileUpload({
|
|
||||||
limits: { fileSize: 5 * 1024 * 1024 }
|
|
||||||
}));
|
|
||||||
app.use(express.static("dist"));
|
app.use(express.static("dist"));
|
||||||
|
|
||||||
// use routers
|
|
||||||
// app.use('/api/lnurl', LnurlRouter);
|
|
||||||
// app.use('/api/actions', ActionRouter);
|
|
||||||
app.use('/api/door', DoorRouter);
|
app.use('/api/door', DoorRouter);
|
||||||
|
|
||||||
app.listen(5000, async () => {
|
app.listen(5000, async () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user