@backstage/plugin-events-backend-module-gitlab 0.1.1-next.0 → 0.1.1-next.2
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 +28 -0
- package/README.md +28 -0
- package/alpha/package.json +1 -1
- package/config.d.ts +36 -0
- package/dist/index.alpha.d.ts +25 -1
- package/dist/index.beta.d.ts +16 -1
- package/dist/index.cjs.js +34 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +16 -1
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @backstage/plugin-events-backend-module-gitlab
|
|
2
2
|
|
|
3
|
+
## 0.1.1-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 884d749b14: Refactored to use `coreServices` from `@backstage/backend-plugin-api`.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/backend-plugin-api@0.2.0-next.2
|
|
10
|
+
- @backstage/config@1.0.5-next.1
|
|
11
|
+
- @backstage/plugin-events-node@0.2.0-next.2
|
|
12
|
+
|
|
13
|
+
## 0.1.1-next.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 31fe8f256a: Add `createGitlabTokenValidator(config)` which can be used
|
|
18
|
+
to create a validator used at an ingress for topic `gitlab`.
|
|
19
|
+
|
|
20
|
+
On top, there is a new `gitlabWebhookEventsModule` for the new backend plugin API
|
|
21
|
+
which auto-registers the `HttpPostIngress` for topic `gitlab` incl. the validator.
|
|
22
|
+
|
|
23
|
+
Please find more information at
|
|
24
|
+
https://github.com/backstage/backstage/tree/master/plugins/events-backend-module-gitlab/README.md.
|
|
25
|
+
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
- @backstage/backend-plugin-api@0.1.5-next.1
|
|
28
|
+
- @backstage/config@1.0.5-next.1
|
|
29
|
+
- @backstage/plugin-events-node@0.2.0-next.1
|
|
30
|
+
|
|
3
31
|
## 0.1.1-next.0
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -40,3 +40,31 @@ Add the event router to the `EventsBackend`:
|
|
|
40
40
|
+ .addSubscribers(gitlabEventRouter);
|
|
41
41
|
// [...]
|
|
42
42
|
```
|
|
43
|
+
|
|
44
|
+
### Token Validator
|
|
45
|
+
|
|
46
|
+
Add the token validator for the topic `gitlab`:
|
|
47
|
+
|
|
48
|
+
```diff
|
|
49
|
+
// at packages/backend/src/plugins/events.ts
|
|
50
|
+
+ import { createGitlabTokenValidator } from '@backstage/plugin-events-backend-module-gitlab';
|
|
51
|
+
// [...]
|
|
52
|
+
const http = HttpPostIngressEventPublisher.fromConfig({
|
|
53
|
+
config: env.config,
|
|
54
|
+
ingresses: {
|
|
55
|
+
+ gitlab: {
|
|
56
|
+
+ validator: createGitlabTokenValidator(env.config),
|
|
57
|
+
+ },
|
|
58
|
+
},
|
|
59
|
+
logger: env.logger,
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Additionally, you need to add the configuration:
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
events:
|
|
67
|
+
modules:
|
|
68
|
+
gitlab:
|
|
69
|
+
webhookSecret: your-secret-token
|
|
70
|
+
```
|
package/alpha/package.json
CHANGED
package/config.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 The Backstage Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface Config {
|
|
18
|
+
events?: {
|
|
19
|
+
modules?: {
|
|
20
|
+
/**
|
|
21
|
+
* events-backend-module-gitlab plugin configuration.
|
|
22
|
+
*/
|
|
23
|
+
gitlab?: {
|
|
24
|
+
/**
|
|
25
|
+
* Secret token for webhook requests used to verify tokens.
|
|
26
|
+
*
|
|
27
|
+
* See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#validate-payloads-by-using-a-secret-token
|
|
28
|
+
* for more details.
|
|
29
|
+
*
|
|
30
|
+
* @visibility secret
|
|
31
|
+
*/
|
|
32
|
+
webhookSecret?: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}
|
package/dist/index.alpha.d.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The module "gitlab" for the Backstage backend plugin "events-backend"
|
|
3
|
-
* adding an event router for GitLab.
|
|
3
|
+
* adding an event router and token validator for GitLab.
|
|
4
4
|
*
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
|
+
import { Config } from '@backstage/config';
|
|
9
10
|
import { EventParams } from '@backstage/plugin-events-node';
|
|
11
|
+
import { RequestValidator } from '@backstage/plugin-events-node';
|
|
10
12
|
import { SubTopicEventRouter } from '@backstage/plugin-events-node';
|
|
11
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Validates a configured secret token against the token received with the `x-gitlab-token` header.
|
|
16
|
+
*
|
|
17
|
+
* See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#validate-payloads-by-using-a-secret-token
|
|
18
|
+
* for more details.
|
|
19
|
+
*
|
|
20
|
+
* @param config - root config
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare function createGitlabTokenValidator(config: Config): RequestValidator;
|
|
24
|
+
|
|
12
25
|
/**
|
|
13
26
|
* Subscribes to the generic `gitlab` topic
|
|
14
27
|
* and publishes the events under the more concrete sub-topic
|
|
@@ -30,4 +43,15 @@ export declare class GitlabEventRouter extends SubTopicEventRouter {
|
|
|
30
43
|
*/
|
|
31
44
|
export declare const gitlabEventRouterEventsModule: (options?: undefined) => BackendFeature;
|
|
32
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Module for the events-backend plugin,
|
|
48
|
+
* registering an HTTP POST ingress with request validator
|
|
49
|
+
* which verifies the webhook token based on a secret.
|
|
50
|
+
*
|
|
51
|
+
* Registers the {@link GitlabEventRouter}.
|
|
52
|
+
*
|
|
53
|
+
* @alpha
|
|
54
|
+
*/
|
|
55
|
+
export declare const gitlabWebhookEventsModule: (options?: undefined) => BackendFeature;
|
|
56
|
+
|
|
33
57
|
export { }
|
package/dist/index.beta.d.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The module "gitlab" for the Backstage backend plugin "events-backend"
|
|
3
|
-
* adding an event router for GitLab.
|
|
3
|
+
* adding an event router and token validator for GitLab.
|
|
4
4
|
*
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
|
+
import { Config } from '@backstage/config';
|
|
9
10
|
import { EventParams } from '@backstage/plugin-events-node';
|
|
11
|
+
import { RequestValidator } from '@backstage/plugin-events-node';
|
|
10
12
|
import { SubTopicEventRouter } from '@backstage/plugin-events-node';
|
|
11
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Validates a configured secret token against the token received with the `x-gitlab-token` header.
|
|
16
|
+
*
|
|
17
|
+
* See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#validate-payloads-by-using-a-secret-token
|
|
18
|
+
* for more details.
|
|
19
|
+
*
|
|
20
|
+
* @param config - root config
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare function createGitlabTokenValidator(config: Config): RequestValidator;
|
|
24
|
+
|
|
12
25
|
/**
|
|
13
26
|
* Subscribes to the generic `gitlab` topic
|
|
14
27
|
* and publishes the events under the more concrete sub-topic
|
|
@@ -23,4 +36,6 @@ export declare class GitlabEventRouter extends SubTopicEventRouter {
|
|
|
23
36
|
|
|
24
37
|
/* Excluded from this release type: gitlabEventRouterEventsModule */
|
|
25
38
|
|
|
39
|
+
/* Excluded from this release type: gitlabWebhookEventsModule */
|
|
40
|
+
|
|
26
41
|
export { }
|
package/dist/index.cjs.js
CHANGED
|
@@ -5,6 +5,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var pluginEventsNode = require('@backstage/plugin-events-node');
|
|
6
6
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
7
7
|
|
|
8
|
+
function createGitlabTokenValidator(config) {
|
|
9
|
+
const secret = config.getString("events.modules.gitlab.webhookSecret");
|
|
10
|
+
return async (request, context) => {
|
|
11
|
+
const token = request.headers["x-gitlab-token"];
|
|
12
|
+
if (secret !== token) {
|
|
13
|
+
context.reject({
|
|
14
|
+
status: 403,
|
|
15
|
+
payload: { message: "invalid token" }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
8
21
|
class GitlabEventRouter extends pluginEventsNode.SubTopicEventRouter {
|
|
9
22
|
constructor() {
|
|
10
23
|
super("gitlab");
|
|
@@ -35,6 +48,27 @@ const gitlabEventRouterEventsModule = backendPluginApi.createBackendModule({
|
|
|
35
48
|
}
|
|
36
49
|
});
|
|
37
50
|
|
|
51
|
+
const gitlabWebhookEventsModule = backendPluginApi.createBackendModule({
|
|
52
|
+
pluginId: "events",
|
|
53
|
+
moduleId: "gitlabWebhook",
|
|
54
|
+
register(env) {
|
|
55
|
+
env.registerInit({
|
|
56
|
+
deps: {
|
|
57
|
+
config: backendPluginApi.coreServices.config,
|
|
58
|
+
events: pluginEventsNode.eventsExtensionPoint
|
|
59
|
+
},
|
|
60
|
+
async init({ config, events }) {
|
|
61
|
+
events.addHttpPostIngress({
|
|
62
|
+
topic: "gitlab",
|
|
63
|
+
validator: createGitlabTokenValidator(config)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
38
70
|
exports.GitlabEventRouter = GitlabEventRouter;
|
|
71
|
+
exports.createGitlabTokenValidator = createGitlabTokenValidator;
|
|
39
72
|
exports.gitlabEventRouterEventsModule = gitlabEventRouterEventsModule;
|
|
73
|
+
exports.gitlabWebhookEventsModule = gitlabWebhookEventsModule;
|
|
40
74
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/router/GitlabEventRouter.ts","../src/service/GitlabEventRouterEventsModule.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 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() {\n super('gitlab');\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","/*\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 { eventsExtensionPoint } 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 {@link GitlabEventRouter}.\n *\n * @alpha\n */\nexport const gitlabEventRouterEventsModule = createBackendModule({\n pluginId: 'events',\n moduleId: 'gitlabEventRouter',\n register(env) {\n env.registerInit({\n deps: {\n events: eventsExtensionPoint,\n },\n async init({ events }) {\n const eventRouter = new GitlabEventRouter();\n\n events.addPublishers(eventRouter);\n events.addSubscribers(eventRouter);\n },\n });\n },\n});\n"],"names":["SubTopicEventRouter","createBackendModule","eventsExtensionPoint"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/http/createGitlabTokenValidator.ts","../src/router/GitlabEventRouter.ts","../src/service/GitlabEventRouterEventsModule.ts","../src/service/GitlabWebhookEventsModule.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 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() {\n super('gitlab');\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","/*\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 { eventsExtensionPoint } 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 {@link GitlabEventRouter}.\n *\n * @alpha\n */\nexport const gitlabEventRouterEventsModule = createBackendModule({\n pluginId: 'events',\n moduleId: 'gitlabEventRouter',\n register(env) {\n env.registerInit({\n deps: {\n events: eventsExtensionPoint,\n },\n async init({ events }) {\n const eventRouter = new GitlabEventRouter();\n\n events.addPublishers(eventRouter);\n events.addSubscribers(eventRouter);\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 coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { eventsExtensionPoint } from '@backstage/plugin-events-node';\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 {@link GitlabEventRouter}.\n *\n * @alpha\n */\nexport const gitlabWebhookEventsModule = createBackendModule({\n pluginId: 'events',\n moduleId: 'gitlabWebhook',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.config,\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":["SubTopicEventRouter","createBackendModule","eventsExtensionPoint","coreServices"],"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,QAAQ,OAAQ,CAAA,gBAAA,CAAA,CAAA;AAE9B,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;;ACpBO,MAAM,0BAA0BA,oCAAoB,CAAA;AAAA,EACzD,WAAc,GAAA;AACZ,IAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAAA,GAChB;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;;ACdO,MAAM,gCAAgCC,oCAAoB,CAAA;AAAA,EAC/D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,mBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAQ,EAAAC,qCAAA;AAAA,OACV;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,MAAA,EAAU,EAAA;AACrB,QAAM,MAAA,WAAA,GAAc,IAAI,iBAAkB,EAAA,CAAA;AAE1C,QAAA,MAAA,CAAO,cAAc,WAAW,CAAA,CAAA;AAChC,QAAA,MAAA,CAAO,eAAe,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;ACXM,MAAM,4BAA4BD,oCAAoB,CAAA;AAAA,EAC3D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,eAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQE,6BAAa,CAAA,MAAA;AAAA,QACrB,MAAQ,EAAAD,qCAAA;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,EAAW,2BAA2B,MAAM,CAAA;AAAA,SAC7C,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The module "gitlab" for the Backstage backend plugin "events-backend"
|
|
3
|
-
* adding an event router for GitLab.
|
|
3
|
+
* adding an event router and token validator for GitLab.
|
|
4
4
|
*
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
|
+
import { Config } from '@backstage/config';
|
|
9
10
|
import { EventParams } from '@backstage/plugin-events-node';
|
|
11
|
+
import { RequestValidator } from '@backstage/plugin-events-node';
|
|
10
12
|
import { SubTopicEventRouter } from '@backstage/plugin-events-node';
|
|
11
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Validates a configured secret token against the token received with the `x-gitlab-token` header.
|
|
16
|
+
*
|
|
17
|
+
* See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#validate-payloads-by-using-a-secret-token
|
|
18
|
+
* for more details.
|
|
19
|
+
*
|
|
20
|
+
* @param config - root config
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare function createGitlabTokenValidator(config: Config): RequestValidator;
|
|
24
|
+
|
|
12
25
|
/**
|
|
13
26
|
* Subscribes to the generic `gitlab` topic
|
|
14
27
|
* and publishes the events under the more concrete sub-topic
|
|
@@ -23,4 +36,6 @@ export declare class GitlabEventRouter extends SubTopicEventRouter {
|
|
|
23
36
|
|
|
24
37
|
/* Excluded from this release type: gitlabEventRouterEventsModule */
|
|
25
38
|
|
|
39
|
+
/* Excluded from this release type: gitlabWebhookEventsModule */
|
|
40
|
+
|
|
26
41
|
export { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-events-backend-module-gitlab",
|
|
3
|
-
"version": "0.1.1-next.
|
|
3
|
+
"version": "0.1.1-next.2",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,18 +23,21 @@
|
|
|
23
23
|
"postpack": "backstage-cli package postpack"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@backstage/backend-plugin-api": "^0.
|
|
27
|
-
"@backstage/
|
|
26
|
+
"@backstage/backend-plugin-api": "^0.2.0-next.2",
|
|
27
|
+
"@backstage/config": "^1.0.5-next.1",
|
|
28
|
+
"@backstage/plugin-events-node": "^0.2.0-next.2",
|
|
28
29
|
"winston": "^3.2.1"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@backstage/backend-test-utils": "^0.1.31-next.
|
|
32
|
-
"@backstage/cli": "^0.21.2-next.
|
|
33
|
-
"@backstage/plugin-events-backend-test-utils": "^0.1.1-next.
|
|
32
|
+
"@backstage/backend-test-utils": "^0.1.31-next.2",
|
|
33
|
+
"@backstage/cli": "^0.21.2-next.2",
|
|
34
|
+
"@backstage/plugin-events-backend-test-utils": "^0.1.1-next.2",
|
|
34
35
|
"supertest": "^6.1.3"
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
37
38
|
"alpha",
|
|
39
|
+
"config.d.ts",
|
|
38
40
|
"dist"
|
|
39
|
-
]
|
|
41
|
+
],
|
|
42
|
+
"configSchema": "config.d.ts"
|
|
40
43
|
}
|