Skip to content

Commit 4707e94

Browse files
Merge #2103
2103: v1.0: Reject master keys less than 16 bytes r=guimachiavelli a=maryamsulemani97 closes #2069 Co-authored-by: maryamsulemani97 <maryam@meilisearch.com> Co-authored-by: Maryam <90181761+maryamsulemani97@users.noreply.github.com>
2 parents 5ce66fe + 23b528c commit 4707e94

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

.vale/styles/Vocab/word_list/accept.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ AMIs
7878
[Cc]ancelation
7979
Brotli
8080
zlib
81+
autogenerate

learn/configuration/instance_options.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ Configures the instance's environment. Value must be either `production` or `dev
166166

167167
`production`:
168168

169-
- Setting a [master key](/learn/security/master_api_keys.md) is **mandatory**
169+
- Setting a [master key](/learn/security/master_api_keys.md) of at least 16 bytes is **mandatory**. If no master key is provided or if it is under 16 bytes, Meilisearch will suggest a secure autogenerated master key
170170
- The [search preview interface](/learn/what_is_meilisearch/search_preview.md) is disabled
171171

172172
`development`:
173173

174-
- Setting a [master key](/learn/security/master_api_keys.md) is **optional**
174+
- Setting a [master key](/learn/security/master_api_keys.md) is **optional**. If no master key is provided or if it is under 16 bytes, Meilisearch will suggest a secure autogenerated master key
175175
- Search preview is enabled
176176

177177
::: tip
@@ -192,18 +192,16 @@ Sets the HTTP address and port Meilisearch will use.
192192
**Environment variable**: `MEILI_MASTER_KEY`
193193
**CLI option**: `--master-key`
194194
**Default value**: `None`
195-
**Expected value**: an alphanumeric string
195+
**Expected value**: a UTF-8 string of at least 16 bytes
196196

197197
Sets the instance's master key, automatically protecting all routes except [`GET /health`](/reference/api/health.md). This means you will need an API key to access endpoints such as `POST /search` and `GET /documents`. [You can read more about security keys in Meilisearch in our dedicated guide.](/learn/security/master_api_keys.md)
198198

199-
::: note
200-
You must supply an alphanumeric string when using this option.
201-
:::
202-
203-
Providing a master key is mandatory when `--env` is set to `production`. If none is given, Meilisearch will throw an error and refuse to launch.
199+
Providing a master key is mandatory when `--env` is set to `production`. If none is given, or it is under 16 bytes, Meilisearch will throw an error and refuse to launch.
204200

205201
If no master key is provided in a `development` environment, all routes will be unprotected and publicly accessible.
206202

203+
If you do not supply a master key in `production` or `development` environments or it is under 16 bytes, Meilisearch will suggest a secure autogenerated master key you can use when restarting your instance.
204+
207205
[Learn more about Meilisearch's use of security keys.](/learn/security/master_api_keys.md)
208206

209207
### Disable auto-batching

learn/cookbooks/running_production.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ In Debian and other Linux distributions, `systemd` allows you to create and mana
119119

120120
Service files are text files that tell your operating system how to run your program, and when. They live in the `/etc/systemd/system` directory, and your system will load them at boot time. In this case, let's use a very simple service file that will run Meilisearch on port `7700`.
121121

122-
To run Meilisearch in a production environment, use the `--env` flag. Set the master key using the `--master-key` option. When you launch an instance for the first time, Meilisearch creates two default API keys: [`Default Search API Key` and `Default Admin API Key`](/learn/security/master_api_keys.md#using-default-api-keys-for-authorization). With the `Default Admin API Key`, you can control who can access or create new documents, indexes, or change the configuration.
122+
To run Meilisearch in a production environment, use the `--env` flag. Set a master key of at least 16 bytes using the `--master-key` option. When you launch an instance for the first time, Meilisearch creates two default API keys: [`Default Search API Key` and `Default Admin API Key`](/learn/security/master_api_keys.md#using-default-api-keys-for-authorization). With the `Default Admin API Key`, you can control who can access or create new documents, indexes, or change the configuration.
123123

124124
Remember to choose a safe and random key and avoid exposing it in publicly accessible applications. You can change the master key with the following command:
125125

learn/getting_started/quick_start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ You should now have a working front-end search interface 🚀🔥
312312

313313
## Securing Meilisearch
314314

315-
The Meilisearch API is unprotected by default, making all routes publicly accessible. You can set a master key to protect your instance from unauthorized use:
315+
The Meilisearch API is unprotected by default, making all routes publicly accessible. You can set a master key of at least 16 bytes to protect your instance from unauthorized use:
316316

317317
:::: tabs
318318

learn/security/master_api_keys.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ This guide will teach you how to protect your Meilisearch instance by setting a
44

55
## Protecting a Meilisearch instance
66

7-
**By default, Meilisearch's API is unprotected**. This means all routes are publicly accessible, and require no authorization to access.
7+
**By default, Meilisearch's API is unprotected**. This means all routes are publicly accessible and require no authorization to access.
88

9-
To protect a Meilisearch instance from unauthorized use, you must supply a master key at launch. This master key can be of any length, but must be composed of valid UTF-8 characters.
9+
To protect a Meilisearch instance from unauthorized use, you must supply a master key at launch. This master key must be at least 16 bytes, composed of valid UTF-8 characters. In a production environment, Meilisearch will throw an error and refuse to launch if no master key is provided or if it is under 16 bytes, Meilisearch will suggest a secure autogenerated master key.
1010

1111
::: warning
1212
You need to set a master key to access the [`/keys`](/reference/api/keys.md) route. Otherwise, you will get a [`missing_master_key`](/reference/errors/error_codes.md#missing-master-key) error.

reference/api/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This API documentation uses the following conventions:
2121

2222
## Authorization
2323

24-
By [providing Meilisearch with a master key at launch](/learn/security/master_api_keys.md#protecting-a-meilisearch-instance), you protect your instance from unauthorized requests. From then on, you must include the `Authorization` header along with a valid API key to access protected routes (all routes except [`/health`](/reference/api/health.md).
24+
By [providing Meilisearch with a master key at launch](/learn/security/master_api_keys.md#protecting-a-meilisearch-instance), you protect your instance from unauthorized requests. The provided master key must be at least 16 bytes. From then on, you must include the `Authorization` header along with a valid API key to access protected routes (all routes except [`/health`](/reference/api/health.md).
2525

2626
<CodeSamples id="authorization_header_1" />
2727

0 commit comments

Comments
 (0)