mirror of
https://github.com/C4illin/ConvertX.git
synced 2025-10-23 04:52:18 +00:00
Use a new env variable to determine whether the user ID should be set to 0 for unauthenticated users
This commit is contained in:
24
README.md
24
README.md
@@ -80,17 +80,19 @@ If you get unable to open database file run `chown -R $USER:$USER path` on the p
|
|||||||
|
|
||||||
All are optional, JWT_SECRET is recommended to be set.
|
All are optional, JWT_SECRET is recommended to be set.
|
||||||
|
|
||||||
| Name | Default | Description |
|
| Name | Default | Description |
|
||||||
| ------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
| ---------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| JWT_SECRET | when unset it will use the value from randomUUID() | A long and secret string used to sign the JSON Web Token |
|
| JWT_SECRET | when unset it will use the value from randomUUID() | A long and secret string used to sign the JSON Web Token |
|
||||||
| ACCOUNT_REGISTRATION | false | Allow users to register accounts |
|
| ACCOUNT_REGISTRATION | false | Allow users to register accounts |
|
||||||
| HTTP_ALLOWED | false | Allow HTTP connections, only set this to true locally |
|
| HTTP_ALLOWED | false | Allow HTTP connections, only set this to true locally |
|
||||||
| ALLOW_UNAUTHENTICATED | false | Allow unauthenticated users to use the service, only set this to true locally |
|
| ALLOW_UNAUTHENTICATED | false | Allow unauthenticated users to use the service, only set this to true locally |
|
||||||
| AUTO_DELETE_EVERY_N_HOURS | 24 | Checks every n hours for files older then n hours and deletes them, set to 0 to disable |
|
| AUTO_DELETE_EVERY_N_HOURS | 24 | Checks every n hours for files older then n hours and deletes them, set to 0 to disable |
|
||||||
| WEBROOT | | The address to the root path setting this to "/convert" will serve the website on "example.com/convert/" |
|
| WEBROOT | | The address to the root path setting this to "/convert" will serve the website on "example.com/convert/" |
|
||||||
| FFMPEG_ARGS | | Arguments to pass to ffmpeg, e.g. `-preset veryfast` |
|
| FFMPEG_ARGS | | Arguments to pass to ffmpeg, e.g. `-preset veryfast` |
|
||||||
| HIDE_HISTORY | false | Hide the history page |
|
| HIDE_HISTORY | false | Hide the history page |
|
||||||
| LANGUAGE | en | Language to format date strings in, specified as a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) |
|
| LANGUAGE | en | Language to format date strings in, specified as a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) |
|
||||||
|
| UNAUTHENTICATED_USER_SHARING | false | Shares conversion history between all unauthenticated users |
|
||||||
|
|
||||||
|
|
||||||
### Docker images
|
### Docker images
|
||||||
|
|
||||||
|
@@ -15,5 +15,6 @@ services:
|
|||||||
# - WEBROOT=/convertx # the root path of the web interface, leave empty to disable
|
# - WEBROOT=/convertx # the root path of the web interface, leave empty to disable
|
||||||
# - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false
|
# - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false
|
||||||
- TZ=Europe/Stockholm # set your timezone, defaults to UTC
|
- TZ=Europe/Stockholm # set your timezone, defaults to UTC
|
||||||
|
# - UNAUTHENTICATED_USER_SHARING=true # for use with ALLOW_UNAUTHENTICATED=true to share history with all unauthenticated users / devices
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
|
@@ -16,4 +16,7 @@ export const WEBROOT = process.env.WEBROOT ?? "";
|
|||||||
|
|
||||||
export const LANGUAGE = process.env.LANGUAGE?.toLowerCase() || "en";
|
export const LANGUAGE = process.env.LANGUAGE?.toLowerCase() || "en";
|
||||||
|
|
||||||
export const MAX_CONVERT_PROCESS = process.env.MAX_CONVERT_PROCESS && Number(process.env.MAX_CONVERT_PROCESS) > 0 ? Number(process.env.MAX_CONVERT_PROCESS) : 0
|
export const MAX_CONVERT_PROCESS = process.env.MAX_CONVERT_PROCESS && Number(process.env.MAX_CONVERT_PROCESS) > 0 ? Number(process.env.MAX_CONVERT_PROCESS) : 0
|
||||||
|
|
||||||
|
export const UNAUTHENTICATED_USER_SHARING =
|
||||||
|
process.env.UNAUTHENTICATED_USER_SHARING?.toLowerCase() === "true" || false;
|
@@ -12,6 +12,7 @@ import {
|
|||||||
ALLOW_UNAUTHENTICATED,
|
ALLOW_UNAUTHENTICATED,
|
||||||
HIDE_HISTORY,
|
HIDE_HISTORY,
|
||||||
HTTP_ALLOWED,
|
HTTP_ALLOWED,
|
||||||
|
UNAUTHENTICATED_USER_SHARING,
|
||||||
WEBROOT,
|
WEBROOT,
|
||||||
} from "../helpers/env";
|
} from "../helpers/env";
|
||||||
import { FIRST_RUN, userService } from "./user";
|
import { FIRST_RUN, userService } from "./user";
|
||||||
@@ -33,7 +34,7 @@ export const root = new Elysia()
|
|||||||
let user: ({ id: string } & JWTPayloadSpec) | false = false;
|
let user: ({ id: string } & JWTPayloadSpec) | false = false;
|
||||||
if (ALLOW_UNAUTHENTICATED) {
|
if (ALLOW_UNAUTHENTICATED) {
|
||||||
const newUserId = String(
|
const newUserId = String(
|
||||||
ACCOUNT_REGISTRATION ? randomInt(2 ** 24, Math.min(2 ** 48 + 2 ** 24 - 1, Number.MAX_SAFE_INTEGER)) : 0,
|
UNAUTHENTICATED_USER_SHARING ? 0 : randomInt(2 ** 24, Math.min(2 ** 48 + 2 ** 24 - 1, Number.MAX_SAFE_INTEGER)),
|
||||||
);
|
);
|
||||||
const accessToken = await jwt.sign({
|
const accessToken = await jwt.sign({
|
||||||
id: newUserId,
|
id: newUserId,
|
||||||
|
Reference in New Issue
Block a user