Skip to content

Commit 861120d

Browse files
committed
fix
1 parent 5550fd6 commit 861120d

4 files changed

Lines changed: 64 additions & 112 deletions

File tree

articles/azure-web-pubsub/concept-client-protocols.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ let service = new WebPubSubServiceClient("<your_connection_string>", "test-hub")
233233
await service.grantPermission("<connection_id>", "joinLeaveGroup", { targetName: "group1" });
234234
```
235235

236+
> [!NOTE]
237+
> 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.
238+
239+
236240
## Next steps
237241

238242
[!INCLUDE [next step](includes/include-next-step.md)]

articles/azure-web-pubsub/concept-wildcard-group-roles.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ Avoid over-broad patterns (like `**`) unless absolutely required; follow the pri
4040
| ------ | ------- |
4141
| `?` | Matches exactly one character except `/` |
4242
| `*` | Matches zero or more characters except `/` |
43-
| `**` | Matches zero or more characters including `/` (crosses path boundaries) |
43+
| `**` | Matches zero or more characters including `/` (crosses segment boundaries) |
4444
| `\` | Escape character for `\`, `*`, `?` |
45+
| `/` | acts as a segment separator and is never matched by `?` or `*` (only by `**`). |
4546

4647
Additional rules:
47-
48-
- `/` acts as a path separator and is never matched by `?` or `*` (only by `**`).
4948
- Use `**` sparingly; prefer narrower patterns (`clientA/*/chat`).
5049
- Up to five total `*` characters (including those forming `**`) are allowed in a single pattern.
5150

@@ -76,8 +75,8 @@ const token = await serviceClient.getClientAccessToken({
7675
roles: [
7776
// Can send to all groups under clientA/
7877
'webpubsub.sendToGroups.clientA/**',
79-
// Can join/leave any direct child group under clientA/public/
80-
'webpubsub.joinLeaveGroups.clientA/public/*'
78+
// Can join/leave any direct child group under public/
79+
'webpubsub.joinLeaveGroups.public/*'
8180
]
8281
});
8382
```
@@ -86,26 +85,34 @@ const token = await serviceClient.getClientAccessToken({
8685

8786
```csharp
8887
var url = service.GetClientAccessUri(roles: new [] {
88+
// Can send to all groups under clientA/
8989
"webpubsub.sendToGroups.clientA/**",
90-
"webpubsub.joinLeaveGroups.clientA/public/*"
90+
// Can join/leave any direct child group under public/
91+
"webpubsub.joinLeaveGroups.public/*"
9192
});
9293
```
9394

9495
# [Python](#tab/python)
9596

9697
```python
9798
token = service.get_client_access_token(roles=[
99+
# Can send to all groups under clientA/
98100
"webpubsub.sendToGroups.clientA/**",
99-
"webpubsub.joinLeaveGroups.clientA/public/*"
101+
102+
# Can join/leave any direct child group under public/
103+
"webpubsub.joinLeaveGroups.public/*"
100104
])
101105
```
102106

103107
# [Java](#tab/java)
104108

105109
```java
106110
GetClientAccessTokenOptions opt = new GetClientAccessTokenOptions();
111+
// Can send to all groups under clientA/
107112
opt.addRole("webpubsub.sendToGroups.clientA/**");
108-
opt.addRole("webpubsub.joinLeaveGroups.clientA/public/*");
113+
114+
// Can join/leave any direct child group under public/
115+
opt.addRole("webpubsub.joinLeaveGroups.public/*");
109116
WebPubSubClientAccessToken token = service.getClientAccessToken(opt);
110117
```
111118

@@ -118,6 +125,7 @@ WebPubSubClientAccessToken token = service.getClientAccessToken(opt);
118125
## Frequently asked questions
119126

120127
**Q: Can I mix literal and pattern roles?**
128+
121129
Yes. A literal role always applies exactly; patterns add broader coverage.
122130

123131

articles/azure-web-pubsub/howto-generate-client-access-url.md

Lines changed: 40 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: How to generate client access URL for Azure Web PubSub clients
33
description: How to generate client access URL for Azure Web PubSub clients.
44
author: vicancy
55
ms.author: lianwei
6-
ms.date: 09/06/2024
6+
ms.date: 10/17/2024
77
ms.service: azure-web-pubsub
88
ms.topic: how-to
99
---
@@ -40,66 +40,45 @@ The same Client Access URL can be generated by using the Web PubSub server SDK.
4040

4141
2. Generate Client Access URL by calling `WebPubSubServiceClient.getClientAccessToken`:
4242

43-
- Generate client access token
44-
45-
```js
46-
// for web pubsub native clients
47-
let token = await serviceClient.getClientAccessToken();
43+
- Generate client access token
4844

49-
// for mqtt clients
50-
let token = await serviceClient.getClientAccessToken({ clientProtocol: "mqtt" });
51-
```
52-
53-
- Configure user ID
45+
```js
46+
// for web pubsub native clients
47+
let token = await serviceClient.getClientAccessToken();
5448

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 = await serviceClient.getClientAccessToken({ clientProtocol: "mqtt" });
51+
```
6652

67-
- Configure a role that can join group `group1` directly when it connects using this Client Access URL
53+
- Configure user ID
6854

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+
```
7458

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
7660

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+
```
8266

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).
8468

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+
```
9574

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
9776

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+
```
10382

10483
# [C#](#tab/csharp)
10584

@@ -129,24 +108,12 @@ The same Client Access URL can be generated by using the Web PubSub server SDK.
129108
var url = service.GetClientAccessUri(expiresAfter: TimeSpan.FromMinutes(5));
130109
```
131110

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).
133112

134113
```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"
150117
});
151118
```
152119

@@ -184,24 +151,12 @@ The same Client Access URL can be generated by using the Web PubSub server SDK.
184151
token = service.get_client_access_token(minutes_to_expire=5)
185152
```
186153

187-
- Configure a role that can join group `group1` directly when it connects using this Client Access URL
188-
189-
```python
190-
token = service.get_client_access_token(roles=["webpubsub.joinLeaveGroup.group1"])
191-
```
192-
193-
- Configure a role that the client can send messages to group `group1` directly when it connects using this Client Access URL
194-
195-
```python
196-
token = service.get_client_access_token(roles=["webpubsub.sendToGroup.group1"])
197-
```
198-
199-
- Configure pattern roles to cover many groups
154+
- 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).
200155

201156
```python
202157
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"
205160
])
206161
```
207162

@@ -248,28 +203,12 @@ The same Client Access URL can be generated by using the Web PubSub server SDK.
248203
WebPubSubClientAccessToken token = service.getClientAccessToken(option);
249204
```
250205

251-
- Configure a role that can join group `group1` directly when it connects using this Client Access URL
252-
253-
```java
254-
GetClientAccessTokenOptions option = new GetClientAccessTokenOptions();
255-
option.addRole("webpubsub.joinLeaveGroup.group1");
256-
WebPubSubClientAccessToken token = service.getClientAccessToken(option);
257-
```
258-
259-
- Configure a role that the client can send messages to group `group1` directly when it connects using this Client Access URL
260-
261-
```java
262-
GetClientAccessTokenOptions option = new GetClientAccessTokenOptions();
263-
option.addRole("webpubsub.sendToGroup.group1");
264-
WebPubSubClientAccessToken token = service.getClientAccessToken(option);
265-
```
266-
267-
- Configure pattern roles to cover many groups
206+
- 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).
268207

269208
```java
270209
GetClientAccessTokenOptions option = new GetClientAccessTokenOptions();
271-
option.addRole("webpubsub.sendToGroups.clientA/**");
272-
option.addRole("webpubsub.joinLeaveGroups.clientA/public/*");
210+
option.addRole("webpubsub.joinLeaveGroup.group1"); // This role allows the client to join and leave "group1"
211+
option.addRole("webpubsub.sendToGroup.group1"); // This role allows the client to send messages to "group1"
273212
WebPubSubClientAccessToken token = service.getClientAccessToken(option);
274213
```
275214

@@ -357,5 +296,3 @@ You could also use Microsoft Entra ID and generate the token by invoking [Genera
357296
}
358297
```
359298

360-
> [!TIP]
361-
> See [Wildcard group role patterns](concept-wildcard-group-roles.md) for syntax, escaping, and security guidance.

articles/azure-web-pubsub/includes/reference-permission.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ A PubSub WebSocket client can only publish to other clients when it's authorized
2020
| `webpubsub.joinLeaveGroups.<pattern>` | The client can join/leave any group whose name matches `<pattern>` (see [Wildcard group role patterns](../concept-wildcard-group-roles.md)).
2121
| `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)).
2222

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

Comments
 (0)