api/core: return public turnstile sitekey in server info

This commit is contained in:
wukko 2024-09-17 22:40:07 +06:00
parent 5e7324bca9
commit 0cc18b488c
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
2 changed files with 8 additions and 2 deletions

View file

@ -34,10 +34,15 @@ const env = {
externalProxy: process.env.API_EXTERNAL_PROXY,
turnstileSitekey: process.env.TURNSTILE_SITEKEY,
turnstileSecret: process.env.TURNSTILE_SECRET,
jwtSecret: process.env.JWT_SECRET,
jwtLifetime: process.env.JWT_EXPIRY || 120,
sessionEnabled: process.env.TURNSTILE_SITEKEY
&& process.env.TURNSTILE_SECRET
&& process.env.JWT_SECRET,
enabledServices,
}

View file

@ -49,6 +49,7 @@ export const runAPI = (express, app, __dirname) => {
url: env.apiURL,
startTime: `${startTimestamp}`,
durationLimit: env.durationLimit,
turnstileSitekey: env.sessionEnabled ? env.turnstileSitekey : undefined,
services: [...env.enabledServices].map(e => {
return friendlyServiceName(e);
}),
@ -106,7 +107,7 @@ export const runAPI = (express, app, __dirname) => {
app.use('/tunnel', apiLimiterStream);
app.post('/', (req, res, next) => {
if (!env.turnstileSecret || !env.jwtSecret) {
if (!env.sessionEnabled) {
return next();
}
@ -156,7 +157,7 @@ export const runAPI = (express, app, __dirname) => {
});
app.post("/session", async (req, res) => {
if (!env.turnstileSecret || !env.jwtSecret) {
if (!env.sessionEnabled) {
return fail(res, "error.api.auth.not_configured")
}