Skip to content

Commit c53124c

Browse files
committed
wip: fix
1 parent ad532a9 commit c53124c

File tree

5 files changed

+8
-15
lines changed

5 files changed

+8
-15
lines changed

meteor/server/api/heapSnapshot.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { fixValidPath } from '../lib/lib'
77
import { sleep } from '../lib/lib'
88
import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
99
import { logger } from '../logging'
10-
import { assertConnectionIsDeveloper, RequestCredentials } from '../security/auth'
10+
import { assertConnectionHasOneOfPermissions, RequestCredentials } from '../security/auth'
1111

1212
async function retrieveHeapSnapshot(cred: RequestCredentials): Promise<Readable> {
13-
assertConnectionIsDeveloper(cred)
13+
assertConnectionHasOneOfPermissions(cred, 'developer')
1414

1515
logger.warn('Taking heap snapshot, expect system to be unresponsive for a few seconds..')
1616
await sleep(100) // Allow the logger to catch up before continuing..

meteor/server/methods.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { extractFunctionSignature } from './lib'
55
import { MethodContext, MethodContextAPI } from './api/methodContext'
66
import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
77
import { isPromise } from '@sofie-automation/shared-lib/dist/lib/lib'
8-
import { assertConnectionIsDeveloper } from './security/auth'
8+
import { assertConnectionHasOneOfPermissions } from './security/auth'
99

1010
type MeteorMethod = (this: MethodContext, ...args: any[]) => any
1111

@@ -152,7 +152,7 @@ export function MeteorDebugMethods(methods: { [key: string]: MeteorDebugMethod }
152152
for (const [key, fn] of Object.entries<MeteorDebugMethod>(methods)) {
153153
if (key && !!fn) {
154154
fiberMethods[key] = function (this: Meteor.MethodThisType, ...args: any[]) {
155-
assertConnectionIsDeveloper(this.connection)
155+
assertConnectionHasOneOfPermissions(this.connection, 'developer')
156156

157157
return fn.call(this, ...args)
158158
}

meteor/server/security/auth.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ export function parseConnectionPermissions(conn: RequestCredentials): UserPermis
4040
return parseUserPermissions(header)
4141
}
4242

43-
export function assertConnectionIsDeveloper(conn: RequestCredentials | null): void {
44-
return assertConnectionHasOneOfPermissions(conn, 'developer')
45-
}
46-
4743
export function assertConnectionHasOneOfPermissions(
4844
conn: RequestCredentials | null,
4945
...allowedPermissions: Array<keyof UserPermissions>
@@ -52,10 +48,7 @@ export function assertConnectionHasOneOfPermissions(
5248

5349
triggerWriteAccess()
5450

55-
if (!conn) {
56-
// nocommit - this won't work nicely
57-
throw new Meteor.Error(403, 'Can only be invoked by clients')
58-
}
51+
if (!conn) throw new Meteor.Error(403, 'Can only be invoked by clients')
5952

6053
const permissions = parseConnectionPermissions(conn)
6154
for (const permission of allowedPermissions) {

meteor/server/systemStatus/systemStatus.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { MethodContext } from '../api/methodContext'
2525
import { getBlueprintVersions } from './blueprintVersions'
2626
import { getUpgradeSystemStatusMessages } from './blueprintUpgradeStatus'
2727
import { triggerWriteAccessBecauseNoCheckNecessary } from '../security/securityVerify'
28-
import { assertConnectionIsDeveloper, RequestCredentials } from '../security/auth'
28+
import { assertConnectionHasOneOfPermissions, RequestCredentials } from '../security/auth'
2929

3030
const PackageInfo = require('../../package.json')
3131
const integrationVersionRange = parseCoreIntegrationCompatabilityRange(PackageInfo.version)
@@ -388,6 +388,7 @@ export async function getDebugStates(
388388
methodContext: MethodContext,
389389
peripheralDeviceId: PeripheralDeviceId
390390
): Promise<object> {
391-
assertConnectionIsDeveloper(methodContext.connection)
391+
assertConnectionHasOneOfPermissions(methodContext.connection, 'developer')
392+
392393
return ServerPeripheralDeviceAPI.getDebugStates(peripheralDeviceId)
393394
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ export interface NewUserAPI {
66
export enum UserAPIMethods {
77
'getUserPermissions' = 'user.getUserPermissions',
88
}
9-

0 commit comments

Comments
 (0)