Skip to content

Commit 596c31e

Browse files
author
Dan Costello
committed
Formatting
1 parent 9504edf commit 596c31e

5 files changed

Lines changed: 40 additions & 39 deletions

File tree

content/docs/data-access/definitions/access-policies.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ In addition, two special types of access policies are available:
2323

2424
Access policies provide central, fine-grained control over sensitive data access. They can evaluate purpose, identity, authorization, location, , and more. They can range from simple "always allow resolution" policies to complex evaluations.
2525

26-
![Access policies give you central, fine-grained control over sensitive data access. Policies can evaluate purpose, identity, permissions, location, expiration timelines, rate limits and more.](/assets/images/what-userclouds-does.webp)
26+
![Access policies give you central, fine-grained control over sensitive data access. Policies can evaluate purpose, identity, permissions, location, expiration timelines, rate limits and more.](/assets/images/flow-chart.webp)
2727

2828
## Example Use Cases
2929

@@ -58,7 +58,7 @@ Access Policies are composed from Access Policy Templates. Templates are paramet
5858

5959
### Template function
6060

61-
```
61+
```javascript
6262
function getAge(DOB) {
6363
const today = new Date();
6464
const birthDate = new Date(DOB);
@@ -77,7 +77,7 @@ function policy(context, params) {
7777

7878
### Parameters to instantiate a policy
7979

80-
```
80+
```javascript
8181
// Example Policy Parameters (not specified in the template function)
8282
const params = { expected_years_old: 16, column_name: "birthdate" };
8383
```
@@ -88,7 +88,7 @@ Here is an example of how you can create a policy to check if the country claim
8888

8989
### Template function
9090

91-
```
91+
```javascript
9292
function policy(context, params) {
9393
const country = context.server.claims.country;
9494
const specifiedCountry = params.specified_country;
@@ -98,7 +98,7 @@ function policy(context, params) {
9898

9999
### Parameters to instantiate a policy
100100

101-
```
101+
```javascript
102102
// Example Policy Parameters (not specified in the template function)
103103
const params = { specified_country: "USA" };
104104
```
@@ -109,7 +109,7 @@ If the country information is not in the JWT but in the client context, the poli
109109

110110
### Template function
111111

112-
```
112+
```javascript
113113
function policy(context, params) {
114114
const country = context.client.country;
115115
const specifiedCountry = params.specified_country;
@@ -119,7 +119,7 @@ function policy(context, params) {
119119

120120
### Parameters to instantiate a policy
121121

122-
```
122+
```javascript
123123
// Example Policy Parameters (not specified in the template function)
124124
const params = { specified_country: "USA" };
125125
```
@@ -136,11 +136,11 @@ We provide a number of built-in functions available as global variables in your
136136

137137
The built-in `networkRequest` function allows you to reach external services via HTTPS requests. You can pass headers in the network request, allowing you to authorize into third-party services, such as Zendesk via Basic Auth. This feature is useful for scenarios where your policy needs to check external data, e.g. for verifying if an employee has been assigned an open ticket for the user whose data they are trying to access.
138138

139-
### Example:
139+
### Example
140140

141141
This example shows how to make a network request to verify the user's country based on their IP address. Note that the interface for `networkRequest` is synchronous, as in the example below:
142142

143-
```
143+
```javascript
144144
function policy(context, params) {
145145
let countryCode = null;
146146
const resp = networkRequest({url: `https://api.iplocation.net/?ip=${context.server.ip_address}`, method: 'GET' });
@@ -151,13 +151,13 @@ function policy(context, params) {
151151
}
152152
```
153153

154-
### Example:
154+
### Example
155155

156-
This example shows how to verify an employee is active in a private employee directory, using Basic Auth.
156+
This example shows how to verify an employee is active in a private employee directory, using Basic Auth.
157157

158-
#### Template Function:
158+
#### Template Function
159159

160-
```
160+
```javascript
161161
function policy(context, params) {
162162
let isActiveEmployee = false;
163163

@@ -181,7 +181,7 @@ function policy(context, params) {
181181

182182
#### Parameters to instantiate a policy
183183

184-
```
184+
```javascript
185185
// Example Policy Parameters (not specified in the template function)
186186
const params = {}; // No specific parameters needed for this example
187187
```
@@ -192,11 +192,11 @@ const params = {}; // No specific parameters needed for this example
192192

193193
The `checkAttribute` function runs a permission check against the UserClouds authorization graph. If you are using UserClouds for authorization as a service, this can verify if a user has the necessary permissions. In short, it asks whether a given object (usually a user) has an attribute (e.g. "can-read" or "is-admin") on another object (which could be just about any entity in your system). You can read more about this in the [Authorization Documentation](https://docs.userclouds.com/reference/get_authz-checkattribute).
194194

195-
### Example:
195+
### Example
196196

197197
**Use Case: Does the calling user have view permission on the target user?**
198198

199-
```
199+
```javascript
200200
function policy(context) {
201201
const callingUserId = context.user.id;
202202
const targetUserId = context.params.targetUserId;
@@ -217,7 +217,7 @@ function policy(context) {
217217
- `country_name`: the ISO 3166 country name, as defined [here](https://github.com/OpenStars/phonenumber/blob/8ad15782bef1/iso3166.go) ; and
218218
- `country_code`: the numeric telephone country code
219219

220-
### Example:
220+
### Example
221221

222222
```javascript
223223
function policy(context, params) {

content/docs/data-access/how-to-guides/create-an-access-policy.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Access policies and templates are managed under the Access Rules element in the
1818

1919
![Policies and templates can be managed from the Policies page, accessible from the sidebar of UserClouds Console.](https://files.readme.io/184bfbc-image_4.png)
2020

21-
2221
## Creating Policy Templates in the UI
2322

2423
Policy templates are parametrizable functions that can be parametrized to create access policies. To create a policy template, go to the Policies page and click Create Policy Template.
@@ -36,7 +35,6 @@ Use the "Test Your Draft" card at the bottom of the page to test your policy tem
3635

3736
![The "Test Your Draft" card allows you to parametrize your draft template (creating an access policy) and then test that access policy with test context.](https://files.readme.io/ef73d2e-spaces_66DzLwptb2SejhKV7Bhn_uploads_oGa62N4DTjIR8mFABEN5_image.webp)
3837

39-
4038
## Creating Access Policies in the UI
4139

4240
**1 Open the Create Access Policy Page**
@@ -83,7 +81,7 @@ The checkAttribute function runs a permission check against the UserClouds autho
8381

8482
**Use Case: Does the calling user have view permission on the target user?**
8583

86-
```
84+
```javascript
8785
function policy(context) {
8886
const callingUserId = context.user.id;
8987
const targetUserId = context.params.targetUserId;
@@ -103,7 +101,7 @@ Parametrizable templates let you create flexible policies by adjusting parameter
103101

104102
### Example: User is N Years Old
105103

106-
```
104+
```javascript
107105
function getAge(DOB) {
108106
const today = new Date();
109107
const birthDate = new Date(DOB);

content/docs/data-access/how-to-guides/edit-existing-user-data/execute-a-mutator.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ hidden: false
66
createdAt: "Fri Feb 09 2024 20:18:55 GMT+0000 (Coordinated Universal Time)"
77
updatedAt: "Tue Jul 30 2024 18:09:50 GMT+0000 (Coordinated Universal Time)"
88
---
9-
Once you have configured a <<glossary:mutator>>, you are ready to edit the user data and consents in your store. This can be done by executing the mutator.
9+
Once you have configured a <<glossary:mutator>>, you are ready to edit the user data and consents in your store. This can be done by executing the mutator.
1010

1111
## How to execute a mutator
1212

13-
There are two ways to execute a mutator:
13+
There are two ways to execute a mutator:
1414

1515
- Download and deploy your tenant's code-generated UserClouds SDK, and call the mutator indirectly using its SDK function name
16-
- Call the [ExecuteMutator API](https://docs.userclouds.com/reference/post_userstore-api-mutators)
16+
- Call the [ExecuteMutator API](https://docs.userclouds.com/reference/post_userstore-api-mutators)
1717

1818
When calling the ExecuteMutator API directly you pass:
1919

@@ -34,7 +34,7 @@ When you execute a mutator, the following steps happen in sequence:
3434

3535
1. The mutator validates and normalizes the inbound data for each column associated with the mutator, using the configured <<glossary:data normalizer>> for that column.
3636
2. The mutator finds candidate user records to update based on the mutator <<glossary:selector>> clause and the passed in <<glossary:SelectorValues>>.
37-
3. Two access policies are applied to each selected user record: the global baseline policy for mutators (learn more [here](https://docs.userclouds.com/docs/apply-global-protection-policies)) and the mutator's own <<glossary:access policy>> composition. This step may involve evaluating the provided client context or any user-specific data already present in the User Store to determine if the write operation is permitted for each selector user record.
37+
3. Two access policies are applied to each selected user record: the global baseline policy for mutators (learn more [here](https://docs.userclouds.com/docs/apply-global-protection-policies)) and the mutator's own <<glossary:access policy>> composition. This step may involve evaluating the provided client context or any user-specific data already present in the User Store to determine if the write operation is permitted for each selector user record.
3838
4. If the access policy passes for the user, the mutator reconciles the normalized changes for each mutator column against existing user data, utilizing full mutation or partial mutation rules according to the column's configuration (see below for more detail).
3939
5. Any resulting changes to the user's data and associated consents are saved to the store.
4040

@@ -65,7 +65,7 @@ For this example, assume we are updating a column configured to be an array of s
6565

6666
1. **insert value with operational and marketing consents**
6767

68-
```
68+
```plaintext
6969
ValueAndPurposes = {
7070
Value: [“foo”, “bar”],
7171
PurposeAdditions: [“operational”, “marketing”],
@@ -76,6 +76,7 @@ For this example, assume we are updating a column configured to be an array of s
7676
("bar", ["operational", "marketing"]),
7777
]
7878
```
79+
7980
2. **add data_science and remove marketing consents for existing values**
8081

8182
```
@@ -90,6 +91,7 @@ For this example, assume we are updating a column configured to be an array of s
9091
("bar", ["operational", "data_science"]),
9192
]
9293
```
94+
9395
3. **update values, adding fraud_prevention consent**
9496

9597
```
@@ -103,6 +105,7 @@ For this example, assume we are updating a column configured to be an array of s
103105
("baz", ["operational", “data_science”, "fraud_prevention"]),
104106
]
105107
```
108+
106109
4. **delete all values**
107110

108111
```

content/docs/data-access/how-to-guides/enforce-rate-limiting.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ UserClouds applies rate limits to a given user based on the `sub` (subject) clai
2020

2121
The `AccessPolicyThresholds` structure defines the parameters for rate limiting:
2222

23-
```
23+
```javascript
2424
type AccessPolicyThresholds = {
2525
announce_max_execution_failure: boolean;
2626
announce_max_result_failure: boolean;
@@ -39,7 +39,7 @@ Execution limits control how often an action can be performed within a specific
3939

4040
Execution limits execute specially when a paginated accessor is called. The initial call is treated as one execution. Paging forward or backward from that initial call is not counted as another execution.
4141

42-
### Behavior:
42+
### Behavior
4343

4444
- If `announce_max_execution_failure` is true, a 429 (Too Many Requests) error is returned when the limit is exceeded for accessors and mutators. Failures for token resolution are always silent (i.e., the token is not resolved).
4545
- If `announce_max_execution_failure` is false, the request does not fail, but no actions will occur. That is, no results are returned (for accessors), modifications are not applied (for mutators), or tokens are not resolved (for token resolution).
@@ -50,13 +50,13 @@ Result limits control the number of results that can be returned or affected by
5050

5151
- `max_results_per_execution`: Maximum number of results affected by a single execution. If this is 0, the limit is turned off.
5252

53-
### Limit definition:
53+
### Limit definition
5454

5555
- For accessors, this limit applies to the total number of results that could be returned, across all pages (if paginated). For example, an accessor that could return 6 different pages of 100 records each would exceed a 500 result limit, even though each individual page size is within the limit.
5656
- For mutators, it applies to the number of records modified.
5757
- For token resolution, it applies to the number of tokens resolved.
5858

59-
### Behavior:
59+
### Behavior
6060

6161
- If `announce_max_result_failure` is true, a 400 (Bad Request) error is returned when the limit is exceeded.
6262
- If `announce_max_result_failure` is false, the request does not fail, but no actions will occur. That is, no results are returned (for accessors), no modifications are applied (for mutators), or no tokens are resolved (for token resolution).
@@ -65,15 +65,15 @@ Result limits control the number of results that can be returned or affected by
6565

6666
Rate limiting is enabled by associating an access policy with rate limits to a mutator, accessor, or token. For tokens, the access policy is specified at token creation time (e.g. via the token resolution policy on an accessor returning the token).
6767

68-
### Token Resolution Note:
68+
### Token Resolution Note
6969

7070
Failures are always silent (no error code is returned), as token resolution requests may involve multiple access policies, some of which may have rate limits and some may not.
7171

7272
## Example Usage
7373

7474
To set rate limits for an access policy, configure the `AccessPolicyThresholds`:
7575

76-
```
76+
```javascript
7777
const accessPolicy: AccessPolicy = {
7878
thresholds: {
7979
announce_max_execution_failure: true,
@@ -86,7 +86,7 @@ const accessPolicy: AccessPolicy = {
8686
};
8787
```
8888

89-
The rate limit thresholds for an access policy may be changed after the access policy is created.
89+
The rate limit thresholds for an access policy may be changed after the access policy is created.
9090

9191
Note that we only consider the thresholds for the top level access policy for the accessor / mutator / token resolution. Since an access policy can be composed of multiple access policies, a sub-policy may have usage thresholds. Those thresholds would be ignored.
9292

content/docs/data-access/proxy-and-plug-in-implementation/3-applying-access-policies-to-queries.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ Once you have re-pointed your application’s database queries, object store req
1414

1515
Access policies are evaluated per row of returned data from the database. Therefore, if an access policy evaluates row-specific data returned from the database (such as a target user’s date of birth), it may return a subset of records.
1616

17-
### To Apply an Access Policy to a Particular Query:
17+
### To Apply an Access Policy to a Particular Query
1818

1919
1. **Trigger the Query, Request, or API Call**: Trigger the action in the application if you haven’t already (e.g., by loading a table of data, requesting an object from storage, or calling an API endpoint).
20-
2. **Select and Edit the Query, Blob Store, or API Call:**
20+
2. **Select and Edit the Query, Blob Store, or API Call:**
2121
1. **For SQL Proxies:** In the UserClouds Console, go to Accessors (under Access Methods), find the relevant query in your list of data accessors, and click "Edit".
2222
2. **For NoSQL Proxies:** In the UserClouds Console, navigate to Object Stores under User Data Storage in the side navigation, select the object store, and click "Edit".
2323
3. **For API Proxies:** In the UserClouds Console, navigate to API connections under User Data Storage in the side navigation, select the API connection, and click "Edit".
2424
3. **Add Access Policies**: Scroll down to the access policy section and add one or more access policies.
25-
1. **For SQL Proxies: **Apply policies at the query level.
26-
2. **For NoSQL Proxies: **Apply policies at the object store level, but you can also consider the file path as context (e.g., a user ID in the file path) for finer-grained access control.
25+
1. **For SQL Proxies:** Apply policies at the query level.
26+
2. **For NoSQL Proxies:** Apply policies at the object store level, but you can also consider the file path as context (e.g., a user ID in the file path) for finer-grained access control.
2727
3. **For API Proxies**: Apply policies at the individual endpoint level.
2828
4. **Define Policy Logic**: If adding two or more access policies, define whether all policies or one policy must be true for the overall policy to pass, by ANDing or ORing the policies together.
2929
5. **Save**: Click "Save".
@@ -38,7 +38,7 @@ Access policies can evaluate context passed in the request. Context can be inclu
3838

3939
This example shows how context is added to a query using comments:
4040

41-
```
41+
```sql
4242
SELECT name, email, phone FROM users WHERE id = 1234 /*geo=’uk’ user=’albus-dumbledore’*/
4343
```
4444

@@ -48,7 +48,7 @@ SELECT name, email, phone FROM users WHERE id = 1234 /*geo=’uk’ user=’albu
4848

4949
This example shows how an access policy might use the context to enforce access control:
5050

51-
```
51+
```javascript
5252
function policy(context, params) {
5353
// Allow access only if the calling user's geo is 'uk'
5454
return context.client.geo === 'uk';

0 commit comments

Comments
 (0)