Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy provisioner API #931

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.d/931.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The legacy provisioning API has been removed (used by services such as Dimension). Developers should seek to update
to use the widget API, which supports more features and is regularly updated.
33 changes: 0 additions & 33 deletions src/Bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { GithubInstance } from "./github/GithubInstance";
import { IBridgeStorageProvider } from "./Stores/StorageProvider";
import { IConnection, GitHubDiscussionSpace, GitHubDiscussionConnection, GitHubUserSpace, JiraProjectConnection, GitLabRepoConnection,
GitHubIssueConnection, GitHubProjectConnection, GitHubRepoConnection, GitLabIssueConnection, FigmaFileConnection, FeedConnection, GenericHookConnection, WebhookResponse } from "./Connections";

Check warning on line 13 in src/Bridge.ts

View workflow job for this annotation

GitHub Actions / lint-node

'GenericHookConnection' is defined but never used
import { IGitLabWebhookIssueStateEvent, IGitLabWebhookMREvent, IGitLabWebhookNoteEvent, IGitLabWebhookPushEvent, IGitLabWebhookReleaseEvent, IGitLabWebhookTagPushEvent, IGitLabWebhookWikiPageEvent } from "./Gitlab/WebhookTypes";
import { JiraIssueEvent, JiraIssueUpdatedEvent, JiraVersionEvent } from "./jira/WebhookTypes";
import { JiraOAuthResult } from "./jira/Types";
Expand All @@ -26,9 +26,8 @@
import { UserTokenStore } from "./tokens/UserTokenStore";
import * as GitHubWebhookTypes from "@octokit/webhooks-types";
import { Logger } from "matrix-appservice-bridge";
import { Provisioner } from "./provisioning/provisioner";
import { JiraProvisionerRouter } from "./jira/Router";

Check warning on line 29 in src/Bridge.ts

View workflow job for this annotation

GitHub Actions / lint-node

'JiraProvisionerRouter' is defined but never used
import { GitHubProvisionerRouter } from "./github/Router";

Check warning on line 30 in src/Bridge.ts

View workflow job for this annotation

GitHub Actions / lint-node

'GitHubProvisionerRouter' is defined but never used
import { OAuthRequest } from "./WebhookTypes";
import { promises as fs } from "fs";
import Metrics from "./Metrics";
Expand Down Expand Up @@ -56,7 +55,6 @@
private adminRooms: Map<string, AdminRoom> = new Map();
private feedReader?: FeedReader;
private houndReader?: HoundReader;
private provisioningApi?: Provisioner;
private replyProcessor = new RichRepliesPreprocessor(true);

private ready = false;
Expand Down Expand Up @@ -135,34 +133,6 @@
this.github,
);

if (this.config.provisioning) {
const routers = [];
if (this.config.jira) {
routers.push({
route: "/v1/jira",
router: new JiraProvisionerRouter(this.config.jira, this.tokenStore).getRouter(),
});
this.connectionManager.registerProvisioningConnection(JiraProjectConnection);
}
if (this.config.github && this.github) {
routers.push({
route: "/v1/github",
router: new GitHubProvisionerRouter(this.config.github, this.tokenStore, this.github).getRouter(),
});
this.connectionManager.registerProvisioningConnection(GitHubRepoConnection);
}
if (this.config.generic) {
this.connectionManager.registerProvisioningConnection(GenericHookConnection);
}
this.provisioningApi = new Provisioner(
this.config.provisioning,
this.connectionManager,
this.botUsersManager,
this.as,
routers,
);
}

this.as.on("query.room", async (roomAlias, cb) => {
try {
cb(await this.onQueryRoom(roomAlias));
Expand Down Expand Up @@ -775,9 +745,6 @@
);

}
if (this.provisioningApi) {
this.listener.bindResource('provisioning', this.provisioningApi.expressRouter);
}
if (this.config.metrics?.enabled) {
this.listener.bindResource('metrics', Metrics.expressRouter);
}
Expand Down Expand Up @@ -936,7 +903,7 @@
}
log.info(`Got message roomId=${roomId} type=${event.type} from=${event.sender}`);
log.debug("Content:", JSON.stringify(event));
let processedReply: any;

Check warning on line 906 in src/Bridge.ts

View workflow job for this annotation

GitHub Actions / lint-node

Unexpected any. Specify a different type
let processedReplyMetadata: IRichReplyMetadata|undefined = undefined;
try {
processedReply = await this.replyProcessor.processEvent(event, this.as.botClient, EventKind.RoomEvent);
Expand Down
2 changes: 1 addition & 1 deletion src/ConnectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { ConnectionDeclaration, ConnectionDeclarations, GenericHookConnection, GitHubDiscussionConnection, GitHubDiscussionSpace, GitHubIssueConnection,
GitHubProjectConnection, GitHubRepoConnection, GitHubUserSpace, GitLabIssueConnection, GitLabRepoConnection, IConnection, IConnectionState, JiraProjectConnection } from "./Connections";
import { FigmaFileConnection, FeedConnection } from "./Connections";
import { GetConnectionTypeResponseItem } from "./provisioning/api";
import { GetConnectionTypeResponseItem } from "./Widgets/api";
import { GitLabClient } from "./Gitlab/Client";
import { GithubInstance } from "./github/GithubInstance";
import { IBridgeStorageProvider } from "./Stores/StorageProvider";
Expand Down Expand Up @@ -175,7 +175,7 @@
* @param rollbackBadState
* @returns
*/
public async createConnectionForState(roomId: string, state: StateEvent<any>, rollbackBadState: boolean): Promise<IConnection|undefined> {

Check warning on line 178 in src/ConnectionManager.ts

View workflow job for this annotation

GitHub Actions / lint-node

Unexpected any. Specify a different type
// Empty object == redacted
if (state.content.disabled === true || Object.keys(state.content).length === 0) {
log.debug(`${roomId} has disabled state for ${state.type}`);
Expand Down
2 changes: 1 addition & 1 deletion src/Connections/FeedConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { BaseConnection } from "./BaseConnection";
import markdown from "markdown-it";
import { Connection, ProvisionConnectionOpts } from "./IConnection";
import { GetConnectionsResponseItem } from "../provisioning/api";
import { GetConnectionsResponseItem } from "../Widgets/api";
import { readFeed, sanitizeHtml } from "../libRs";
import UserAgent from "../UserAgent";
import { retry, retryMatrixErrorFilter } from "../PromiseUtil";
Expand Down Expand Up @@ -57,7 +57,7 @@
static readonly ServiceCategory = "feeds";


public static createConnectionForState(roomId: string, event: StateEvent<any>, {config, intent}: InstantiateConnectionOpts) {

Check warning on line 60 in src/Connections/FeedConnection.ts

View workflow job for this annotation

GitHub Actions / lint-node

Unexpected any. Specify a different type
if (!config.feeds?.enabled) {
throw Error('RSS/Atom feeds are not configured');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Connections/GenericHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MatrixEvent } from "../MatrixEvent";
import { Appservice, Intent, StateEvent } from "matrix-bot-sdk";
import { ApiError, ErrCode } from "../api";
import { BaseConnection } from "./BaseConnection";
import { GetConnectionsResponseItem } from "../provisioning/api";
import { GetConnectionsResponseItem } from "../Widgets/api";
import { BridgeConfigGenericWebhooks } from "../config/Config";
import { ensureUserIsInRoom } from "../IntentUtils";
import { randomUUID } from 'node:crypto';
Expand Down
2 changes: 1 addition & 1 deletion src/Connections/GithubRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CommentProcessor } from "../CommentProcessor";
import { FormatUtil, LooseMinimalGitHubRepo } from "../FormatUtil";
import { Octokit } from "@octokit/rest";
import { Connection, IConnection, IConnectionState, InstantiateConnectionOpts, ProvisionConnectionOpts } from "./IConnection";
import { GetConnectionsResponseItem } from "../provisioning/api";
import { GetConnectionsResponseItem } from "../Widgets/api";
import { IssuesOpenedEvent, IssuesReopenedEvent, IssuesEditedEvent, PullRequestOpenedEvent, IssuesClosedEvent, PullRequestClosedEvent,
PullRequestReadyForReviewEvent, PullRequestReviewSubmittedEvent, ReleasePublishedEvent, ReleaseCreatedEvent,
IssuesLabeledEvent, IssuesUnlabeledEvent, WorkflowRunCompletedEvent, IssueCommentCreatedEvent, PushEvent
Expand Down
2 changes: 1 addition & 1 deletion src/Connections/GitlabRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { BridgeConfigGitLab, GitLabInstance } from "../config/Config";
import { IGitlabMergeRequest, IGitlabProject, IGitlabUser, IGitLabWebhookMREvent, IGitLabWebhookNoteEvent, IGitLabWebhookPushEvent, IGitLabWebhookReleaseEvent, IGitLabWebhookTagPushEvent, IGitLabWebhookWikiPageEvent } from "../Gitlab/WebhookTypes";
import { CommandConnection } from "./CommandConnection";
import { Connection, IConnection, IConnectionState, InstantiateConnectionOpts, ProvisionConnectionOpts } from "./IConnection";
import { ConnectionWarning, GetConnectionsResponseItem } from "../provisioning/api";
import { ConnectionWarning, GetConnectionsResponseItem } from "../Widgets/api";
import { ErrCode, ApiError, ValidatorApiError } from "../api"
import { AccessLevel, SerializedGitlabDiscussionThreads } from "../Gitlab/Types";
import Ajv, { JSONSchemaType } from "ajv";
Expand Down
2 changes: 1 addition & 1 deletion src/Connections/IConnection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MatrixEvent, MatrixMessageContent } from "../MatrixEvent";
import { IssuesOpenedEvent, IssuesEditedEvent } from "@octokit/webhooks-types";
import { ConnectionWarning, GetConnectionsResponseItem } from "../provisioning/api";
import { ConnectionWarning, GetConnectionsResponseItem } from "../Widgets/api";
import { Appservice, Intent, IRichReplyMetadata, StateEvent } from "matrix-bot-sdk";
import { BridgeConfig, BridgePermissionLevel } from "../config/Config";
import { UserTokenStore } from "../tokens/UserTokenStore";
Expand Down
2 changes: 1 addition & 1 deletion src/Connections/JiraProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { UserTokenStore } from "../tokens/UserTokenStore";
import { CommandError, NotLoggedInError } from "../errors";
import { ApiError, ErrCode } from "../api";
import JiraApi from "jira-client";
import { GetConnectionsResponseItem } from "../provisioning/api";
import { GetConnectionsResponseItem } from "../Widgets/api";
import { BridgeConfigJira } from "../config/Config";
import { HookshotJiraApi } from "../jira/Client";
import { GrantChecker } from "../grants/GrantCheck";
Expand Down
4 changes: 2 additions & 2 deletions src/ListenerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { errorMiddleware } from "./api";

// Appserices can't be handled yet because the bot-sdk maintains control of it.
// See https://github.com/turt2live/matrix-bot-sdk/issues/191
export type ResourceName = "webhooks"|"widgets"|"metrics"|"provisioning";
export const ResourceTypeArray: ResourceName[] = ["webhooks","widgets","metrics","provisioning"];
export type ResourceName = "webhooks"|"widgets"|"metrics";
export const ResourceTypeArray: ResourceName[] = ["webhooks","widgets","metrics"];
import { Handlers } from "@sentry/node";
export interface BridgeConfigListener {
bindAddress?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/BridgeWidgetApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ProvisioningApi, ProvisioningRequest } from "matrix-appservice-bridge";
import { IBridgeStorageProvider } from "../Stores/StorageProvider";
import { ConnectionManager } from "../ConnectionManager";
import BotUsersManager, {BotUser} from "../Managers/BotUsersManager";
import { assertUserPermissionsInRoom, GetConnectionsResponseItem } from "../provisioning/api";
import { assertUserPermissionsInRoom, GetConnectionsResponseItem } from "./api";
import { Appservice, PowerLevelsEvent } from "matrix-bot-sdk";
import { GithubInstance } from '../github/GithubInstance';
import { AllowedTokenTypes, TokenType, UserTokenStore } from '../tokens/UserTokenStore';
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/BridgeWidgetInterface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GetConnectionsResponseItem } from "../provisioning/api";
import { GetConnectionsResponseItem } from "./api";

export interface BridgeRoomStateGitHub {
enabled: boolean;
Expand Down
File renamed without changes.
25 changes: 5 additions & 20 deletions src/config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,6 @@ export interface BridgeConfigServiceBot {
service: string;
}

export interface BridgeConfigProvisioning {
bindAddress?: string;
port?: number;
secret: string;
}

export interface BridgeConfigMetrics {
enabled: boolean;
bindAddress?: string;
Expand Down Expand Up @@ -472,7 +466,6 @@ export interface BridgeConfigRoot {
metrics?: BridgeConfigMetrics;
passFile: string;
permissions?: BridgeConfigActorPermission[];
provisioning?: BridgeConfigProvisioning;
queue?: BridgeConfigQueue;
sentry?: BridgeConfigSentry;
serviceBots?: BridgeConfigServiceBot[];
Expand Down Expand Up @@ -524,8 +517,6 @@ export class BridgeConfig {
public readonly serviceBots?: BridgeConfigServiceBot[];
@configKey("EXPERIMENTAL support for complimentary widgets", true)
public readonly widgets?: BridgeWidgetConfig;
@configKey("Provisioning API for integration managers", true)
public readonly provisioning?: BridgeConfigProvisioning;
@configKey("Prometheus metrics support", true)
public readonly metrics?: BridgeConfigMetrics;

Expand Down Expand Up @@ -559,7 +550,6 @@ export class BridgeConfig {
this.jira = configData.jira && new BridgeConfigJira(configData.jira);
this.generic = configData.generic && new BridgeConfigGenericWebhooks(configData.generic);
this.feeds = configData.feeds && new BridgeConfigFeeds(configData.feeds);
this.provisioning = configData.provisioning;
this.passFile = configData.passFile ?? "./passkey.pem";
this.bot = configData.bot;
this.serviceBots = configData.serviceBots;
Expand Down Expand Up @@ -627,7 +617,11 @@ export class BridgeConfig {
}

if ('goNebMigrator' in configData) {
log.warn(`The GoNEB migrator has been removed from this release. You should remove the 'goNebMigrator' from your config.`);
log.warn(`The GoNEB migrator has been removed from Hookshot. You should remove the 'goNebMigrator' from your config.`);
}

if ('provisioning' in configData) {
log.warn(`The provisioning API has been removed from Hookshot. You should remove the 'provisioning' from your config.`);
}

// Listeners is a bit special
Expand All @@ -650,15 +644,6 @@ export class BridgeConfig {
})
}

if (this.provisioning?.port) {
this.listeners.push({
resources: ['provisioning'],
port: this.provisioning.port,
bindAddress: this.provisioning.bindAddress,
})
log.warn("The `provisioning` configuration still specifies a port/bindAddress. This should be moved to the `listeners` config.");
}

if (this.metrics?.port) {
this.listeners.push({
resources: ['metrics'],
Expand Down
5 changes: 1 addition & 4 deletions src/config/Defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ export const DefaultConfigRoot: BridgeConfigRoot = {
pollTimeoutSeconds: 30,
pollConcurrency: 4,
},
provisioning: {
secret: "!secretToken"
},
metrics: {
enabled: true,
},
Expand All @@ -141,7 +138,7 @@ export const DefaultConfigRoot: BridgeConfigRoot = {
{
port: 9001,
bindAddress: '127.0.0.1',
resources: ['metrics', 'provisioning'],
resources: ['metrics'],
},
{
port: 9002,
Expand Down
Loading
Loading