Skip to content

Commit ad3440d

Browse files
docs: Update docs according to the style guide (#6512)
Co-authored-by: Hassan Khan <[email protected]>
1 parent 2cd3669 commit ad3440d

File tree

101 files changed

+5813
-4023
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+5813
-4023
lines changed

docs/content/Auth/Security-Context.mdx

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Security Context
2+
title: Security context
33
permalink: /security/context
44
category: Authentication & Authorization
55
menuOrder: 2
@@ -38,11 +38,11 @@ with filters. For example, let's take the following query:
3838

3939
```json
4040
{
41-
"dimensions": ["Orders.status"],
42-
"measures": ["Orders.count", "Orders.total"],
41+
"dimensions": ["orders.status"],
42+
"measures": ["orders.count", "orders.total"],
4343
"timeDimensions": [
4444
{
45-
"dimension": "Orders.createdAt",
45+
"dimension": "orders.createdAt",
4646
"dateRange": ["2015-01-01", "2015-12-31"],
4747
"granularity": "month"
4848
}
@@ -84,7 +84,7 @@ module.exports = {
8484
}
8585

8686
query.filters.push({
87-
member: 'Orders.userId',
87+
member: 'orders.user_id',
8888
operator: 'equals',
8989
values: [securityContext.user_id],
9090
});
@@ -112,7 +112,7 @@ Authorization HTTP header.
112112
curl \
113113
-H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1Ijp7ImlkIjo0Mn0sImlhdCI6MTU1NjAyNTM1MiwiZXhwIjoxNTU4NjE3MzUyfQ._8QBL6nip6SkIrFzZzGq2nSF8URhl5BSSSGZYp7IJZ4" \
114114
-G \
115-
--data-urlencode 'query={"measures":["Orders.count"]}' \
115+
--data-urlencode 'query={"measures":["orders.count"]}' \
116116
http://localhost:4000/cubejs-api/v1/load
117117
```
118118

@@ -155,23 +155,33 @@ With the same JWT payload as before, we can modify models before they are
155155
compiled. The following cube will ensure users only see results for their
156156
`company_id` in a multi-tenant deployment:
157157

158-
```javascript
159-
const {
160-
securityContext: { company_id },
161-
} = COMPILE_CONTEXT;
158+
<CodeTabs>
159+
160+
```yaml
161+
cubes:
162+
- name: orders
163+
sql_table: "{COMPILE_CONTEXT.securityContext.company_id}.orders"
162164

163-
cube(`Orders`, {
164-
sql: `SELECT * FROM ${company_id}.orders`,
165+
measures:
166+
- name: count
167+
type: count
168+
```
169+
170+
```javascript
171+
cube(`orders`, {
172+
sql_table: `${COMPILE_CONTEXT.securityContext.company_id}.orders`,
165173

166174
measures: {
167175
count: {
168-
type: `count`,
169-
},
170-
},
171-
});
176+
type: `count`
177+
}
178+
}
179+
})
172180
```
173181

174-
### <--{"id" : "Using COMPILE_CONTEXT"}--> Usage with Pre-Aggregations
182+
</CodeTabs>
183+
184+
### <--{"id" : "Using COMPILE_CONTEXT"}--> Usage with pre-aggregations
175185

176186
To generate pre-aggregations that rely on `COMPILE_CONTEXT`, [configure
177187
`scheduledRefreshContexts` in your `cube.js` configuration

0 commit comments

Comments
 (0)