Skip to content

Commit 910e2a7

Browse files
torcolvinsimon-dew
andauthored
DOC-11383 clarify collection_access for channel assignment (#853)
* DOC-11383 clarify collection_access for channel assignment * Clarify channel definition --------- Co-authored-by: Simon Dew <Simon.Dew@couchbase.com>
1 parent 1d24b72 commit 910e2a7

7 files changed

Lines changed: 96 additions & 25 deletions

File tree

modules/ROOT/pages/_partials/concepts/channels.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Version 3.x::
9595
image::channel-access-grant-3.0.png["Access Control Points 3.x",400]
9696
9797
<1> Using the Admin REST API: +
98-
You can provide the `admin_channels` property using the *Admin REST API* endpoint ({rest-api-admin-user-put--xref}).
98+
You can provide the `admin_channels` property within the `collection_access` property using the *Admin REST API* endpoint ({rest-api-admin-user-put--xref}).
9999
100100
<2> Programmatically using Access Grant Document: +
101101
The {sync-function--xref} provides a flexible and secure method for controlling document access and routing.

modules/ROOT/pages/_partials/concepts/roles.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ They enable the grouping together of {users--xref} with similar characteristics,
1111
// end::summary[]
1212
// tag::body[]
1313

14-
A Role and a user assigned to a Role is granted access to a channel, a part of collections.
15-
The user can then access all documents assigned to that channel.
14+
A Role and a user assigned to a role is granted to access to a channel, which is associated with a specific collection.
15+
The user can then access all documents assigned to that channel.
1616
When granting user access to admin channels statically, the user must specify the collection and corresponding channel.
1717

1818
As an entity, roles comprise a name and a list of channels.
1919

20-
Any user associated with a role inherits the right to access any of the channels in the roles list. This provides a convenient way to associate multiple channels with multiple users.
20+
Any user associated with a role inherits the right to access any of the channels in the role's list. This provides a convenient way to associate multiple channels with multiple users.
2121

22-
TIP: Roles have a separate namespace from users, so its possible to have a user and a role with the same name.
22+
TIP: Roles have a separate namespace from users, so it's possible to have a user and a role with the same name.
2323

2424

2525
// end::body[]

modules/ROOT/pages/_partials/howto/how-to-control-document-access.adoc

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This dual-purpose is reflected in the way you use channels:
2222
You grant roles and-or users access to channels using:
2323

2424
* Admin REST API +
25-
Using admin_channels property using the admin REST API endpoint -- see {rest-api-admin-user-put--xref}
25+
Using `admin_channels` property inside the `collection_access` property using the admin REST API endpoint -- see {rest-api-admin-user-put--xref}
2626
* Dynamically via Sync Function  +
2727
 Programmatically within the sync function using the exposed helper function access() — see {sync-function-api--xref}
2828
* Configuration File (pre 3.0) +
@@ -47,11 +47,11 @@ Specify the roles to be assigned in the `admin_channels` array.
4747
----
4848
$ curl -vX PUT "http://localhost:4985/mydatabase/_user/{user}" -H //<.>
4949
"accept: application/json" -H "Content-Type: application/json" -d
50-
'{ "admin_channels": ["Channel1","Channel3]}' // <.>
50+
'{"collection_access": {"scopename": { "collectionname": {"admin_channels": ["Channel1","Channel3"]}}}}' // <.>
5151
----
5252

5353
<.> {user} is the user name to be updated, e.g. "Edge1User"
54-
<.> Here we add _Channel1_ and _Channel3_ to the user
54+
<.> Here we add _Channel1_ and _Channel3_ to the user inside scope scopename and collection collectionname.
5555

5656
--
5757

@@ -134,21 +134,46 @@ Use the *Admin REST API* for production systems.
134134
"mydatabase": {
135135
"users": {
136136
"GUEST": {"disabled": true},
137-
"Edge1User": {"password": "pass", "admin_roles": ["Edge1"],
138-
"admin_channels": ["Channel1","Channel3","RandomChannel"]} // <.>
137+
"Edge1User": {
138+
"password": "pass",
139+
"admin_roles": ["Edge1"],
140+
"collection_access": {
141+
"scopename": {
142+
"collectionname": {
143+
"admin_channels": ["Channel1","Channel3","RandomChannel"] // <.>
144+
}
145+
}
146+
}
147+
}
139148
},
140149
"roles": {
141-
"Edge1": {"admin_channels": ["channel1", "channel3"]},
142-
"Edge2": {"admin_channels": ["Channel2","Channel3","SkyChannel"]} // <.>
150+
"Edge1": {
151+
"collection_access": {
152+
"scopename": {
153+
"collectionname": {
154+
"admin_channels": ["channel1","channel3"]
155+
}
156+
}
157+
}
158+
},
159+
"Edge2": {
160+
"collection_access": {
161+
"scopename": {
162+
"collectionname": {
163+
"admin_channels": ["channel2","channel3","SkyChannel"]} // <.>
164+
}
165+
}
166+
}
167+
},
143168
}
144169
}
145170
}
146171
}
147172
----
148173
149-
<.> Here we have added the channel _RandomChannel_ to the user _Edge1User_ {configuration-schema-database--pfx--db}-users-this_user-admin_channels[databases.$db.users.$user.admin_channel]
174+
<.> Here we have added the channels _channel1_ and `_channel3_ to the user _Edge1User_ {configuration-schema-database--pfx--db}-users-this_user-admin_channels[databases.$db.users.$user.collection_access.$scopename.$collectionname.admin_channels]
150175
151-
<.> Here we have added the channel _SkyChannel_ to the role _Edge2_ {configuration-schema-database--pfx--db}-roles-this_role-admin_channels[databases.$db.users.$user.admin_channel]
176+
<.> Here we have added the channels _channel2_, _channel3_ and _SkyChannel_ to the role _Edge2_ {configuration-schema-database--pfx--db}-roles-this_role-admin_channels[databases.$db.users.$user.$collection_access.$scopename.$collectionname.$admin_channels]
152177
153178
--
154179

modules/ROOT/pages/_partials/howto/how-to-create-roles.adoc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ Create a new role using the {rest-api-admin-role-post--xref} endpoint.
4747
----
4848
$ curl -vX POST "http://localhost:4985/mydatabase/_roles/" -H
4949
"accept: application/json" -H "Content-Type: application/json" -d
50-
'{"name": "Edge1", "admin_channels": ["channel1", "channel3"]]}' // <.>
50+
'{"name": "Edge1", "collection_acces": {"scopename": {"collectionname": {"admin_channels": ["channel1", "channel3"]]}}}}' // <.>
5151
----
52-
<.> Here we add the Edge1 role.
52+
<.> Here we add the Edge1 role which grants channel access to channel1 and channel3 in scope scopename and collection collectionname.
5353

5454
--
5555

@@ -69,7 +69,15 @@ It is recommended to use the *REST API* for production systems.
6969
"databases": {
7070
"mydatabase": {
7171
"roles": { // <.>
72-
"Edge1": {"admin_channels": ["channel1", "channel3"]}, // <.>
72+
"Edge1": {
73+
"collection_access": {
74+
"scopename": {
75+
"collectionname": {
76+
"admin_channels": ["channel1", "channel3"] // <.>
77+
}
78+
}
79+
}
80+
},
7381
"Edge2": {"admin_channels": ["channel2", "channel3"]},
7482
"GUEST": {"disabled": true}
7583
}
@@ -84,4 +92,4 @@ It is recommended to use the *REST API* for production systems.
8492
=====
8593
====
8694

87-
// END how-to -- HOW-TO CREATE A ROLE
95+
// END how-to -- HOW-TO CREATE A ROLE

modules/ROOT/pages/_partials/howto/how-to-verify-access.adoc

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ curl http://localhost:4985/db/_user/pupshaw
4040
4141
The <<ex-output,output>> shows that the user `pupshaw` has access to the following channels:
4242
43-
<.> `all` through its own `admin_channels` setting
44-
<.> `hoopy` through the `froods` role's `admin_channels` setting
43+
<.> `all` through its own `admin_channels` setting for the default collection.
44+
<.> `collectionAChannel` through its own `admin_channels` setting for the collection `collectionA`.
45+
<.> `hoopy` through the `froods` role's `admin_channels` setting in the default collection.
4546
4647
[#ex-output]
4748
[source,json]
@@ -50,6 +51,18 @@ The <<ex-output,output>> shows that the user `pupshaw` has access to the followi
5051
"admin_channels": [
5152
"all" // <.>
5253
],
54+
"collection_access": {
55+
"scopeA": {
56+
"collectionA": {
57+
"admin_channels": [
58+
"collectionAChannel" // <.>
59+
],
60+
"all_channels": [
61+
"collectionAChannel"
62+
]
63+
}
64+
}
65+
},
5366
"admin_roles": [
5467
"froods"
5568
],
@@ -77,12 +90,25 @@ curl http://localhost:4985/db/_role/frood
7790
7891
The output shows that the role `froods` has access to the following channels:
7992
80-
<.> `hoopy` through its role's `admin_channels` setting
93+
<.> `hoopy` through its role's `admin_channels` setting for the default collection.
94+
<.> `collectionA` through its role's `admin_channels` setting for the collection `collectionA`.
8195
8296
[source,json]
8397
----
8498
{
8599
"name": "froods",
100+
"collection_access": {
101+
"scopeA": {
102+
"collectionA": {
103+
"admin_channels": [
104+
"collectionAChannel" // <.>
105+
],
106+
"all_channels": [
107+
"collectionAChannel"
108+
]
109+
}
110+
}
111+
},
86112
"admin_channels": [
87113
"hoopy" // <.>
88114
],
@@ -128,4 +154,4 @@ That assignment to `hoopy` is what makes it available to our `froods` role and t
128154
129155
====
130156

131-
// END how-to -- HOW-TO VERIFY ACCESS
157+
// END how-to -- HOW-TO VERIFY ACCESS

modules/ROOT/pages/authentication-users.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The following sample command enables the GUEST account and allows it access to a
5555
[source,bash]
5656
----
5757
$ curl -X PUT localhost:4985/$DB/_user/GUEST --data \
58-
'{"disabled":false, "admin_channels":["public"]}'
58+
'{"disabled":false, "collection_access": {"scopename": {"collectionname": {"admin_channels":["public"]}}}}'
5959
----
6060

6161

modules/ROOT/pages/get-started-verify-install.adoc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,13 @@ curl --location --request PUT 'http://127.0.0.1:4985/traveldb/_role/stdrole' \/
202202
--header 'Content-Type: application/json' \
203203
--data-raw '{
204204
"name": "stdrole",
205-
"admin_channels": ["newrolechannel"] // <.>
205+
"collection_access": {
206+
"scopename": {
207+
"collection_name" {
208+
admin_channels": ["newrolechannel"] // <.>
209+
}
210+
}
211+
}
206212
}'
207213
----
208214
@@ -231,7 +237,13 @@ curl --location -g --request POST 'http://localhost:4985/traveldb/_user/' \// <
231237
"name": "sgwuser1", // <.>
232238
"password": "passwordstring",
233239
"admin_roles": ["stdrole"], // <.>
234-
"admin_channels": ["public"] // <.>
240+
"collection_access": {
241+
"scopename": {
242+
"collection_name" {
243+
admin_channels": ["public"] // <.>
244+
}
245+
}
246+
}
235247
}'
236248
----
237249
<.> Here we identify the name of the {sgw} database -- `traveldb` and the required object, `_user`

0 commit comments

Comments
 (0)