Skip to content
This repository has been archived by the owner on Dec 25, 2024. It is now read-only.

Commit

Permalink
Refactor Redis and cache password handling in
Browse files Browse the repository at this point in the history
options.ts
  • Loading branch information
walnuts1018 committed Nov 7, 2023
1 parent e62ce0a commit d4cf5ad
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions front/src/app/api/auth/[...nextauth]/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,15 @@ import Redis from 'ioredis';
import crypto from 'crypto';
import AsyncLock from 'async-lock';

if (!process.env.REDIS_HOST || !process.env.REDIS_PASSWORD) {
throw new Error("Redis host or password not set");
}
const redis = new Redis({
host: process.env.REDIS_HOST,
port: 6379,
password: process.env.REDIS_PASSWORD,
db: 0,
});


const cachePassword = process.env.CACHE_PASSWORD;
if (!cachePassword) {
throw new Error("Cache password not set");
}
const cacheKey = crypto.scryptSync(cachePassword, "", 32);
const cachePassword = process.env.CACHE_PASSWORD || "password";
const cacheKey = crypto.scryptSync(cachePassword, "salt", 32);

const lock = new AsyncLock({ timeout: 10000 });

Expand Down

0 comments on commit d4cf5ad

Please sign in to comment.