This commit is contained in:
soraefir
2026-05-31 12:33:56 +02:00
parent 6d356b56c5
commit 865cbbec7e

View File

@@ -140,11 +140,11 @@ in {
PSQL="${pkgs.postgresql}/bin/psql -U postgres" PSQL="${pkgs.postgresql}/bin/psql -U postgres"
TOKEN_STRING="$HOMEPAGE_VAR_GITEA_API" TOKEN_STRING="$HOMEPAGE_VAR_GITEA_API"
SALT=$(${nixpkgs.coreutils}/bin/cat /dev/urandom | ${nixpkgs.gnugrep}/bin/tr -dc 'a-zA-Z0-9' | ${nixpkgs.coreutils}/bin/head -c 10) SALT=$(${pkgs.coreutils}/bin/cat /dev/urandom | ${pkgs.gnugrep}/bin/tr -dc 'a-zA-Z0-9' | ${pkgs.coreutils}/bin/head -c 10)
COMBINED_STRING="${SALT}${TOKEN_STRING}" COMBINED_STRING="${SALT}${TOKEN_STRING}"
HASH=$(echo -n "$COMBINED_STRING" | ${nixpkgs.openssl}/bin/openssl dgst -sha256 | ${nixpkgs.coreutils}/bin/cut -d' ' -f2) HASH=$(echo -n "$COMBINED_STRING" | ${pkgs.openssl}/bin/openssl dgst -sha256 | ${pkgs.coreutils}/bin/cut -d' ' -f2)
LAST_8="${TOKEN_STRING: -8}" LAST_8="${TOKEN_STRING: -8}"
NOW=$(${nixpkgs.coreutils}/bin/date +%s) NOW=$(${pkgs.coreutils}/bin/date +%s)
$PSQL -d "gitea_db" -e \ $PSQL -d "gitea_db" -e \
"INSERT INTO access_token (uid, name, token_hash, token_salt, token_last_eight, created_unix, updated_unix) \ "INSERT INTO access_token (uid, name, token_hash, token_salt, token_last_eight, created_unix, updated_unix) \
VALUES (1, 'homepage-dashboard', '$HASH', '$SALT', '$LAST_8', $NOW, $NOW);" VALUES (1, 'homepage-dashboard', '$HASH', '$SALT', '$LAST_8', $NOW, $NOW);"