File tree Expand file tree Collapse file tree 5 files changed +8
-15
lines changed
packages/meteor-lib/src/api Expand file tree Collapse file tree 5 files changed +8
-15
lines changed Original file line number Diff line number Diff line change @@ -7,10 +7,10 @@ import { fixValidPath } from '../lib/lib'
77import { sleep } from '../lib/lib'
88import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
99import { logger } from '../logging'
10- import { assertConnectionIsDeveloper , RequestCredentials } from '../security/auth'
10+ import { assertConnectionHasOneOfPermissions , RequestCredentials } from '../security/auth'
1111
1212async 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..
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { extractFunctionSignature } from './lib'
55import { MethodContext , MethodContextAPI } from './api/methodContext'
66import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
77import { isPromise } from '@sofie-automation/shared-lib/dist/lib/lib'
8- import { assertConnectionIsDeveloper } from './security/auth'
8+ import { assertConnectionHasOneOfPermissions } from './security/auth'
99
1010type 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 }
Original file line number Diff line number Diff 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-
4743export 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 ) {
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import { MethodContext } from '../api/methodContext'
2525import { getBlueprintVersions } from './blueprintVersions'
2626import { getUpgradeSystemStatusMessages } from './blueprintUpgradeStatus'
2727import { triggerWriteAccessBecauseNoCheckNecessary } from '../security/securityVerify'
28- import { assertConnectionIsDeveloper , RequestCredentials } from '../security/auth'
28+ import { assertConnectionHasOneOfPermissions , RequestCredentials } from '../security/auth'
2929
3030const PackageInfo = require ( '../../package.json' )
3131const 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}
Original file line number Diff line number Diff line change @@ -6,4 +6,3 @@ export interface NewUserAPI {
66export enum UserAPIMethods {
77 'getUserPermissions' = 'user.getUserPermissions' ,
88}
9-
You can’t perform that action at this time.
0 commit comments