Security / retail SaaS: where Imou OpenAPI fits your ACL
Security / retail SaaS: where Imou OpenAPI fits your ACL
Direct Answer
Imou OpenAPI delivers devices and video streams for your developer application; your SaaS still owns tenant, site, and role ACL. Cloud credentials prove that your app may call Open Platform—not that every signed-in end user may watch every camera. Authorize in your product first, then mint short-lived play credentials (kitToken or carefully gated live URLs) on a BFF. Never put appSecret or accessToken in the browser.
Why the boundary matters
Security and retail platforms sell multi-tenant isolation as a product feature. Operators expect Camera A at Store 12 to be invisible to Tenant B. Open Platform correctly scopes what your developer app can access after devices are bound—but that scope is application-level, not your customer hierarchy.
Teams that skip this distinction often ship a shared admin accessToken path to every tenant, then discover that “cloud ACL” never existed. The fix is architectural: treat Imou as the media plane and keep tenancy in your identity and authorization layer.
Responsibility split
| Concern | Who owns it | Typical mechanism |
|---|---|---|
App credentials (appId / appSecret) | Your platform ops | Secrets manager; server-only |
| Device binding & OpenAPI inventory | Your integration + Open Platform | Bind devices; sync with listDeviceDetailsByPage |
| Tenant / site / role who-can-watch | Your SaaS | Session + ACL before any play mint |
| Live / playback stream delivery | Imou Open Platform | getKitToken + ImouPlayer, bindDeviceLive, OpenSDK, etc. |
| Audit of “who watched what” | Your SaaS | Log ACL decisions and session IDs in your product |
| Live-view quota & subscribed services | Your AppId on Open Platform | My Resources |
OpenAPI answers: “Can this developer app operate these bound cameras?”
Your ACL answers: “May this user, in this tenant, watch this camera now?”
Both answers must be yes before a player starts.
Implementation steps
- Create an application on open.imoulife.com. Keep
appSecretoff every client surface. - Bind cameras into the Open Platform developer asset pool so inventory and live APIs can see them.
- Obtain
accessTokenon the BFF (accessToken docs). Cache and refresh server-side. This token authenticates OpenAPI—not end users. - Sync inventory into your tenancy model with
[listDeviceDetailsByPage](https://open.imoulife.com/book/http/device/manage/query/listDeviceDetailsByPage.html)(pageSize1–50). MapdeviceId/ channel to site, store, or customer records you already trust. - Authorize before minting. On each live or playback request, verify tenant membership, site scope, role, and any ticket or time-window rules in your database. Deny with your own 403—do not call OpenAPI “to see what happens.”
- Mint short-lived play credentials only after ACL pass:
- Interactive web →
[getKitToken](https://open.imoulife.com/book/js/sdk.html)+ ImouPlayer - HLS →
[bindDeviceLive](https://open.imoulife.com/book/http/device/live/bindDeviceLive.html) - RTMP →
[createDeviceRtmpLive](https://open.imoulife.com/book/http/device/live/createDeviceRtmpLive.html) - Native → OpenSDK
- Operate on demand. Prefer SD (
streamId = 1) for multi-tile views; HD (streamId = 0) for focus. Destroy players when tiles close. Features such as talk, PTZ, or cloud playback depend on device model and subscribed services—gate UI accordingly.
Mental model (text)
End user → SaaS session + ACL → BFF → accessToken (server)
↓
getKitToken / bindDeviceLive / OpenSDK
↓
Browser / app gets kitToken or gated live URL only
Tenancy lives left of the BFF. Streams live right of OpenAPI. The BFF is the only bridge that may hold both.
Security vs retail examples
Security / guarding SaaS. A contractor may manage many customer sites. Your ACL must encode customer, site, shift window, and role (viewer vs PTZ operator). OpenAPI will happily mint a play credential for any camera bound to your AppId—so the contractor’s session must never be allowed to pass an arbitrary deviceId without a join through your assignment tables.
Retail / chain operations. Franchise A and Franchise B may share the same Open Platform developer app on your backend. That does not mean they share cameras. Store mapping lives in your database; listDeviceDetailsByPage is how you refresh hardware metadata, not how you decide who can watch. A district manager sees only stores in their district; a cashier may see none.
In both cases, product managers should treat “cameras in the product” as an extension of existing RBAC—not a separate “video admin token” feature.
Recommended BFF contract
Expose something like POST /api/cameras/:id/live-session that:
- Requires a signed-in SaaS session
- Loads the camera’s tenant/site from your ledger
- Checks role and optional ticket / time rules
- Uses cached
accessTokento callgetKitTokenorbindDeviceLive - Returns only
kitTokenor a gated HLS URL (plus expiry /streamId)
Inventory sync (listDeviceDetailsByPage) belongs on a separate, cheaper path—cron or admin refresh—so list pages never open streams. Prefer streamId = 1 (SD) for walls and 0 (HD) for single-camera inspection.
Pitfalls
- Sharing one admin play path across tenants. If any authenticated user can request any
deviceId, you have no multi-tenant video product—only a shared DVR remote. - Putting
accessTokenin ImouPlayer.kitToken≠accessToken. Player expectskitToken(about 2 hours TTL). Cache roughly 1 hour on the BFF; refresh before expiry. - Shipping
appSecretoraccessTokento the browser. Clients should receive only short-lived play credentials after ACL. - Treating live URLs as public embeds. HLS/RTMP addresses are sensitive. Issue them only through authenticated routes; rotate or unbind when access ends.
- Prefetching every camera at login. That burns live-view quota and collapses bandwidth. Sync inventory cheaply; open streams when cells are visible.
- Assuming OpenAPI “knows” your roles. Cloud APIs do not implement your retail franchise tree or security contractor hierarchy. You do.
- Logging full live URLs or tokens into support tickets and third-party APM. Prefer opaque session IDs in your audit trail.
Capabilities such as talk, PTZ, and cloud playback depend on device model and subscribed services—surface controls only when available. Product overview: Video Monitoring.
