mirror of
https://github.com/aljazceru/gitpear.git
synced 2025-12-17 06:04:25 +01:00
enable pus honly authenticated mod
Signed-off-by: dzdidi <deniszalessky@gmail.com>
This commit is contained in:
12
src/rpc.js
12
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-repos', async req => await this.getReposHandler(peerInfo.publicKey, req))
|
||||||
rpc.respond('get-refs', async req => await this.getRefsHandler(peerInfo.publicKey, req))
|
rpc.respond('get-refs', async req => await this.getRefsHandler(peerInfo.publicKey, req))
|
||||||
|
|
||||||
/* -- PUSH HANDLERS -- */
|
if (process.env.GIT_PEAR_AUTH) {
|
||||||
rpc.respond('push', async req => await this.pushHandler(peerInfo.publicKey, req))
|
/* -- PUSH HANDLERS -- */
|
||||||
rpc.respond('f-push', async req => await this.forcePushHandler(peerInfo.publicKey, req))
|
rpc.respond('push', async req => await this.pushHandler(peerInfo.publicKey, req))
|
||||||
rpc.respond('d-branch', async req => await this.deleteBranchHandler(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
|
this.connections[peerInfo.publicKey] = rpc
|
||||||
}
|
}
|
||||||
@@ -63,6 +65,8 @@ module.exports = class RPC {
|
|||||||
const { url, repoName, branch, userId } = await this.parseReq(publicKey, req)
|
const { url, repoName, branch, userId } = await this.parseReq(publicKey, req)
|
||||||
const isContributor = acl.getContributors(repoName).includes(userId)
|
const isContributor = acl.getContributors(repoName).includes(userId)
|
||||||
|
|
||||||
|
console.error('pushHandler', { url, repoName, branch, userId, isContributor })
|
||||||
|
|
||||||
if (!isContributor) {
|
if (!isContributor) {
|
||||||
throw new Error('You are not allowed to push to this repo')
|
throw new Error('You are not allowed to push to this repo')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user