mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Save a list of safe to export secret keys
This commit is contained in:
@@ -32,6 +32,14 @@ const SECRET_KEYS = {
|
||||
OOBA: 'api_key_ooba',
|
||||
};
|
||||
|
||||
// These are the keys that are safe to expose, even if allowKeysExposure is false
|
||||
const EXPORTABLE_KEYS = [
|
||||
SECRET_KEYS.LIBRE_URL,
|
||||
SECRET_KEYS.LINGVA_URL,
|
||||
SECRET_KEYS.ONERING_URL,
|
||||
SECRET_KEYS.DEEPLX_URL,
|
||||
];
|
||||
|
||||
/**
|
||||
* Writes a secret to the secrets file
|
||||
* @param {string} key Secret key
|
||||
@@ -212,15 +220,13 @@ router.post('/view', jsonParser, async (_, response) => {
|
||||
|
||||
router.post('/find', jsonParser, (request, response) => {
|
||||
const allowKeysExposure = getConfigValue('allowKeysExposure', false);
|
||||
|
||||
const key = request.body.key;
|
||||
|
||||
if (!allowKeysExposure && key.slice(key.length-4) !== '_url' ) {
|
||||
|
||||
if (!allowKeysExposure && !EXPORTABLE_KEYS.includes(key)) {
|
||||
console.error('Cannot fetch secrets unless allowKeysExposure in config.yaml is set to true');
|
||||
return response.sendStatus(403);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
const secret = readSecret(key);
|
||||
|
||||
|
Reference in New Issue
Block a user