api/core: return public turnstile sitekey in server info
This commit is contained in:
parent
5e7324bca9
commit
0cc18b488c
2 changed files with 8 additions and 2 deletions
|
@ -34,10 +34,15 @@ const env = {
|
||||||
|
|
||||||
externalProxy: process.env.API_EXTERNAL_PROXY,
|
externalProxy: process.env.API_EXTERNAL_PROXY,
|
||||||
|
|
||||||
|
turnstileSitekey: process.env.TURNSTILE_SITEKEY,
|
||||||
turnstileSecret: process.env.TURNSTILE_SECRET,
|
turnstileSecret: process.env.TURNSTILE_SECRET,
|
||||||
jwtSecret: process.env.JWT_SECRET,
|
jwtSecret: process.env.JWT_SECRET,
|
||||||
jwtLifetime: process.env.JWT_EXPIRY || 120,
|
jwtLifetime: process.env.JWT_EXPIRY || 120,
|
||||||
|
|
||||||
|
sessionEnabled: process.env.TURNSTILE_SITEKEY
|
||||||
|
&& process.env.TURNSTILE_SECRET
|
||||||
|
&& process.env.JWT_SECRET,
|
||||||
|
|
||||||
enabledServices,
|
enabledServices,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ export const runAPI = (express, app, __dirname) => {
|
||||||
url: env.apiURL,
|
url: env.apiURL,
|
||||||
startTime: `${startTimestamp}`,
|
startTime: `${startTimestamp}`,
|
||||||
durationLimit: env.durationLimit,
|
durationLimit: env.durationLimit,
|
||||||
|
turnstileSitekey: env.sessionEnabled ? env.turnstileSitekey : undefined,
|
||||||
services: [...env.enabledServices].map(e => {
|
services: [...env.enabledServices].map(e => {
|
||||||
return friendlyServiceName(e);
|
return friendlyServiceName(e);
|
||||||
}),
|
}),
|
||||||
|
@ -106,7 +107,7 @@ export const runAPI = (express, app, __dirname) => {
|
||||||
app.use('/tunnel', apiLimiterStream);
|
app.use('/tunnel', apiLimiterStream);
|
||||||
|
|
||||||
app.post('/', (req, res, next) => {
|
app.post('/', (req, res, next) => {
|
||||||
if (!env.turnstileSecret || !env.jwtSecret) {
|
if (!env.sessionEnabled) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +157,7 @@ export const runAPI = (express, app, __dirname) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/session", async (req, res) => {
|
app.post("/session", async (req, res) => {
|
||||||
if (!env.turnstileSecret || !env.jwtSecret) {
|
if (!env.sessionEnabled) {
|
||||||
return fail(res, "error.api.auth.not_configured")
|
return fail(res, "error.api.auth.not_configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue