Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/doc/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
image: redis:5

elasticsearch:
image: kuzzleio/elasticsearch:7.4.0
image: kuzzleio/elasticsearch:7
ulimits:
nofile: 65536

Expand Down
2 changes: 1 addition & 1 deletion .ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ services:
image: redis:5

elasticsearch:
image: kuzzleio/elasticsearch:7.4.0
image: kuzzleio/elasticsearch:7
ulimits:
nofile: 65536
12 changes: 11 additions & 1 deletion .ci/test-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ until $(curl --output /dev/null --silent --head --fail http://localhost:7512); d
done

cd ${here}/../doc/7/getting-started/.react
npm install
npm ci
SKIP_PREFLIGHT_CHECK=true npm run start &
until $(curl --output /dev/null --silent --head --fail http://localhost:3000); do
printf '.'
Expand All @@ -35,6 +35,16 @@ until $(curl --output /dev/null --silent --head --fail http://localhost:8080); d
done
npm run test

cd ${here}/../doc/7/getting-started/.react-native
# Here we use install instead of ci because expo-cli cannot be installed with ci
npm install
npm run web &
until $(curl --output /dev/null --silent --head --fail http://localhost:19006); do
printf '.'
sleep 5
done
npm run test

cd ${here}
docker-compose -f ./doc/docker-compose.yml down

Expand Down
21 changes: 19 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:

addons:
apt:
update: true
sources:
- ubuntu-toolchain-r-test
packages:
Expand Down Expand Up @@ -47,6 +48,7 @@ jobs:

addons:
apt:
update: true
sources:
- ubuntu-toolchain-r-test
packages:
Expand Down Expand Up @@ -78,34 +80,41 @@ jobs:

- stage: Tests
name: Dead link check
language: node_js
node_js: 12
if: type = pull_request OR type = push AND branch =~ /^master|[0-9]+-(dev|stable|beta)$/ OR type = cron

before_script:
- npm ci
- npm run doc-prepare
- npm run --prefix doc/framework repositories -- clone
- $(npm bin)/kuzdoc iterate-repos:install --repos_path doc/framework/.repos/
- $(npm bin)/kuzdoc framework:link -d /sdk/js/7/ -v 7
script:
- gem install typhoeus
- HYDRA_MAX_CONCURRENCY=20 npm run --prefix doc/framework dead-links
- cd doc/framework/ && HYDRA_MAX_CONCURRENCY=20 ruby .ci/dead-links.rb -p src/sdk/js/7/

- stage: Deployment Doc Dev
name: Deploy next-docs.kuzzle.io
if: type = push AND branch =~ /^[0-9]+-dev$/
language: node_js
node_js: 10
env:
- BRANCH=dev
- NODE_ENV=production
- S3_BUCKET=docs-next.kuzzle.io
- CLOUDFRONT_DISTRIBUTION_ID=E2ZCCEK9GRB49U
- AWS_DEFAULT_REGION=us-west-2

addons:
apt:
update: true
packages:
- python
- python-pip

install:
- pip install awscli --upgrade --user
- npm ci

script:
- npm run doc-prepare
Expand All @@ -116,6 +125,8 @@ jobs:
script:
- npm run doc-upload
skip_cleanup: true
on:
all_branches: true

after_deploy:
- npm run doc-cloudfront
Expand All @@ -133,12 +144,14 @@ jobs:

addons:
apt:
update: true
packages:
- python
- python-pip

install:
- pip install awscli --upgrade --user
- npm ci

script:
- npm run doc-prepare
Expand All @@ -149,6 +162,8 @@ jobs:
script:
- npm run doc-upload
skip_cleanup: true
on:
all_branches: true

after_deploy:
- npm run doc-cloudfront
Expand Down Expand Up @@ -195,6 +210,7 @@ jobs:

addons:
apt:
update: true
sources:
- ubuntu-toolchain-r-test
packages:
Expand Down Expand Up @@ -228,6 +244,7 @@ jobs:

addons:
apt:
update: true
sources:
- ubuntu-toolchain-r-test
packages:
Expand Down
70 changes: 70 additions & 0 deletions doc/7/controllers/auth/create-api-key/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
code: true
type: page
title: createApiKey
description: Creates a new API key for the currently loggued user.
---

# createApiKey

<SinceBadge version="7.1.0" />

<SinceBadge version="Kuzzle 2.1.0" />

Creates a new API key for the currently loggued user.

<br />

```js
createApiKey(description, [options]);
```

<br />

| Property | Type | Description |
| --- | --- | --- |
| `description` | <pre>string</pre> | API key description |
| `options` | <pre>object</pre> | Additional options |

### options

Additional query options

| Property | Type<br />(default) | Description |
| --- | --- | --- |
| `expiresIn` | <pre>string/number</pre><br />(`-1`) | Expiration duration |
| `_id` | <pre>string</pre><br />(`null`) | API key unique ID |
| `refresh` | <pre>boolean</pre><br />(`false`) | If set to `wait_for`, Kuzzle will not respond until the API key is indexed |

**Notes**:
- `expiresIn`:
- if a raw number is provided (not enclosed between quotes), then the expiration delay is in milliseconds. Example: `86400000`
- if this value is a string, then its content is parsed by the [ms](https://www.npmjs.com/package/ms) library. Examples: `"6d"`, `"10h"`
- if `-1` is provided, the token will never expire

## Resolves

An object containing the newly created API key:

| Name | Type | Description |
| --------- | ----------------- | ---------------- |
| `_id` | <pre>string</pre> | ID of the newly created API key |
| `_source` | <pre>object</pre> | API key content |

The API key content has the following properties:

| Name | Type | Description |
| --------- | ----------------- | ---------------- |
| `userId` | <pre>string</pre> | User kuid |
| `expiresAt` | <pre>number</pre> | Aexpiration date in UNIX micro-timestamp format (`-1` if the token never expires) |
| `ttl` | <pre>number</pre> | Original TTL |
| `description` | <pre>string</pre> | API key description |
| `token` | <pre>string</pre> | Authentication token associated with this API key |

::: warning
The authentication token `token` will never be returned by Kuzzle again. If you lose it, you'll have to delete the API key and recreate a new one.
:::

## Usage

<<< ./snippets/create-api-key.js
23 changes: 23 additions & 0 deletions doc/7/controllers/auth/create-api-key/snippets/create-api-key.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
try {
await kuzzle.auth.login('local', { username: 'john.doe', password: 'password' });

const apiKey = await kuzzle.auth.createApiKey('Sigfox API key');

console.log(apiKey);
/*
{
_id: '-fQRa28BsidO6V_wmOcL',
_source: {
description: 'Sigfox API key',
userId: 'john.doe',
expiresAt: -1,
ttl: -1,
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiJqb2huLmRvZSIsImlhdCI6MTU3ODA0OTMxMn0.XO_keW6EtsCGmPzxVJCChU9VREakEECDGg-N5lhCfF8'
}
}
*/

console.log('API key successfully created');
} catch (e) {
console.error(e);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: auth#createApiKey
description: Creates a new API key for the currently loggued user.
hooks:
before: >
curl -H "Content-type: application/json" -d '{
"content": {
"profileIds": ["default"]
},
"credentials": {
"local": {
"username": "john.doe",
"password": "password"
}
}
}' "kuzzle:7512/users/john.doe/_create?refresh=wait_for"
after:
curl -XDELETE kuzzle:7512/users/john.doe
template: default
expected:
- "description: 'Sigfox API key'"
- "userId: 'john.doe'"
- API key successfully created
43 changes: 43 additions & 0 deletions doc/7/controllers/auth/delete-api-key/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
code: true
type: page
title: deleteApiKey
description: Deletes an API key for the currently loggued user.
---

# deleteApiKey

<SinceBadge version="7.1.0" />

<SinceBadge version="Kuzzle 2.1.0" />

Deletes an API key for the currently loggued user.

<br />

```js
deleteApiKey(id, [options]);
```

<br />

| Property | Type | Description |
| --- | --- | --- |
| `id` | <pre>string</pre> | API key unique ID |
| `options` | <pre>object</pre> | Additional options |

### options

Additional query options

| Property | Type<br />(default) | Description |
| --- | --- | --- |
| `refresh` | <pre>boolean</pre><br />(`false`) | If set to `wait_for`, Kuzzle will not respond until the API key is indexed |

## Resolves

Resolves if the API key is successfully deleted.

## Usage

<<< ./snippets/delete-api-key.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
try {
await kuzzle.auth.login('local', { username: 'john.doe', password: 'password' });

await kuzzle.auth.deleteApiKey('fQRa28BsidO6V_wmOcL');

console.log('API key successfully deleted');
} catch (e) {
console.error(e);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: auth#deleteApiKey
description: Deletes an API key for the currently loggued user
hooks:
before: >
curl -H "Content-type: application/json" -d '{
"content": {
"profileIds": ["default"]
},
"credentials": {
"local": {
"username": "john.doe",
"password": "password"
}
}
}' "kuzzle:7512/users/john.doe/_create?refresh=wait_for"
&&
curl -XPOST -H "Content-type: application/json" -d '{
"description": "Sigfox API key"
}' "kuzzle:7512/users/john.doe/api-keys/_create?_id=fQRa28BsidO6V_wmOcL&refresh=wait_for"
after:
curl -XDELETE kuzzle:7512/users/john.doe
template: default
expected:
- API key successfully deleted
Loading