mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-28 18:08:16 +00:00
Make IP/user-agent validation in CDN work
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
import { route } from "@spacebar/api";
|
||||
import { RefreshUrlsRequestSchema, resignUrl } from "@spacebar/util";
|
||||
import { RefreshUrlsRequestSchema, getUrlSignature, NewUrlSignatureData } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
@@ -37,7 +37,13 @@ router.post(
|
||||
async (req: Request, res: Response) => {
|
||||
const { attachment_urls } = req.body as RefreshUrlsRequestSchema;
|
||||
|
||||
const refreshed_urls = attachment_urls.map(url => resignUrl(url, req));
|
||||
const refreshed_urls = attachment_urls.map(url => {
|
||||
return getUrlSignature(new NewUrlSignatureData({
|
||||
url: url,
|
||||
ip: req.ip,
|
||||
userAgent: req.headers["user-agent"] as string
|
||||
})).applyToUrl(url).toString();
|
||||
});
|
||||
|
||||
return res.status(200).json({
|
||||
refreshed_urls,
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
emitEvent,
|
||||
getPermission,
|
||||
getRights,
|
||||
uploadFile, Config, getUrlSignature,
|
||||
uploadFile
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
|
||||
@@ -35,8 +35,8 @@ import {
|
||||
emitEvent,
|
||||
getPermission,
|
||||
isTextChannel,
|
||||
resignUrl,
|
||||
uploadFile,
|
||||
getUrlSignature,
|
||||
uploadFile, NewUrlSignatureData,
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
@@ -210,8 +210,17 @@ router.get(
|
||||
|
||||
y.proxy_url = url.toString();
|
||||
|
||||
y.proxy_url = resignUrl(y.proxy_url, req);
|
||||
y.url = resignUrl(y.url, req);
|
||||
y.proxy_url = getUrlSignature(new NewUrlSignatureData({
|
||||
url: y.proxy_url,
|
||||
userAgent: req.headers["user-agent"],
|
||||
ip: req.ip,
|
||||
})).applyToUrl(y.proxy_url).toString();
|
||||
|
||||
y.url = getUrlSignature(new NewUrlSignatureData({
|
||||
url: y.url,
|
||||
userAgent: req.headers["user-agent"],
|
||||
ip: req.ip,
|
||||
})).applyToUrl(y.url).toString();
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user