Skip to content

Commit 573389a

Browse files
committed
fix: handle permissions for ingest rundown status test tool with header auth properly
1 parent 6f1afc4 commit 573389a

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,
@@ -130,6 +131,11 @@ export enum MeteorPubSub {
130131
*/
131132
timelineForStudio = 'timelineForStudio',
132133

134+
/**
135+
* Ingest status of rundowns for a PeripheralDevice
136+
*/
137+
ingestDeviceRundownStatusTestTool = 'ingestDeviceRundownStatusTestTool',
138+
133139
/**
134140
* Fetch the simplified playout UI view of the specified ShowStyleBase
135141
*/
@@ -236,6 +242,11 @@ export interface MeteorPubSubTypes {
236242
studioId: StudioId,
237243
token?: string
238244
) => PeripheralDevicePubSubCollectionsNames.studioTimeline
245+
246+
[MeteorPubSub.ingestDeviceRundownStatusTestTool]: (
247+
peripheralDeviceId: PeripheralDeviceId
248+
) => PeripheralDevicePubSubCollectionsNames.ingestRundownStatus
249+
239250
[MeteorPubSub.uiShowStyleBase]: (showStyleBaseId: ShowStyleBaseId) => CustomCollectionName.UIShowStyleBase
240251
/** Subscribe to one or all studios */
241252
[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
@@ -65,6 +65,7 @@ export default defineConfig({
6565
ws: true,
6666
},
6767
},
68+
allowedHosts: true,
6869
},
6970

7071
// TODO: old meteor recompile instructions?

0 commit comments

Comments
 (0)