Skip to content

Commit 8383cd6

Browse files
committed
wip: cleanup
1 parent 6fd795c commit 8383cd6

File tree

14 files changed

+5
-955
lines changed

14 files changed

+5
-955
lines changed

meteor/server/security/README.md

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
11
import './lib/lib'
2-
3-
import './buckets'
4-
import './noSecurity'
5-
import './organization'
6-
import './peripheralDevice'
7-
import './rundown'
8-
import './rundownPlaylist'
9-
import './showStyle'
10-
import './studio'
11-
import './system'

meteor/server/security/buckets.ts

Lines changed: 0 additions & 80 deletions
This file was deleted.

meteor/server/security/lib/credentials.ts

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { User } from '@sofie-automation/meteor-lib/dist/collections/Users'
21
import { PeripheralDevice } from '@sofie-automation/corelib/dist/dataModel/PeripheralDevice'
32
import { cacheResult } from '../../lib/cacheResult'
43
import { LIMIT_CACHE_TIME } from './security'
@@ -12,12 +11,6 @@ export interface Credentials {
1211
token?: string
1312
}
1413

15-
/**
16-
* A minimal set of properties about the user.
17-
* We keep it small so that we don't cache too much in memory or have to invalidate the credentials when something insignificant changes
18-
*/
19-
export type ResolvedUser = Pick<User, '_id' | 'organizationId' | 'superAdmin'>
20-
2114
/**
2215
* A minimal set of properties about the OeripheralDevice.
2316
* We keep it small so that we don't cache too much in memory or have to invalidate the credentials when something insignificant changes
@@ -26,54 +19,9 @@ export type ResolvedPeripheralDevice = Pick<PeripheralDevice, '_id' | 'organizat
2619

2720
export interface ResolvedCredentials {
2821
organizationId: OrganizationId | null
29-
user?: ResolvedUser
22+
user?: any
3023
device?: ResolvedPeripheralDevice
3124
}
32-
export interface ResolvedUserCredentials {
33-
organizationId: OrganizationId
34-
user: ResolvedUser
35-
}
36-
export interface ResolvedPeripheralDeviceCredentials {
37-
organizationId: OrganizationId
38-
device: ResolvedPeripheralDevice
39-
}
40-
41-
/**
42-
* Resolve the provided credentials, and retrieve the PeripheralDevice and Organization for the provided credentials.
43-
* @returns null if the PeripheralDevice was not found
44-
*/
45-
export async function resolveAuthenticatedPeripheralDevice(
46-
cred: Credentials
47-
): Promise<ResolvedPeripheralDeviceCredentials | null> {
48-
const resolved = await resolveCredentials({ userId: null, token: cred.token })
49-
50-
if (resolved.device && resolved.organizationId) {
51-
return {
52-
organizationId: resolved.organizationId,
53-
device: resolved.device,
54-
}
55-
} else {
56-
return null
57-
}
58-
}
59-
60-
/**
61-
* Resolve the provided credentials, and retrieve the User and Organization for the provided credentials.
62-
* Note: this requies that the UserId came from a trusted source,it must not be from user input
63-
* @returns null if the user was not found
64-
*/
65-
export async function resolveAuthenticatedUser(cred: Credentials): Promise<ResolvedUserCredentials | null> {
66-
const resolved = await resolveCredentials({ userId: cred.userId })
67-
68-
if (resolved.user && resolved.organizationId) {
69-
return {
70-
organizationId: resolved.organizationId,
71-
user: resolved.user,
72-
}
73-
} else {
74-
return null
75-
}
76-
}
7725

7826
/**
7927
* Resolve the provided credentials/identifier, and fetch the authenticating document from the database.
@@ -152,7 +100,7 @@ export async function resolveCredentials(cred: Credentials | ResolvedCredentials
152100
function credCacheName(cred: Credentials) {
153101
return `resolveCredentials_${cred.userId}_${cred.token}`
154102
}
155-
export function isResolvedCredentials(cred: Credentials | ResolvedCredentials): cred is ResolvedCredentials {
103+
function isResolvedCredentials(cred: Credentials | ResolvedCredentials): cred is ResolvedCredentials {
156104
const c = cred as ResolvedCredentials
157105
return !!(c.user || c.organizationId || c.device)
158106
}

0 commit comments

Comments
 (0)