diff --git a/packages/server/src/routes/api/search.ts b/packages/server/src/routes/api/search.ts index 8fc437b5..4d8cd2d1 100644 --- a/packages/server/src/routes/api/search.ts +++ b/packages/server/src/routes/api/search.ts @@ -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(