feat: enhance auth secret generation with CryptoJS MD5 hashing

This commit is contained in:
hamster1963 2025-02-07 14:32:57 +08:00
parent e90914b320
commit 4bbda14bf0
3 changed files with 4 additions and 1 deletions

View File

@ -1,9 +1,10 @@
import getEnv from "@/lib/env-entry" import getEnv from "@/lib/env-entry"
import NextAuth from "next-auth" import NextAuth from "next-auth"
import CredentialsProvider from "next-auth/providers/credentials" import CredentialsProvider from "next-auth/providers/credentials"
import CryptoJS from 'crypto-js'
export const { handlers, signIn, signOut, auth } = NextAuth({ export const { handlers, signIn, signOut, auth } = NextAuth({
secret: process.env.AUTH_SECRET ?? "this_is_nezha_dash_web_secret", secret: process.env.AUTH_SECRET ?? CryptoJS.MD5(`this_is_nezha_dash_web_secret_${getEnv("SitePassword")}`).toString(),
trustHost: (process.env.AUTH_TRUST_HOST as boolean | undefined) ?? true, trustHost: (process.env.AUTH_TRUST_HOST as boolean | undefined) ?? true,
providers: [ providers: [
CredentialsProvider({ CredentialsProvider({

BIN
bun.lockb

Binary file not shown.

View File

@ -27,6 +27,7 @@
"@radix-ui/react-switch": "^1.1.2", "@radix-ui/react-switch": "^1.1.2",
"@radix-ui/react-tooltip": "^1.1.7", "@radix-ui/react-tooltip": "^1.1.7",
"@trivago/prettier-plugin-sort-imports": "^5.2.2", "@trivago/prettier-plugin-sort-imports": "^5.2.2",
"@types/crypto-js": "^4.2.2",
"@types/d3-geo": "^3.1.0", "@types/d3-geo": "^3.1.0",
"@types/luxon": "^3.4.2", "@types/luxon": "^3.4.2",
"babel-plugin-react-compiler": "^19.0.0-beta-e552027-20250112", "babel-plugin-react-compiler": "^19.0.0-beta-e552027-20250112",
@ -35,6 +36,7 @@
"clsx": "^2.1.1", "clsx": "^2.1.1",
"cmdk": "^1.0.4", "cmdk": "^1.0.4",
"country-flag-icons": "^1.5.14", "country-flag-icons": "^1.5.14",
"crypto-js": "^4.2.0",
"d3-geo": "^3.1.1", "d3-geo": "^3.1.1",
"d3-selection": "^3.0.0", "d3-selection": "^3.0.0",
"flag-icons": "^7.3.2", "flag-icons": "^7.3.2",