Secure PubNub applications with Access Manager, encryption, and TLS
Does it follow best practices?
Evaluation — 95%
↑ 1.13xAgent success when using this tile
Validation for skill structure
A B2B SaaS company provides a real-time collaboration platform where each tenant (company) has its own workspace with channels for teams, direct messages between users, and an admin panel for workspace managers. They need a server-side Node.js module that manages PubNub access control for their multi-role system.
The platform has four roles: "guest" (can only view public announcements), "member" (can participate in team channels), "manager" (can also access analytics and manage team memberships), and "owner" (has full access including billing and admin channels). Each tenant's channels are prefixed with the tenant ID to ensure isolation.
The team wants a module that, given a user's role and tenant ID, issues the appropriate PubNub credentials with exactly the right level of access -- no more, no less. They want it to scale well as the number of channels per tenant grows.
Create a file called access-control.js containing:
initializePubNub() that creates and returns the server-side PubNub instanceissueCredentials(tenantId, userId, role) that issues PubNub credentials appropriate for the given rolerevokeAccess(token) that revokes a previously issued tokenAlso create a file called channel-design.md documenting the channel naming scheme and which roles can access which channel patterns.