Autoapprove Element Call oidc requests (#11209)

* autoapprove Element Call oidc requests

Signed-off-by: Timo K <toger5@hotmail.de>

* update comment

Signed-off-by: Timo K <toger5@hotmail.de>

* add tests for oidc element-call

Signed-off-by: Timo K <toger5@hotmail.de>

* fix ES lint

Signed-off-by: Timo K <toger5@hotmail.de>

---------

Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
Timo 2023-07-10 17:06:58 +02:00 committed by GitHub
parent ab972ddea9
commit 58710d129d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View file

@ -165,6 +165,14 @@ export class StopGapWidgetDriver extends WidgetDriver {
WidgetEventCapability.forToDeviceEvent(EventDirection.Receive, eventType).raw,
);
}
// To always allow OIDC requests for element call, the widgetPermissionStore is used:
SdkContextClass.instance.widgetPermissionStore.setOIDCState(
forWidget,
forWidgetKind,
inRoomId,
OIDCState.Allowed,
);
}
}

View file

@ -16,7 +16,7 @@ limitations under the License.
import { mocked } from "jest-mock";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { Widget, WidgetKind } from "matrix-widget-api";
import { MatrixWidgetType, Widget, WidgetKind } from "matrix-widget-api";
import { OIDCState, WidgetPermissionStore } from "../../../src/stores/widgets/WidgetPermissionStore";
import SettingsStore from "../../../src/settings/SettingsStore";
@ -24,6 +24,7 @@ import { TestSdkContext } from "../../TestSdkContext";
import { SettingLevel } from "../../../src/settings/SettingLevel";
import { SdkContextClass } from "../../../src/contexts/SDKContext";
import { stubClient } from "../../test-utils";
import { StopGapWidgetDriver } from "../../../src/stores/widgets/StopGapWidgetDriver";
jest.mock("../../../src/settings/SettingsStore");
@ -38,6 +39,12 @@ describe("WidgetPermissionStore", () => {
type: "m.custom",
url: "https://invalid.address.here",
});
const elementCallWidget = new Widget({
id: "group_call",
creatorUserId: "@alice:example.org",
type: MatrixWidgetType.Custom,
url: "https://call.element.io",
});
let settings: Record<string, any> = {}; // key value store
beforeEach(() => {
@ -92,4 +99,10 @@ describe("WidgetPermissionStore", () => {
const store2 = context.widgetPermissionStore;
expect(store2).toStrictEqual(store);
});
it("auto-approves OIDC requests for element-call", async () => {
new StopGapWidgetDriver([], elementCallWidget, WidgetKind.Room, true, roomId);
expect(widgetPermissionStore.getOIDCState(elementCallWidget, WidgetKind.Room, roomId)).toEqual(
OIDCState.Allowed,
);
});
});