This commit is contained in:
soraefir
2026-05-31 13:05:20 +02:00
parent deafe70bea
commit 0570a0d278
4 changed files with 50 additions and 21 deletions

View File

@@ -138,18 +138,6 @@ in {
--synchronize-users
''}
PSQL="${pkgs.postgresql}/bin/psql -U postgres"
TOKEN_STRING="$HOMEPAGE_VAR_GITEA_API"
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}"
HASH=$(echo -n "$COMBINED_STRING" | ${pkgs.openssl}/bin/openssl dgst -sha256 | ${pkgs.coreutils}/bin/cut -d' ' -f2)
LAST_8="''${TOKEN_STRING: -8}"
NOW=$(${pkgs.coreutils}/bin/date +%s)
$PSQL -d "gitea_db" -e \
"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);"
echo "Completed Gitea Setup"
'';
};