Skip to content

Commit

Permalink
feat: enable tenant check on AMT operations
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdmike committed Sep 21, 2023
1 parent 984e1af commit 907b29b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/middleware/cira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ const ciraMiddleware = async (req: Request, res: Response, next): Promise<void>
const device = devices[guid]

if ((device as any)?.ciraSocket.readyState === 'open') {
// const cred = await req.mpsService.secrets.getAMTCredentials(guid);
// req.amtStack = req.amtFactory.getAmtStack(guid, amtPort, cred[0], cred[1], 0)
// (req as any).httpHandler = new HttpHandler(cred[0], cred[1])
// if a tenantId is provided, ensure the request is for the same tenant/device
if (req.tenantId != null) {
if (req.tenantId !== device.tenantId) {
res.status(401).json(ErrorResponse(401, 'Unauthorized')).end()
return

Check warning on line 24 in src/middleware/cira.ts

View check run for this annotation

Codecov / codecov/patch

src/middleware/cira.ts#L23-L24

Added lines #L23 - L24 were not covered by tests
}
}

const ciraHandler = new CIRAHandler(device.httpHandler, device.username, device.password, device.limiter)
req.deviceAction = new DeviceAction(ciraHandler, device.ciraSocket)
Expand Down

0 comments on commit 907b29b

Please sign in to comment.