feat(auth): separate browser preview control permissions (#9789)
Co-authored-by: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
321c6f9d26
commit
7175edcff4
26 files changed
+476
-82
No files matched your search
@@ -9,6 +9,7 @@ import {
|
||||
AuthOrchestrationOperateScope,
|
||||
AuthOrchestrationReadScope,
|
||||
AuthSourceControlWriteScope,
|
||||
AuthPreviewOperateScope,
|
||||
AuthRelayReadScope,
|
||||
AuthRelayWriteScope,
|
||||
WS_METHODS,
|
||||
@@ -138,6 +139,28 @@ describe("RPC authorization scopes", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("separates preview control from observation", () => {
|
||||
for (const method of [
|
||||
WS_METHODS.previewOpen,
|
||||
WS_METHODS.previewNavigate,
|
||||
WS_METHODS.previewResize,
|
||||
WS_METHODS.previewRefresh,
|
||||
WS_METHODS.previewClose,
|
||||
WS_METHODS.previewReportStatus,
|
||||
WS_METHODS.previewAdjust,
|
||||
WS_METHODS.previewClearProfile,
|
||||
]) {
|
||||
expect(requiredScopeForRpcMethod(method)).toBe(AuthPreviewOperateScope);
|
||||
}
|
||||
for (const method of [
|
||||
WS_METHODS.previewList,
|
||||
WS_METHODS.subscribePreviewEvents,
|
||||
WS_METHODS.subscribeDiscoveredLocalServers,
|
||||
]) {
|
||||
expect(requiredScopeForRpcMethod(method)).toBe(AuthOrchestrationReadScope);
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects unknown RPC method names", () => {
|
||||
for (const method of ["server.notRegistered", "toString", "constructor"]) {
|
||||
expect(() => requiredScopeForRpcMethod(method)).toThrow(
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
AuthFilesystemWriteScope,
|
||||
AuthOrchestrationOperateScope,
|
||||
AuthOrchestrationReadScope,
|
||||
AuthPreviewOperateScope,
|
||||
AuthRelayReadScope,
|
||||
AuthRelayWriteScope,
|
||||
AuthTerminalOperateScope,
|
||||
@@ -167,15 +168,15 @@ export const RPC_REQUIRED_SCOPES = {
|
||||
[WS_METHODS.terminalClose]: AuthTerminalOperateScope,
|
||||
[WS_METHODS.subscribeTerminalEvents]: AuthTerminalOperateScope,
|
||||
[WS_METHODS.subscribeTerminalMetadata]: AuthTerminalOperateScope,
|
||||
[WS_METHODS.previewOpen]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.previewNavigate]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.previewResize]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.previewAdjust]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.previewRefresh]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.previewClose]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.previewOpen]: AuthPreviewOperateScope,
|
||||
[WS_METHODS.previewNavigate]: AuthPreviewOperateScope,
|
||||
[WS_METHODS.previewResize]: AuthPreviewOperateScope,
|
||||
[WS_METHODS.previewAdjust]: AuthPreviewOperateScope,
|
||||
[WS_METHODS.previewRefresh]: AuthPreviewOperateScope,
|
||||
[WS_METHODS.previewClose]: AuthPreviewOperateScope,
|
||||
[WS_METHODS.previewList]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.previewClearProfile]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.previewReportStatus]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.previewClearProfile]: AuthPreviewOperateScope,
|
||||
[WS_METHODS.previewReportStatus]: AuthPreviewOperateScope,
|
||||
[WS_METHODS.subscribePreviewEvents]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.subscribeDiscoveredLocalServers]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.deviceConfigure]: AuthSettingsWriteScope,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { expect, it } from "@effect/vitest";
|
||||
import {
|
||||
AuthOrchestrationOperateScope,
|
||||
EnvironmentId,
|
||||
PreviewAutomationClientDisconnectedError,
|
||||
PreviewAutomationInvalidSelectorError,
|
||||
@@ -11,15 +10,12 @@ import {
|
||||
PreviewTabId,
|
||||
ProviderInstanceId,
|
||||
ThreadId,
|
||||
WS_METHODS,
|
||||
WsRpcGroup,
|
||||
type PreviewAutomationHost,
|
||||
type PreviewAutomationRequest,
|
||||
type PreviewAutomationStreamEvent,
|
||||
SERVER_BROWSER_AUTOMATION_CLIENT_ID,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Exit from "effect/Exit";
|
||||
import * as Deferred from "effect/Deferred";
|
||||
import * as Fiber from "effect/Fiber";
|
||||
@@ -27,10 +23,7 @@ import * as Result from "effect/Result";
|
||||
import * as Scheduler from "effect/Scheduler";
|
||||
import * as Stream from "effect/Stream";
|
||||
import * as TestClock from "effect/testing/TestClock";
|
||||
import * as RpcGroup from "effect/rpc/RpcGroup";
|
||||
import * as RpcTest from "effect/rpc/RpcTest";
|
||||
|
||||
import * as RpcAuthorization from "../auth/RpcAuthorization.ts";
|
||||
import * as PreviewAutomationBroker from "./PreviewAutomationBroker.ts";
|
||||
|
||||
const makeBroker = PreviewAutomationBroker.make.pipe(Effect.provide(NodeServices.layer));
|
||||
|
||||
Reference in new issue
Block a user