Skip to content

Commit 755826b

Browse files
committed
fix: handle permissions for ingest rundown status test tool with header auth properly
1 parent 12e4793 commit 755826b

File tree

5 files changed

+51
-21
lines changed

5 files changed

+51
-21
lines changed

meteor/server/publications/ingestStatus/publication.ts

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { PeripheralDeviceId, RundownId, RundownPlaylistId } from '@sofie-automation/corelib/dist/dataModel/Ids'
22
import { ReadonlyDeep } from 'type-fest'
33
import {
4+
CustomPublish,
45
CustomPublishCollection,
56
meteorCustomPublish,
67
setUpCollectionOptimizedObserver,
@@ -21,7 +22,8 @@ import { IngestRundownStatus } from '@sofie-automation/shared-lib/dist/ingest/ru
2122
import { protectString } from '@sofie-automation/corelib/dist/protectedString'
2223
import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
2324
import { createIngestRundownStatus } from './createIngestRundownStatus'
24-
import { Settings } from '../../Settings'
25+
import { assertConnectionHasOneOfPermissions } from '../../security/auth'
26+
import { MeteorPubSub } from '@sofie-automation/meteor-lib/dist/api/pubsub'
2527

2628
interface IngestRundownStatusArgs {
2729
readonly deviceId: PeripheralDeviceId
@@ -171,29 +173,45 @@ async function manipulateIngestRundownStatusPublicationData(
171173
}
172174
}
173175

176+
async function startOrJoinIngestStatusPublication(
177+
pub: CustomPublish<IngestRundownStatus>,
178+
deviceId: PeripheralDeviceId
179+
) {
180+
await setUpCollectionOptimizedObserver<
181+
IngestRundownStatus,
182+
IngestRundownStatusArgs,
183+
IngestRundownStatusState,
184+
IngestRundownStatusUpdateProps
185+
>(
186+
`pub_${PeripheralDevicePubSub.ingestDeviceRundownStatus}_${deviceId}`,
187+
{ deviceId },
188+
setupIngestRundownStatusPublicationObservers,
189+
manipulateIngestRundownStatusPublicationData,
190+
pub,
191+
100
192+
)
193+
}
194+
174195
meteorCustomPublish(
175196
PeripheralDevicePubSub.ingestDeviceRundownStatus,
176197
PeripheralDevicePubSubCollectionsNames.ingestRundownStatus,
177198
async function (pub, deviceId: PeripheralDeviceId, token: string | undefined) {
178199
check(deviceId, String)
179200

180-
if (Settings.enableHeaderAuth) {
181-
// This is used in a testTool, so only check when auth is enabled
182-
await checkAccessAndGetPeripheralDevice(deviceId, token, this)
183-
}
201+
await checkAccessAndGetPeripheralDevice(deviceId, token, this)
202+
203+
await startOrJoinIngestStatusPublication(pub, deviceId)
204+
}
205+
)
206+
207+
meteorCustomPublish(
208+
MeteorPubSub.ingestDeviceRundownStatusTestTool,
209+
PeripheralDevicePubSubCollectionsNames.ingestRundownStatus,
210+
async function (pub, deviceId: PeripheralDeviceId) {
211+
check(deviceId, String)
212+
213+
assertConnectionHasOneOfPermissions(this.connection, 'testing')
184214

185-
await setUpCollectionOptimizedObserver<
186-
IngestRundownStatus,
187-
IngestRundownStatusArgs,
188-
IngestRundownStatusState,
189-
IngestRundownStatusUpdateProps
190-
>(
191-
`pub_${PeripheralDevicePubSub.ingestDeviceRundownStatus}_${deviceId}`,
192-
{ deviceId },
193-
setupIngestRundownStatusPublicationObservers,
194-
manipulateIngestRundownStatusPublicationData,
195-
pub,
196-
100
197-
)
215+
await startOrJoinIngestStatusPublication(pub, deviceId)
198216
}
199217
)

packages/meteor-lib/src/api/pubsub.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
BucketId,
33
OrganizationId,
44
PartId,
5+
PeripheralDeviceId,
56
RundownId,
67
RundownPlaylistActivationId,
78
RundownPlaylistId,
@@ -122,6 +123,11 @@ export enum MeteorPubSub {
122123
*/
123124
timelineForStudio = 'timelineForStudio',
124125

126+
/**
127+
* Ingest status of rundowns for a PeripheralDevice
128+
*/
129+
ingestDeviceRundownStatusTestTool = 'ingestDeviceRundownStatusTestTool',
130+
125131
/**
126132
* Fetch the simplified playout UI view of the specified ShowStyleBase
127133
*/
@@ -228,6 +234,11 @@ export interface MeteorPubSubTypes {
228234
studioId: StudioId,
229235
token?: string
230236
) => PeripheralDevicePubSubCollectionsNames.studioTimeline
237+
238+
[MeteorPubSub.ingestDeviceRundownStatusTestTool]: (
239+
peripheralDeviceId: PeripheralDeviceId
240+
) => PeripheralDevicePubSubCollectionsNames.ingestRundownStatus
241+
231242
[MeteorPubSub.uiShowStyleBase]: (showStyleBaseId: ShowStyleBaseId) => CustomCollectionName.UIShowStyleBase
232243
/** Subscribe to one or all studios */
233244
[MeteorPubSub.uiStudio]: (studioId: StudioId | null) => CustomCollectionName.UIStudio

packages/webui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"homepage": "https://github.com/nrkno/sofie-core/blob/master/packages/webui#readme",
1616
"scripts": {
17-
"dev": "vite --port=3005",
17+
"dev": "vite --port=3005 --force",
1818
"build": "tsc -b && vite build",
1919
"build:main": "tsc -p tsconfig.app.json --noEmit",
2020
"check-types": "tsc -p tsconfig.app.json --noEmit",

packages/webui/src/client/ui/TestTools/IngestRundownStatus.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { useSubscription, useTracker } from '../../lib/ReactMeteorData/react-met
22
import { unprotectString } from '../../lib/tempLib'
33
import { makeTableOfObject } from '../../lib/utilComponents'
44
import { PeripheralDeviceId } from '@sofie-automation/corelib/dist/dataModel/Ids'
5-
import { PeripheralDevicePubSub } from '@sofie-automation/shared-lib/dist/pubsub/peripheralDevice'
65
import { useTranslation } from 'react-i18next'
76
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
87
import { PeripheralDevices } from '../../collections'
98
import { Link } from 'react-router-dom'
109
import { PeripheralDeviceCategory } from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI'
1110
import { IngestRundownStatuses } from './collections'
1211
import { IngestPartStatus, IngestRundownStatus } from '@sofie-automation/shared-lib/dist/ingest/rundownStatus'
12+
import { MeteorPubSub } from '@sofie-automation/meteor-lib/dist/api/pubsub'
1313

1414
interface IMappingsViewProps {
1515
match?: {
@@ -39,7 +39,7 @@ interface ComponentMappingsTableProps {
3939
peripheralDeviceId: PeripheralDeviceId
4040
}
4141
function ComponentMappingsTable({ peripheralDeviceId }: Readonly<ComponentMappingsTableProps>): JSX.Element {
42-
useSubscription(PeripheralDevicePubSub.ingestDeviceRundownStatus, peripheralDeviceId)
42+
useSubscription(MeteorPubSub.ingestDeviceRundownStatusTestTool, peripheralDeviceId)
4343

4444
const rundowns = useTracker(() => IngestRundownStatuses.find({}).fetch(), [], [])
4545

packages/webui/vite.config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export default defineConfig({
7272
ws: true,
7373
},
7474
},
75+
allowedHosts: true,
7576
},
7677

7778
// TODO: old meteor recompile instructions?

0 commit comments

Comments
 (0)