Skip to content

Commit 66452b9

Browse files
authored
feat(cubejs-cli): adds USER_CONTEXT parameter to cli (#1215) Thanks to @TheSPD!
1 parent 85ca240 commit 66452b9

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

docs/Cube.js-ClI/Reference.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ _Use these manually generated tokens in production with caution._ <br> _Please r
7272
### Usage
7373

7474
```bash
75-
$ cubejs token -e TOKEN-EXPIRY -s SECRET -p FOO=BAR
75+
$ cubejs token -e TOKEN-EXPIRY -s SECRET -p FOO=BAR -u BAZ=QUX
7676
```
7777

7878
### Flags
@@ -82,6 +82,7 @@ $ cubejs token -e TOKEN-EXPIRY -s SECRET -p FOO=BAR
8282
| -e, --expiry &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Token expiry. Set to 0 for no expiry (default: "30 days") | `1 day`, `30 days` &nbsp; &nbsp; &nbsp; &nbsp; |
8383
| -s, --secret | Cube.js app secret. Also can be set via environment variable `CUBEJS_API_SECRET` | - |
8484
| -p, --payload | Token Payload | `foo=bar`, `userId=2` |
85+
| -u, --user-context | Token USER_CONTEXT Payload | `baz=qux`, `companyId=5` |
8586

8687
### Example
8788

packages/cubejs-cli/cubejsCli.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ program
254254
.option('-e, --expiry [expiry]', 'Token expiry. Set to 0 for no expiry', defaultExpiry)
255255
.option('-s, --secret [secret]', 'Cube.js app secret. Also can be set via environment variable CUBEJS_API_SECRET')
256256
.option('-p, --payload [values]', 'Payload. Example: -p foo=bar', collect, [])
257+
.option('-u, --user-context [values]', 'USER_CONTEXT. Example: -u baz=qux', collect, [])
257258
.description('Create JWT token')
258259
.action(
259260
(options) => token(options)

packages/cubejs-cli/token.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const token = async (options = {}) => {
2626
if (expiry !== '0') extraOptions.expiresIn = expiry;
2727

2828
const payload = parsePayload(options.payload);
29+
payload.u = parsePayload(options.userContext);
2930

3031
console.log('Generating Cube.js JWT token');
3132
console.log('');

0 commit comments

Comments
 (0)