Permissions

Control who can access channels and user metadata in your chat app. Define permission schemas to protect against unauthorized access.

Examples:

  • Restrict channel/profile modifications to specific users
  • Allow only admins to remove users from channels

Chat SDK limitations (client-side only):

  • Channel membership restrictions (direct, group, public)
  • Feature availability errors in public chats (typing indicator, invites, read receipts)

Use Access Manager for strict server-enforced access rules. Chat SDK exposes all Unity SDK Access Manager methods.

Required configuration​

  1. Enable Access Manager in the Admin Portal.
  2. Initialize Chat SDK:
    • Server: with SecretKey to administer permissions
    • Client: with AuthKey to authenticate users

See Moderation for examples.

Secret key security

Never expose SecretKey to clients. If compromised, generate a new one in the Admin Portal.

Use Access Manager​

Available methods:

Channel group limitation

Chat SDK doesn't support channel groups. Use a core SDK for channel groups.

Resource permissions​

Define operations users can perform on PubNub resources:

Resource typePermissions
ChannelsRead, Write, Get, Manage, Update, Join, Delete
UuidsGet, Update, Delete

See Moderation for muting/banning with Access Manager.

Operations-to-permissions mapping​

Access levels determine user operations. Example: Write on Channels allows sending messages via SendText().

The tables below map permissions to Chat SDK operations.

Pub/Sub​

PubNub operationResource type(s)PermissionUnity Chat SDK method(s)
Publish on channelsChannelsWriteSend text messages (SendText())

Forward messages (Forward(), ForwardMessage())

Create and send events (EmitCustomEvent())

Report messages (Report())
Send signals to channelsChannelsWriteTyping indicator methods

Create and send events (EmitCustomEvent())
Subscribe to channelsChannelsReadTyping indicator methods

Receive events (SetListeningForUpdates())

Receive messages (Connect())

Membership updates (OnUpdated)

Channel updates (Update(), UpdateChannel())

Messages updates (OnUpdated)

User updates (OnUpdated)
Subscribe to presence channelsPresence channels (<channel-name>-pnpres)Readn/a
Unsubscribe from channelsChannelsNone requiredStop receiving typing signals, events, messages, updates on membership, channels, messages, and users

Presence​

PubNub operationResource type(s)PermissionUnity Chat SDK method(s)
Here NowChannelsReadChannel presence (WhoIsPresent())
Where NowChannelsNone requiredChannel presence (WherePresent(), IsPresentOn(), IsPresent())

Message Persistence​

PubNub operationResource type(s)PermissionUnity Chat SDK method(s)
Fetch historical messagesChannelsReadgetMessageHistory()
Message countsChannelsReadUnread messages (GetUnreadMessagesCount(), GetUnreadMessagesCounts())
Delete messagesChannelsDeleteDelete()

App Context​

PubNub operationResource type(s)PermissionUnity Chat SDK method(s)
Set user metadataUuidsUpdateCreate users (CreateUser())

Update user metadata (Update(), UpdateUser())
Delete user metadataUuidsDeleteDeleteUser()
Get user metadataUuidsGetGet user data (GetUser())
Get all user metadataUuidsYou don't need to specify permissions to enable it if you uncheck the Disallow Get All User Metadata option in the App Context configuration in the Admin Portal.chat.GetUsers()
Set channel metadataChannels

When working with threads, also grant permissions to PUBNUB_INTERNAL_THREAD channels.
Update, GetCreate channels (CreateDirectConversation(), CreateGroupConversation(), CreatePublicConversation())

Update channels (Update(), UpdateChannel())

Pin messages (Pin(), PinMessage())

Threads (CreateThread(), PinMessage(), PinMessageToParentChannel(), UnpinMessage(), UnpinMessageFromParentChannel())
Delete channel metadataChannelsDeleteDelete(), DeleteChannel()
Get channel metadataChannelsGetGet channel details (GetChannel())

Get pinned messages (GetPinnedMessage())

Get thread (GetThread())
Get all channel metadataChannelsYou don't need to specify permissions to enable it if you uncheck the Disallow Get All Channel Metadata option in the App Context configuration in the Admin Portal.chat.GetChannels()
Set channel membersChannelsManageInvite multiple users to channels (InviteMultiple())

Mute/Ban users (SetRestriction())
Remove channel membersChannelsManageUnmute/Unban users (SetRestriction())
Get channel membersChannelsGetGet members (GetMemberships())

Check restrictions (GetUserRestriction(), GetUsersRestrictions(), GetChannelsRestrictions(), GetChannelRestriction())
Set channel membershipsChannels, UuidsJoin on Channels
Update on Uuids
Create channels (CreateDirectConversation(), CreateGroupConversation())

Invite a user to a channel (Invite())

Join channels (Join())

Update membership (Update())

Unread messages (SetLastReadMessage(), MarkAllMessagesAsRead())
Remove channel membershipsChannels, UuidsJoin on Channels
Update on Uuids
Leave channels (Leave())
Get channel membershipsUuidsGetList channels (GetChannels()), GetMemberships()

Message Reactions​

PubNub operationResource type(s)PermissionUnity Chat SDK method(s)
Add message reactionChannelsWriteToggleReaction()
Remove message reactionChannelsDeleteToggleReaction()
Get history with reactionsChannelsReadgetMessageHistory()

Was this page useful?

Last updated on