mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-08 14:47:59 +02:00
add config to enable download
This commit is contained in:
@@ -10,6 +10,10 @@ interface Config {
|
|||||||
MAX_FILE_SIZE: number;
|
MAX_FILE_SIZE: number;
|
||||||
MAX_REPO_SIZE: number;
|
MAX_REPO_SIZE: number;
|
||||||
AUTH_CALLBACK: string;
|
AUTH_CALLBACK: string;
|
||||||
|
/**
|
||||||
|
* Allow to download repository and files
|
||||||
|
*/
|
||||||
|
ENABLE_DOWNLOAD: boolean;
|
||||||
ANONYMIZATION_MASK: string;
|
ANONYMIZATION_MASK: string;
|
||||||
PORT: number;
|
PORT: number;
|
||||||
HOSTNAME: string;
|
HOSTNAME: string;
|
||||||
@@ -32,6 +36,7 @@ const config: Config = {
|
|||||||
DEFAULT_QUOTA: 2 * 1024 * 1024 * 1024 * 8,
|
DEFAULT_QUOTA: 2 * 1024 * 1024 * 1024 * 8,
|
||||||
MAX_FILE_SIZE: 10 * 1024 * 1024, // in b
|
MAX_FILE_SIZE: 10 * 1024 * 1024, // in b
|
||||||
MAX_REPO_SIZE: 8 * 1024, // in kb
|
MAX_REPO_SIZE: 8 * 1024, // in kb
|
||||||
|
ENABLE_DOWNLOAD: false,
|
||||||
AUTH_CALLBACK: "http://localhost:5000/github/auth",
|
AUTH_CALLBACK: "http://localhost:5000/github/auth",
|
||||||
ANONYMIZATION_MASK: "XXXX",
|
ANONYMIZATION_MASK: "XXXX",
|
||||||
PORT: 5000,
|
PORT: 5000,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
|
import config from "../../config";
|
||||||
|
|
||||||
import * as db from "../database/database";
|
import * as db from "../database/database";
|
||||||
import { getRepo, getUser, handleError } from "./route-utils";
|
import { getRepo, getUser, handleError } from "./route-utils";
|
||||||
@@ -19,6 +20,8 @@ router.get("/:repoId/", async (req: express.Request, res: express.Response) => {
|
|||||||
router.get(
|
router.get(
|
||||||
"/:repoId/zip",
|
"/:repoId/zip",
|
||||||
async (req: express.Request, res: express.Response) => {
|
async (req: express.Request, res: express.Response) => {
|
||||||
|
if (!config.ENABLE_DOWNLOAD)
|
||||||
|
return res.status(403).send({ error: "download_not_enabled" });
|
||||||
const repo = await getRepo(req, res);
|
const repo = await getRepo(req, res);
|
||||||
if (!repo) return;
|
if (!repo) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user