screwdriver-api 4.1.273 → 4.1.274
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screwdriver-api",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.274",
|
|
4
4
|
"description": "API server for the Screwdriver.cd service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"screwdriver-executor-queue": "^3.1.2",
|
|
115
115
|
"screwdriver-executor-router": "^2.3.0",
|
|
116
116
|
"screwdriver-logger": "^1.1.0",
|
|
117
|
-
"screwdriver-models": "^28.18.
|
|
117
|
+
"screwdriver-models": "^28.18.1",
|
|
118
118
|
"screwdriver-notifications-email": "^2.2.0",
|
|
119
119
|
"screwdriver-notifications-slack": "^3.2.1",
|
|
120
120
|
"screwdriver-request": "^1.0.3",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"screwdriver-scm-router": "^6.3.0",
|
|
126
126
|
"screwdriver-template-validator": "^5.2.0",
|
|
127
127
|
"screwdriver-workflow-parser": "^3.2.1",
|
|
128
|
-
"sqlite3": "^5.0.
|
|
128
|
+
"sqlite3": "^5.0.11",
|
|
129
129
|
"stream": "0.0.2",
|
|
130
130
|
"tinytim": "^0.1.1",
|
|
131
131
|
"uuid": "^8.3.2",
|
|
@@ -22,7 +22,7 @@ module.exports = () => ({
|
|
|
22
22
|
handler: async (request, h) => {
|
|
23
23
|
const { id } = request.params;
|
|
24
24
|
const { pipelineFactory, userFactory } = request.server.app;
|
|
25
|
-
const { username, scmContext } = request.auth.credentials;
|
|
25
|
+
const { username, scmContext, scope } = request.auth.credentials;
|
|
26
26
|
const { isValidToken } = request.server.plugins.pipelines;
|
|
27
27
|
|
|
28
28
|
if (!isValidToken(id, request.auth.credentials)) {
|
|
@@ -44,30 +44,38 @@ module.exports = () => ({
|
|
|
44
44
|
|
|
45
45
|
// Use parent's scmUri if pipeline is child pipeline and using read-only SCM
|
|
46
46
|
const scmUri = await getScmUri({ pipeline, pipelineFactory });
|
|
47
|
+
let hasPushPermissions = false;
|
|
48
|
+
let permissions;
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
try {
|
|
51
|
+
// Get user permissions
|
|
52
|
+
permissions = await user.getPermissions(scmUri);
|
|
53
|
+
} catch (error) {
|
|
50
54
|
throw boom.boomify(error, { statusCode: error.statusCode });
|
|
51
|
-
}
|
|
55
|
+
}
|
|
52
56
|
|
|
53
57
|
// check if user has push access
|
|
54
58
|
if (!permissions.push) {
|
|
55
|
-
//
|
|
59
|
+
// user is not permitted, delete from admins table
|
|
56
60
|
const newAdmins = pipeline.admins;
|
|
57
61
|
|
|
58
62
|
delete newAdmins[username];
|
|
59
63
|
// This is needed to make admins dirty and update db
|
|
60
64
|
pipeline.admins = newAdmins;
|
|
61
65
|
|
|
62
|
-
|
|
66
|
+
await pipeline.update();
|
|
67
|
+
|
|
68
|
+
if (!scope.includes('admin')) {
|
|
63
69
|
throw boom.forbidden(
|
|
64
70
|
`User ${user.getFullDisplayName()} does not have push permission for this repo`
|
|
65
71
|
);
|
|
66
|
-
}
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
hasPushPermissions = true;
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
// user has good permissions, add the user as an admin
|
|
70
|
-
if (!pipeline.admins[username]) {
|
|
78
|
+
if (!pipeline.admins[username] && hasPushPermissions) {
|
|
71
79
|
const newAdmins = pipeline.admins;
|
|
72
80
|
|
|
73
81
|
newAdmins[username] = true;
|
|
@@ -78,7 +86,6 @@ module.exports = () => ({
|
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
try {
|
|
81
|
-
// user has good permissions, sync the pipeline
|
|
82
89
|
await pipeline.sync();
|
|
83
90
|
|
|
84
91
|
return h.response().code(204);
|
|
@@ -21,7 +21,7 @@ module.exports = () => ({
|
|
|
21
21
|
handler: async (request, h) => {
|
|
22
22
|
const { id } = request.params;
|
|
23
23
|
const { pipelineFactory, userFactory } = request.server.app;
|
|
24
|
-
const { username, scmContext } = request.auth.credentials;
|
|
24
|
+
const { username, scmContext, scope } = request.auth.credentials;
|
|
25
25
|
|
|
26
26
|
// Fetch the pipeline and user models
|
|
27
27
|
const [pipeline, user] = await Promise.all([
|
|
@@ -36,11 +36,13 @@ module.exports = () => ({
|
|
|
36
36
|
throw boom.notFound(`User ${username} does not exist`);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if (!scope.includes('admin')) {
|
|
40
|
+
// Use parent's scmUri if pipeline is child pipeline and using read-only SCM
|
|
41
|
+
const scmUri = await getScmUri({ pipeline, pipelineFactory });
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
// Check the user's permission
|
|
44
|
+
await getUserPermissions({ user, scmUri, level: 'push' });
|
|
45
|
+
}
|
|
44
46
|
|
|
45
47
|
await pipeline.syncPRs();
|
|
46
48
|
|
|
@@ -21,7 +21,7 @@ module.exports = () => ({
|
|
|
21
21
|
handler: async (request, h) => {
|
|
22
22
|
const { id } = request.params;
|
|
23
23
|
const { pipelineFactory, userFactory } = request.server.app;
|
|
24
|
-
const { username, scmContext } = request.auth.credentials;
|
|
24
|
+
const { username, scmContext, scope } = request.auth.credentials;
|
|
25
25
|
|
|
26
26
|
// Fetch the pipeline and user models
|
|
27
27
|
const [pipeline, user] = await Promise.all([
|
|
@@ -36,11 +36,13 @@ module.exports = () => ({
|
|
|
36
36
|
throw boom.notFound(`User ${username} does not exist`);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if (!scope.includes('admin')) {
|
|
40
|
+
// Use parent's scmUri if pipeline is child pipeline and using read-only SCM
|
|
41
|
+
const scmUri = await getScmUri({ pipeline, pipelineFactory });
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
// Check the user's permission
|
|
44
|
+
await getUserPermissions({ user, scmUri, level: 'push' });
|
|
45
|
+
}
|
|
44
46
|
|
|
45
47
|
// user has good permissions, add or update webhooks
|
|
46
48
|
await pipeline.addWebhooks(`${request.server.info.uri}/v4/webhooks`);
|