You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Wildcard roles (e.g., `webpubsub.sendToGroups.<pattern>`) are not supported in REST APIs or server SDKs during runtime yet. This feature will be supported in a future update.
@@ -3,7 +3,7 @@ title: How to generate client access URL for Azure Web PubSub clients
3
3
description: How to generate client access URL for Azure Web PubSub clients.
4
4
author: vicancy
5
5
ms.author: lianwei
6
-
ms.date: 09/06/2024
6
+
ms.date: 10/17/2024
7
7
ms.service: azure-web-pubsub
8
8
ms.topic: how-to
9
9
---
@@ -40,66 +40,45 @@ The same Client Access URL can be generated by using the Web PubSub server SDK.
40
40
41
41
2. Generate Client Access URL by calling `WebPubSubServiceClient.getClientAccessToken`:
42
42
43
-
- Generate client access token
44
-
45
-
```js
46
-
// for web pubsub native clients
47
-
let token =awaitserviceClient.getClientAccessToken();
43
+
- Generate client access token
48
44
49
-
// for mqtt clients
50
-
let token =awaitserviceClient.getClientAccessToken({ clientProtocol:"mqtt" });
51
-
```
52
-
53
-
- Configure user ID
45
+
```js
46
+
// for web pubsub native clients
47
+
let token =awaitserviceClient.getClientAccessToken();
54
48
55
-
```js
56
-
let token = await serviceClient.getClientAccessToken({ userId: "user1" });
57
-
```
58
-
59
-
- Configure the lifetime of the token
60
-
61
-
```js
62
-
let token = await serviceClient.getClientAccessToken({
63
-
expirationTimeInMinutes: 5,
64
-
});
65
-
```
49
+
// for mqtt clients
50
+
let token =awaitserviceClient.getClientAccessToken({ clientProtocol:"mqtt" });
51
+
```
66
52
67
-
- Configure a role that can join group `group1` directly when it connects using this Client Access URL
53
+
- Configure user ID
68
54
69
-
```js
70
-
let token = await serviceClient.getClientAccessToken({
71
-
roles: ["webpubsub.joinLeaveGroup.group1"],
72
-
});
73
-
```
55
+
```js
56
+
let token = await serviceClient.getClientAccessToken({ userId: "user1" });
57
+
```
74
58
75
-
- Configure a role that the client can send messages to group `group1` directly when it connects using this Client Access URL
59
+
- Configure the lifetime of the token
76
60
77
-
```js
78
-
let token = await serviceClient.getClientAccessToken({
79
-
roles: ["webpubsub.sendToGroup.group1"],
80
-
});
81
-
```
61
+
```js
62
+
let token = await serviceClient.getClientAccessToken({
63
+
expirationTimeInMinutes: 5,
64
+
});
65
+
```
82
66
83
-
- Configure pattern roles to cover many groups
67
+
- Configure role(s) of the client when it connects using this Client Access URL. For additional roles that can be assigned, refer to [Permissions](./concept-client-protocols.md#permissions).
84
68
85
-
```js
86
-
let token = await serviceClient.getClientAccessToken({
87
-
roles: [
88
-
// send to any group under clientA/
89
-
"webpubsub.sendToGroups.clientA/**",
90
-
// join/leave any direct child of clientA/public/
91
-
"webpubsub.joinLeaveGroups.clientA/public/*"
92
-
]
93
-
});
94
-
```
69
+
```js
70
+
let token = await serviceClient.getClientAccessToken({
71
+
roles: ["webpubsub.joinLeaveGroup.group1"], // This role allows the client to join and leave "group1"
72
+
});
73
+
```
95
74
96
-
- Configure a group `group1` that the client joins once it connects using this Client Access URL
75
+
- Configure a group `group1` that the client joins once it connects using this Client Access URL
97
76
98
-
```js
99
-
let token = await serviceClient.getClientAccessToken({
100
-
groups: ["group1"],
101
-
});
102
-
```
77
+
```js
78
+
let token = await serviceClient.getClientAccessToken({
79
+
groups: ["group1"],
80
+
});
81
+
```
103
82
104
83
# [C#](#tab/csharp)
105
84
@@ -129,24 +108,12 @@ The same Client Access URL can be generated by using the Web PubSub server SDK.
129
108
var url = service.GetClientAccessUri(expiresAfter: TimeSpan.FromMinutes(5));
130
109
```
131
110
132
-
- Configure a role that can join group `group1` directly when it connects using this Client Access URL
111
+
- Configure roles assigned to the client when it connects using this Client Access URL. For additional roles that can be assigned, refer to [Permissions](./concept-client-protocols.md#permissions).
133
112
134
113
```csharp
135
-
var url = service.GetClientAccessUri(roles: new string[] { "webpubsub.joinLeaveGroup.group1" });
136
-
```
137
-
138
-
- Configure a role that the client can send messages to group `group1` directly when it connects using this Client Access URL
139
-
140
-
```csharp
141
-
var url = service.GetClientAccessUri(roles: new string[] { "webpubsub.sendToGroup.group1" });
142
-
```
143
-
144
-
- Configure pattern roles to cover many groups
145
-
146
-
```csharp
147
-
var url = service.GetClientAccessUri(roles: new [] {
148
-
"webpubsub.sendToGroups.clientA/**",
149
-
"webpubsub.joinLeaveGroups.clientA/public/*"
114
+
var url = service.GetClientAccessUri(roles: new string[] {
115
+
"webpubsub.joinLeaveGroup.group1", // This role allows the client to join and leave "group1"
116
+
"webpubsub.sendToGroup.group1" // This role allows the client to send messages to "group1"
150
117
});
151
118
```
152
119
@@ -184,24 +151,12 @@ The same Client Access URL can be generated by using the Web PubSub server SDK.
- Configure roles assigned to the client when it connects using this Client Access URL. For additional roles that can be assigned, refer to [Permissions](./concept-client-protocols.md#permissions).
200
155
201
156
```python
202
157
token = service.get_client_access_token(roles=[
203
-
"webpubsub.sendToGroups.clientA/**",
204
-
"webpubsub.joinLeaveGroups.clientA/public/*"
158
+
"webpubsub.joinLeaveGroup.group1", # This role allows the client to join and leave "group1"
159
+
"webpubsub.sendToGroup.group1" # This role allows the client to send messages to "group1"
205
160
])
206
161
```
207
162
@@ -248,28 +203,12 @@ The same Client Access URL can be generated by using the Web PubSub server SDK.
- Configure roles assigned to the client when it connects using this Client Access URL. For additional roles that can be assigned, refer to [Permissions](./concept-client-protocols.md#permissions).
268
207
269
208
```java
270
209
GetClientAccessTokenOptions option = new GetClientAccessTokenOptions();
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/includes/reference-permission.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,4 +20,7 @@ A PubSub WebSocket client can only publish to other clients when it's authorized
20
20
| `webpubsub.joinLeaveGroups.<pattern>` | The client can join/leave any group whose name matches `<pattern>` (see [Wildcard group role patterns](../concept-wildcard-group-roles.md)).
21
21
| `webpubsub.sendToGroups.<pattern>` | The client can publish messages to any group whose name matches `<pattern>` (see [Wildcard group role patterns](../concept-wildcard-group-roles.md)).
22
22
23
-
The server can dynamically grant or revoke client permissions through REST APIs or server SDKs.
23
+
The server can dynamically grant or revoke client permissions through REST APIs or server SDKs.
24
+
25
+
> [!NOTE]
26
+
> Wildcard roles (e.g., `webpubsub.sendToGroups.<pattern>`) are not supported in REST APIs or server SDKs during runtime yet.
0 commit comments