gitea token

This commit is contained in:
soraefir
2026-05-31 12:32:37 +02:00
parent 50c96de851
commit 6d356b56c5
3 changed files with 14 additions and 4 deletions

View File

@@ -138,6 +138,17 @@ in {
--synchronize-users
''}
PSQL="${pkgs.postgresql}/bin/psql -U postgres"
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)
COMBINED_STRING="${SALT}${TOKEN_STRING}"
HASH=$(echo -n "$COMBINED_STRING" | ${nixpkgs.openssl}/bin/openssl dgst -sha256 | ${nixpkgs.coreutils}/bin/cut -d' ' -f2)
LAST_8="${TOKEN_STRING: -8}"
NOW=$(${nixpkgs.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"
'';

View File

@@ -173,7 +173,6 @@ in {
INSERT OR IGNORE INTO ApiKeys (Id, AccessToken, Name, DateCreated, DateLastActivity)
VALUES ( 1, "$HOMEPAGE_VAR_JELLYFIN_API", 'Home', strftime('%Y-%m-%d %H:%M:%S', 'now'), strftime('%Y-%m-%d %H:%M:%S', 'now'));
EOF
echo "Completed Setup"
'';