Access Manager v3 API for POSIX C SDK (legacy)
New SDK available
The POSIX C SDK is built on C-Core (legacy), which is still supported. If you are starting a new project, use the new C SDK.
Access Manager isn't enabled by default
Access Manager allows you to enforce security controls for client access to resources within the PubNub Platform. With Access Manager v3, your servers (that use a PubNub instance configured with a secret key) can grant their clients tokens with embedded permissions that provide access to individual PubNub resources:
- For a limited period of time.
- Through resource lists or patterns (regular expressions).
- In a single API request, even if permission levels differ (
readtochannel1andwritetochannel2).
You can add the author_uuid parameter to the grant request to restrict token usage to one client with a given UUID. Only this author_uuid can use the token to make API requests for the specified resources and permissions.
For more information about Access Manager v3, refer to Manage Permissions with Access Manager v3.
Grant token
Requires Access Manager add-on
This method requires that the Access Manager add-on is enabled for your key in the Admin Portal. See Enable the features your app calls.
Requires Secret Key authentication
Granting permissions to resources should be done by administrators whose SDK instance has been initialized with a Secret Key (available on the Admin Portal on your app's keyset).
The pubnub_grant_token() method generates a time-limited authorization token with an embedded access control list. The token defines time to live (ttl_minutes), author_uuid, and a set of permissions giving access to one or more resources:
channelsgroupsuuids(other users' object metadata, such as their names or avatars)
Only this author_uuid will be able to use the token with the defined permissions. The authorized client will send the token to PubNub with each request until the token's ttl_minutes expires. Any unauthorized request or a request made with an invalid token will return a 403 with a respective error message.
#
The grant request allows your server to securely grant your clients access to the resources within the PubNub Platform. There is a limited set of operations the clients can perform on every resource:
| Resource | Permissions |
|---|---|
channels | read, write, get, manage, update, join, delete |
groups | read, manage |
uuids | get, update, delete |
For permissions and API operations mapping, refer to Manage Permissions with Access Manager v3.
#
The ttl_minutes (time to live) parameter defines how many minutes the permissions remain valid. After expiration, the client must get a new token to maintain access. ttl_minutes is required for every grant call. There is no default value. The maximum value is 43,200 (30 days).
For more details, see TTL in Access Manager v3.
#
Use regular expressions (RegEx) to specify permissions by pattern instead of listing each resource. Define RegEx permissions for a given resource type in the grant request. Patterns are evaluated on the server using RE2-style syntax; backreferences and lookaround assertions are not supported.
For more details, see RegEx in Access Manager v3.