feat: support encrypted password in search API

This commit is contained in:
Viren070
2025-09-14 14:06:40 +01:00
parent 2591835eb8
commit 69963fa581
+20
View File
@@ -9,6 +9,8 @@ import {
constants,
formatZodError,
validateConfig,
isEncrypted,
decryptString,
} from '@aiostreams/core';
import { streamApiRateLimiter } from '../../middlewares/ratelimit';
import { createLogger } from '@aiostreams/core';
@@ -102,6 +104,24 @@ router.get(
`Missing username or password in basic auth`
);
}
if (isEncrypted(password)) {
const {
success: successfulDecryption,
data: decryptedPassword,
error,
} = decryptString(password);
if (!successfulDecryption) {
next(
new APIError(
constants.ErrorCode.ENCRYPTION_ERROR,
undefined,
error
)
);
return;
}
password = decryptedPassword;
}
logger.debug(`Using basic auth for Search API request: ${uuid}`);
} catch (error: any) {
throw new APIError(