From 8a4285bca42f40b925a88a3d6f7120198c656540 Mon Sep 17 00:00:00 2001 From: dzdidi Date: Mon, 29 Jan 2024 09:37:18 +0000 Subject: [PATCH] enable pus honly authenticated mod Signed-off-by: dzdidi --- src/rpc.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/rpc.js b/src/rpc.js index bdedf13..c2a3677 100755 --- a/src/rpc.js +++ b/src/rpc.js @@ -24,10 +24,12 @@ module.exports = class RPC { rpc.respond('get-repos', async req => await this.getReposHandler(peerInfo.publicKey, req)) rpc.respond('get-refs', async req => await this.getRefsHandler(peerInfo.publicKey, req)) - /* -- PUSH HANDLERS -- */ - rpc.respond('push', async req => await this.pushHandler(peerInfo.publicKey, req)) - rpc.respond('f-push', async req => await this.forcePushHandler(peerInfo.publicKey, req)) - rpc.respond('d-branch', async req => await this.deleteBranchHandler(peerInfo.publicKey, req)) + if (process.env.GIT_PEAR_AUTH) { + /* -- PUSH HANDLERS -- */ + rpc.respond('push', async req => await this.pushHandler(peerInfo.publicKey, req)) + rpc.respond('f-push', async req => await this.forcePushHandler(peerInfo.publicKey, req)) + rpc.respond('d-branch', async req => await this.deleteBranchHandler(peerInfo.publicKey, req)) + } this.connections[peerInfo.publicKey] = rpc } @@ -63,6 +65,8 @@ module.exports = class RPC { const { url, repoName, branch, userId } = await this.parseReq(publicKey, req) const isContributor = acl.getContributors(repoName).includes(userId) + console.error('pushHandler', { url, repoName, branch, userId, isContributor }) + if (!isContributor) { throw new Error('You are not allowed to push to this repo') }