Backstage
    Preparing search index...

    Module @backstage/plugin-events-backend-module-gitlab

    The module "gitlab" for the Backstage backend plugin "events-backend" adding an event router and token validator for GitLab.

    events-backend-module-gitlab

    Welcome to the events-backend-module-gitlab backend module!

    This package is a module for the events-backend backend plugin and extends the event system with an GitlabEventRouter.

    The event router will subscribe to the topic gitlab and route the events to more concrete topics based on the value of the provided $.event_name payload field.

    Examples:

    $.event_name topic
    push gitlab.push
    merge_request gitlab.merge_request

    Please find all possible webhook event types at the official documentation.

    # From your Backstage root directory
    yarn --cwd packages/backend add @backstage/plugin-events-backend-module-gitlab
    // packages/backend/src/index.ts
    import { eventsModuleGitlabEventRouter } from '@backstage/plugin-events-backend-module-gitlab/alpha';
    // ...
    backend.add(eventsModuleGitlabEventRouter);
    // packages/backend/src/plugins/events.ts
    const eventRouter = new GitlabEventRouter({ events: env.events });
    await eventRouter.subscribe();
    // packages/backend/src/index.ts
    import { eventsModuleGitlabWebhook } from '@backstage/plugin-events-backend-module-gitlab/alpha';
    // ...
    backend.add(eventsModuleGitlabWebhook);

    Add the token validator for the topic gitlab:

    // packages/backend/src/plugins/events.ts
    + import { createGitlabTokenValidator } from '@backstage/plugin-events-backend-module-gitlab';
    // [...]
    const http = HttpPostIngressEventPublisher.fromConfig({
    config: env.config,
    events: env.events,
    ingresses: {
    + gitlab: {
    + validator: createGitlabTokenValidator(env.config, env.logger),
    + },
    },
    logger: env.logger,
    });

    Webhook authentication is secure by default. Requests to the module's endpoint /api/events/http/gitlab without a configured webhookSecret return an HTTP 403 Forbidden status.

    This only covers the module's own endpoint. Routes created solely through events.http.topics have no validator attached and still accept unauthenticated requests.

    Add the following to your app-config.yaml:

    events:
    modules:
    gitlab:
    webhookSecret: your-secret-token

    For more details on securing webhooks on GitLab, see the GitLab documentation.

    For development or testing environments where a webhook secret cannot be configured, you can set dangerouslyAllowUnauthenticatedEvents: true as an explicit escape hatch under the module configuration:

    events:
    modules:
    gitlab:
    dangerouslyAllowUnauthenticatedEvents: true
    Warning

    Only use dangerouslyAllowUnauthenticatedEvents: true for development or testing. Never enable this option in production environments.

    GitlabEventRouter
    index
    createGitlabTokenValidator