From 54b43fd95199da2a9314a4e07072cf2ad5954f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20L=C3=BCscher?= Date: Mon, 6 Jul 2020 13:01:45 +0200 Subject: [PATCH] Add GitHub authentication for API requests, to prevent limits. --- .env.example | 4 ++++ public/webhooks/github.php | 1 + 2 files changed, 5 insertions(+) diff --git a/.env.example b/.env.example index c1359ee..af302d4 100644 --- a/.env.example +++ b/.env.example @@ -34,6 +34,10 @@ TG_PATHS='{"download": "${TG_DOWNLOADS_DIR}", "upload": "${TG_UPLOADS_DIR}"}' # Webhook secrets TG_WEBHOOK_SECRET_GITHUB='github-secret' +# GitHub API token +TG_GITHUB_AUTH_USER='github-user' +TG_GITHUB_AUTH_TOKEN='github-token' + # Telegram Payments TG_PAYMENT_PROVIDER_TOKEN='123:TEST:abc' diff --git a/public/webhooks/github.php b/public/webhooks/github.php index a45b2ec..ae1691d 100644 --- a/public/webhooks/github.php +++ b/public/webhooks/github.php @@ -113,6 +113,7 @@ function parseReleaseBody($body, $user, $repo): string }, $body); $github_client = new Client(); + $github_client->authenticate(getenv('TG_GITHUB_AUTH_USER'), getenv('TG_GITHUB_AUTH_TOKEN')); $github_client->addCache(new Pool(new MySQL( new PDO('mysql:dbname=' . getenv('TG_DB_DATABASE') . ';host=' . getenv('TG_DB_HOST'), getenv('TG_DB_USER'), getenv('TG_DB_PASSWORD')) )));