@backstage/plugin-events-backend-module-gitlab 0.2.11 → 0.2.12-next.1
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/CHANGELOG.md +19 -0
- package/README.md +2 -2
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +4 -39
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/http/createGitlabTokenValidator.cjs.js +17 -0
- package/dist/http/createGitlabTokenValidator.cjs.js.map +1 -0
- package/dist/index.cjs.js +3 -3
- package/dist/{cjs/GitlabEventRouter-C7Oujuqb.cjs.js → router/GitlabEventRouter.cjs.js} +1 -15
- package/dist/router/GitlabEventRouter.cjs.js.map +1 -0
- package/dist/service/eventsModuleGitlabEventRouter.cjs.js +24 -0
- package/dist/service/eventsModuleGitlabEventRouter.cjs.js.map +1 -0
- package/dist/service/eventsModuleGitlabWebhook.cjs.js +27 -0
- package/dist/service/eventsModuleGitlabWebhook.cjs.js.map +1 -0
- package/package.json +7 -7
- package/dist/cjs/GitlabEventRouter-C7Oujuqb.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @backstage/plugin-events-backend-module-gitlab
|
|
2
2
|
|
|
3
|
+
## 0.2.12-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-plugin-api@1.0.1-next.1
|
|
9
|
+
- @backstage/config@1.2.0
|
|
10
|
+
- @backstage/plugin-events-node@0.4.1-next.1
|
|
11
|
+
|
|
12
|
+
## 0.2.12-next.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 2f88f88: Updated backend installation instructions.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @backstage/plugin-events-node@0.4.1-next.0
|
|
19
|
+
- @backstage/backend-plugin-api@1.0.1-next.0
|
|
20
|
+
- @backstage/config@1.2.0
|
|
21
|
+
|
|
3
22
|
## 0.2.11
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ yarn --cwd packages/backend add @backstage/plugin-events-backend-module-gitlab
|
|
|
32
32
|
// packages/backend/src/index.ts
|
|
33
33
|
import { eventsModuleGitlabEventRouter } from '@backstage/plugin-events-backend-module-gitlab/alpha';
|
|
34
34
|
// ...
|
|
35
|
-
backend.add(eventsModuleGitlabEventRouter
|
|
35
|
+
backend.add(eventsModuleGitlabEventRouter);
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
#### Legacy Backend System
|
|
@@ -49,7 +49,7 @@ await eventRouter.subscribe();
|
|
|
49
49
|
// packages/backend/src/index.ts
|
|
50
50
|
import { eventsModuleGitlabWebhook } from '@backstage/plugin-events-backend-module-gitlab/alpha';
|
|
51
51
|
// ...
|
|
52
|
-
backend.add(eventsModuleGitlabWebhook
|
|
52
|
+
backend.add(eventsModuleGitlabWebhook);
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
#### Legacy Backend System
|
package/alpha/package.json
CHANGED
package/dist/alpha.cjs.js
CHANGED
|
@@ -1,45 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var GitlabEventRouter = require('./cjs/GitlabEventRouter-C7Oujuqb.cjs.js');
|
|
6
|
-
var alpha = require('@backstage/plugin-events-node/alpha');
|
|
3
|
+
var eventsModuleGitlabEventRouter = require('./service/eventsModuleGitlabEventRouter.cjs.js');
|
|
4
|
+
var eventsModuleGitlabWebhook = require('./service/eventsModuleGitlabWebhook.cjs.js');
|
|
7
5
|
|
|
8
|
-
const eventsModuleGitlabEventRouter = backendPluginApi.createBackendModule({
|
|
9
|
-
pluginId: "events",
|
|
10
|
-
moduleId: "gitlab-event-router",
|
|
11
|
-
register(env) {
|
|
12
|
-
env.registerInit({
|
|
13
|
-
deps: {
|
|
14
|
-
events: pluginEventsNode.eventsServiceRef
|
|
15
|
-
},
|
|
16
|
-
async init({ events }) {
|
|
17
|
-
const eventRouter = new GitlabEventRouter.GitlabEventRouter({ events });
|
|
18
|
-
await eventRouter.subscribe();
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
6
|
|
|
24
|
-
const eventsModuleGitlabWebhook = backendPluginApi.createBackendModule({
|
|
25
|
-
pluginId: "events",
|
|
26
|
-
moduleId: "gitlab-webhook",
|
|
27
|
-
register(env) {
|
|
28
|
-
env.registerInit({
|
|
29
|
-
deps: {
|
|
30
|
-
config: backendPluginApi.coreServices.rootConfig,
|
|
31
|
-
events: alpha.eventsExtensionPoint
|
|
32
|
-
},
|
|
33
|
-
async init({ config, events }) {
|
|
34
|
-
events.addHttpPostIngress({
|
|
35
|
-
topic: "gitlab",
|
|
36
|
-
validator: GitlabEventRouter.createGitlabTokenValidator(config)
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
7
|
|
|
43
|
-
exports.eventsModuleGitlabEventRouter = eventsModuleGitlabEventRouter;
|
|
44
|
-
exports.eventsModuleGitlabWebhook = eventsModuleGitlabWebhook;
|
|
8
|
+
exports.eventsModuleGitlabEventRouter = eventsModuleGitlabEventRouter.eventsModuleGitlabEventRouter;
|
|
9
|
+
exports.eventsModuleGitlabWebhook = eventsModuleGitlabWebhook.eventsModuleGitlabWebhook;
|
|
45
10
|
//# sourceMappingURL=alpha.cjs.js.map
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":[
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function createGitlabTokenValidator(config) {
|
|
4
|
+
const secret = config.getString("events.modules.gitlab.webhookSecret");
|
|
5
|
+
return async (request, context) => {
|
|
6
|
+
const token = request.headers["x-gitlab-token"];
|
|
7
|
+
if (secret !== token) {
|
|
8
|
+
context.reject({
|
|
9
|
+
status: 403,
|
|
10
|
+
payload: { message: "invalid token" }
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.createGitlabTokenValidator = createGitlabTokenValidator;
|
|
17
|
+
//# sourceMappingURL=createGitlabTokenValidator.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createGitlabTokenValidator.cjs.js","sources":["../../src/http/createGitlabTokenValidator.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n RequestDetails,\n RequestValidationContext,\n RequestValidator,\n} from '@backstage/plugin-events-node';\n\n/**\n * Validates a configured secret token against the token received with the `x-gitlab-token` header.\n *\n * See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#validate-payloads-by-using-a-secret-token\n * for more details.\n *\n * @param config - root config\n * @public\n */\nexport function createGitlabTokenValidator(config: Config): RequestValidator {\n const secret = config.getString('events.modules.gitlab.webhookSecret');\n\n return async (\n request: RequestDetails,\n context: RequestValidationContext,\n ): Promise<void> => {\n const token = request.headers['x-gitlab-token'] as string | undefined;\n\n if (secret !== token) {\n context.reject({\n status: 403,\n payload: { message: 'invalid token' },\n });\n }\n };\n}\n"],"names":[],"mappings":";;AAgCO,SAAS,2BAA2B,MAAkC,EAAA;AAC3E,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,SAAA,CAAU,qCAAqC,CAAA,CAAA;AAErE,EAAO,OAAA,OACL,SACA,OACkB,KAAA;AAClB,IAAM,MAAA,KAAA,GAAQ,OAAQ,CAAA,OAAA,CAAQ,gBAAgB,CAAA,CAAA;AAE9C,IAAA,IAAI,WAAW,KAAO,EAAA;AACpB,MAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,QACb,MAAQ,EAAA,GAAA;AAAA,QACR,OAAA,EAAS,EAAE,OAAA,EAAS,eAAgB,EAAA;AAAA,OACrC,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA;AACF;;;;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('
|
|
3
|
+
var createGitlabTokenValidator = require('./http/createGitlabTokenValidator.cjs.js');
|
|
4
|
+
var GitlabEventRouter = require('./router/GitlabEventRouter.cjs.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
exports.createGitlabTokenValidator = createGitlabTokenValidator.createGitlabTokenValidator;
|
|
8
9
|
exports.GitlabEventRouter = GitlabEventRouter.GitlabEventRouter;
|
|
9
|
-
exports.createGitlabTokenValidator = GitlabEventRouter.createGitlabTokenValidator;
|
|
10
10
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -2,19 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var pluginEventsNode = require('@backstage/plugin-events-node');
|
|
4
4
|
|
|
5
|
-
function createGitlabTokenValidator(config) {
|
|
6
|
-
const secret = config.getString("events.modules.gitlab.webhookSecret");
|
|
7
|
-
return async (request, context) => {
|
|
8
|
-
const token = request.headers["x-gitlab-token"];
|
|
9
|
-
if (secret !== token) {
|
|
10
|
-
context.reject({
|
|
11
|
-
status: 403,
|
|
12
|
-
payload: { message: "invalid token" }
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
5
|
class GitlabEventRouter extends pluginEventsNode.SubTopicEventRouter {
|
|
19
6
|
constructor(options) {
|
|
20
7
|
super({
|
|
@@ -35,5 +22,4 @@ class GitlabEventRouter extends pluginEventsNode.SubTopicEventRouter {
|
|
|
35
22
|
}
|
|
36
23
|
|
|
37
24
|
exports.GitlabEventRouter = GitlabEventRouter;
|
|
38
|
-
|
|
39
|
-
//# sourceMappingURL=GitlabEventRouter-C7Oujuqb.cjs.js.map
|
|
25
|
+
//# sourceMappingURL=GitlabEventRouter.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitlabEventRouter.cjs.js","sources":["../../src/router/GitlabEventRouter.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n EventParams,\n EventsService,\n SubTopicEventRouter,\n} from '@backstage/plugin-events-node';\n\n/**\n * Subscribes to the generic `gitlab` topic\n * and publishes the events under the more concrete sub-topic\n * depending on the `$.event_name` field provided.\n *\n * @public\n */\nexport class GitlabEventRouter extends SubTopicEventRouter {\n constructor(options: { events: EventsService }) {\n super({\n events: options.events,\n topic: 'gitlab',\n });\n }\n\n protected getSubscriberId(): string {\n return 'GitlabEventRouter';\n }\n\n protected determineSubTopic(params: EventParams): string | undefined {\n if ('event_name' in (params.eventPayload as object)) {\n const payload = params.eventPayload as { event_name: string };\n return payload.event_name;\n }\n\n return undefined;\n }\n}\n"],"names":["SubTopicEventRouter"],"mappings":";;;;AA6BO,MAAM,0BAA0BA,oCAAoB,CAAA;AAAA,EACzD,YAAY,OAAoC,EAAA;AAC9C,IAAM,KAAA,CAAA;AAAA,MACJ,QAAQ,OAAQ,CAAA,MAAA;AAAA,MAChB,KAAO,EAAA,QAAA;AAAA,KACR,CAAA,CAAA;AAAA,GACH;AAAA,EAEU,eAA0B,GAAA;AAClC,IAAO,OAAA,mBAAA,CAAA;AAAA,GACT;AAAA,EAEU,kBAAkB,MAAyC,EAAA;AACnE,IAAI,IAAA,YAAA,IAAiB,OAAO,YAAyB,EAAA;AACnD,MAAA,MAAM,UAAU,MAAO,CAAA,YAAA,CAAA;AACvB,MAAA,OAAO,OAAQ,CAAA,UAAA,CAAA;AAAA,KACjB;AAEA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AACF;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var pluginEventsNode = require('@backstage/plugin-events-node');
|
|
5
|
+
var GitlabEventRouter = require('../router/GitlabEventRouter.cjs.js');
|
|
6
|
+
|
|
7
|
+
const eventsModuleGitlabEventRouter = backendPluginApi.createBackendModule({
|
|
8
|
+
pluginId: "events",
|
|
9
|
+
moduleId: "gitlab-event-router",
|
|
10
|
+
register(env) {
|
|
11
|
+
env.registerInit({
|
|
12
|
+
deps: {
|
|
13
|
+
events: pluginEventsNode.eventsServiceRef
|
|
14
|
+
},
|
|
15
|
+
async init({ events }) {
|
|
16
|
+
const eventRouter = new GitlabEventRouter.GitlabEventRouter({ events });
|
|
17
|
+
await eventRouter.subscribe();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
exports.eventsModuleGitlabEventRouter = eventsModuleGitlabEventRouter;
|
|
24
|
+
//# sourceMappingURL=eventsModuleGitlabEventRouter.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventsModuleGitlabEventRouter.cjs.js","sources":["../../src/service/eventsModuleGitlabEventRouter.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport { eventsServiceRef } from '@backstage/plugin-events-node';\nimport { GitlabEventRouter } from '../router/GitlabEventRouter';\n\n/**\n * Module for the events-backend plugin, adding an event router for GitLab.\n *\n * Registers the `GitlabEventRouter`.\n *\n * @alpha\n */\nexport const eventsModuleGitlabEventRouter = createBackendModule({\n pluginId: 'events',\n moduleId: 'gitlab-event-router',\n register(env) {\n env.registerInit({\n deps: {\n events: eventsServiceRef,\n },\n async init({ events }) {\n const eventRouter = new GitlabEventRouter({ events: events });\n await eventRouter.subscribe();\n },\n });\n },\n});\n"],"names":["createBackendModule","eventsServiceRef","GitlabEventRouter"],"mappings":";;;;;;AA2BO,MAAM,gCAAgCA,oCAAoB,CAAA;AAAA,EAC/D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,qBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAQ,EAAAC,iCAAA;AAAA,OACV;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,MAAA,EAAU,EAAA;AACrB,QAAA,MAAM,WAAc,GAAA,IAAIC,mCAAkB,CAAA,EAAE,QAAgB,CAAA,CAAA;AAC5D,QAAA,MAAM,YAAY,SAAU,EAAA,CAAA;AAAA,OAC9B;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var alpha = require('@backstage/plugin-events-node/alpha');
|
|
5
|
+
var createGitlabTokenValidator = require('../http/createGitlabTokenValidator.cjs.js');
|
|
6
|
+
|
|
7
|
+
const eventsModuleGitlabWebhook = backendPluginApi.createBackendModule({
|
|
8
|
+
pluginId: "events",
|
|
9
|
+
moduleId: "gitlab-webhook",
|
|
10
|
+
register(env) {
|
|
11
|
+
env.registerInit({
|
|
12
|
+
deps: {
|
|
13
|
+
config: backendPluginApi.coreServices.rootConfig,
|
|
14
|
+
events: alpha.eventsExtensionPoint
|
|
15
|
+
},
|
|
16
|
+
async init({ config, events }) {
|
|
17
|
+
events.addHttpPostIngress({
|
|
18
|
+
topic: "gitlab",
|
|
19
|
+
validator: createGitlabTokenValidator.createGitlabTokenValidator(config)
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
exports.eventsModuleGitlabWebhook = eventsModuleGitlabWebhook;
|
|
27
|
+
//# sourceMappingURL=eventsModuleGitlabWebhook.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventsModuleGitlabWebhook.cjs.js","sources":["../../src/service/eventsModuleGitlabWebhook.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha';\nimport { createGitlabTokenValidator } from '../http/createGitlabTokenValidator';\n\n/**\n * Module for the events-backend plugin,\n * registering an HTTP POST ingress with request validator\n * which verifies the webhook token based on a secret.\n *\n * Registers the `GitlabEventRouter`.\n *\n * @alpha\n */\nexport const eventsModuleGitlabWebhook = createBackendModule({\n pluginId: 'events',\n moduleId: 'gitlab-webhook',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\n events: eventsExtensionPoint,\n },\n async init({ config, events }) {\n events.addHttpPostIngress({\n topic: 'gitlab',\n validator: createGitlabTokenValidator(config),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","coreServices","eventsExtensionPoint","createGitlabTokenValidator"],"mappings":";;;;;;AAgCO,MAAM,4BAA4BA,oCAAoB,CAAA;AAAA,EAC3D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,gBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,UAAA;AAAA,QACrB,MAAQ,EAAAC,0BAAA;AAAA,OACV;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,MAAA,EAAQ,QAAU,EAAA;AAC7B,QAAA,MAAA,CAAO,kBAAmB,CAAA;AAAA,UACxB,KAAO,EAAA,QAAA;AAAA,UACP,SAAA,EAAWC,sDAA2B,MAAM,CAAA;AAAA,SAC7C,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-events-backend-module-gitlab",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12-next.1",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin-module",
|
|
6
6
|
"pluginId": "events",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"test": "backstage-cli package test"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@backstage/backend-plugin-api": "
|
|
50
|
-
"@backstage/config": "
|
|
51
|
-
"@backstage/plugin-events-node": "
|
|
49
|
+
"@backstage/backend-plugin-api": "1.0.1-next.1",
|
|
50
|
+
"@backstage/config": "1.2.0",
|
|
51
|
+
"@backstage/plugin-events-node": "0.4.1-next.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@backstage/backend-test-utils": "
|
|
55
|
-
"@backstage/cli": "
|
|
56
|
-
"@backstage/plugin-events-backend-test-utils": "
|
|
54
|
+
"@backstage/backend-test-utils": "1.0.1-next.2",
|
|
55
|
+
"@backstage/cli": "0.28.0-next.2",
|
|
56
|
+
"@backstage/plugin-events-backend-test-utils": "0.1.36-next.1"
|
|
57
57
|
},
|
|
58
58
|
"configSchema": "config.d.ts"
|
|
59
59
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GitlabEventRouter-C7Oujuqb.cjs.js","sources":["../../src/http/createGitlabTokenValidator.ts","../../src/router/GitlabEventRouter.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n RequestDetails,\n RequestValidationContext,\n RequestValidator,\n} from '@backstage/plugin-events-node';\n\n/**\n * Validates a configured secret token against the token received with the `x-gitlab-token` header.\n *\n * See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#validate-payloads-by-using-a-secret-token\n * for more details.\n *\n * @param config - root config\n * @public\n */\nexport function createGitlabTokenValidator(config: Config): RequestValidator {\n const secret = config.getString('events.modules.gitlab.webhookSecret');\n\n return async (\n request: RequestDetails,\n context: RequestValidationContext,\n ): Promise<void> => {\n const token = request.headers['x-gitlab-token'] as string | undefined;\n\n if (secret !== token) {\n context.reject({\n status: 403,\n payload: { message: 'invalid token' },\n });\n }\n };\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n EventParams,\n EventsService,\n SubTopicEventRouter,\n} from '@backstage/plugin-events-node';\n\n/**\n * Subscribes to the generic `gitlab` topic\n * and publishes the events under the more concrete sub-topic\n * depending on the `$.event_name` field provided.\n *\n * @public\n */\nexport class GitlabEventRouter extends SubTopicEventRouter {\n constructor(options: { events: EventsService }) {\n super({\n events: options.events,\n topic: 'gitlab',\n });\n }\n\n protected getSubscriberId(): string {\n return 'GitlabEventRouter';\n }\n\n protected determineSubTopic(params: EventParams): string | undefined {\n if ('event_name' in (params.eventPayload as object)) {\n const payload = params.eventPayload as { event_name: string };\n return payload.event_name;\n }\n\n return undefined;\n }\n}\n"],"names":["SubTopicEventRouter"],"mappings":";;;;AAgCO,SAAS,2BAA2B,MAAkC,EAAA;AAC3E,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,SAAA,CAAU,qCAAqC,CAAA,CAAA;AAErE,EAAO,OAAA,OACL,SACA,OACkB,KAAA;AAClB,IAAM,MAAA,KAAA,GAAQ,OAAQ,CAAA,OAAA,CAAQ,gBAAgB,CAAA,CAAA;AAE9C,IAAA,IAAI,WAAW,KAAO,EAAA;AACpB,MAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,QACb,MAAQ,EAAA,GAAA;AAAA,QACR,OAAA,EAAS,EAAE,OAAA,EAAS,eAAgB,EAAA;AAAA,OACrC,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA;AACF;;ACnBO,MAAM,0BAA0BA,oCAAoB,CAAA;AAAA,EACzD,YAAY,OAAoC,EAAA;AAC9C,IAAM,KAAA,CAAA;AAAA,MACJ,QAAQ,OAAQ,CAAA,MAAA;AAAA,MAChB,KAAO,EAAA,QAAA;AAAA,KACR,CAAA,CAAA;AAAA,GACH;AAAA,EAEU,eAA0B,GAAA;AAClC,IAAO,OAAA,mBAAA,CAAA;AAAA,GACT;AAAA,EAEU,kBAAkB,MAAyC,EAAA;AACnE,IAAI,IAAA,YAAA,IAAiB,OAAO,YAAyB,EAAA;AACnD,MAAA,MAAM,UAAU,MAAO,CAAA,YAAA,CAAA;AACvB,MAAA,OAAO,OAAQ,CAAA,UAAA,CAAA;AAAA,KACjB;AAEA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AACF;;;;;"}
|