Signed-off-by: dzdidi <deniszalessky@gmail.com>
This commit is contained in:
dzdidi
2024-01-28 14:02:55 +00:00
parent e8cbdc5e64
commit f466308755
6 changed files with 29 additions and 52 deletions

View File

@@ -1,7 +1,7 @@
const ProtomuxRPC = require('protomux-rpc')
const { spawn } = require('child_process')
const home = require('./home')
const acl = require('./acl')
const auth = require('./auth')
module.exports = class RPC {
constructor (announcedRefs, repositories, drives) {
@@ -98,7 +98,7 @@ module.exports = class RPC {
})
}
async parseReq(publicKey, req, access, branch = '*') {
async parseReq(publicKey, req) {
if (!req) throw new Error('Request is empty')
let request = JSON.parse(req.toString())
const parsed = {
@@ -116,22 +116,12 @@ module.exports = class RPC {
if (process.env.GIT_PEAR_AUTH === 'naitive') {
userId = publicKey
} else {
userId = (await acl.getId({ ...request.body, payload: request.header })).userId
userId = (await auth.getId({ ...request.body, payload: request.header })).userId
}
const aclObj = home.getACL(parsed.repoName)
const userACL = aclObj[userId] || aclObj['*']
if (!userACL) throw new Error('You are not allowed to access this repo')
if (aclObj.protectecBranches.includes(branch)) {
// protected branch must have exaplicit access grant
if (access === 'w') {
} else {
//
}
} else {
}
return parsed
}