mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
feat: support encrypted password in search API
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user