Skip to content

Commit 978fc2d

Browse files
authored
Add missing default API keys in the engine (#3442)
1 parent 2f2a5d2 commit 978fc2d

4 files changed

Lines changed: 94 additions & 10 deletions

File tree

guides/vercel.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Once you click on **Create project**, you should see the following message: “Y
6767

6868
### Understand and use Meilisearch API keys
6969

70-
Meilisearch creates two default API keys: [`Default Search API Key` and `Default Admin API Key`](/learn/security/basic_security#obtaining-api-keys).
70+
Meilisearch creates [four default API keys](/learn/security/basic_security#obtaining-api-keys): `Default Search API Key`, `Default Admin API Key`, `Default Read-Only Admin API Key`, and `Default Chat API Key`.
7171

7272
#### Admin API key
7373

@@ -77,7 +77,7 @@ Use the `Default Admin API Key`, to control who can access or create new documen
7777

7878
Use the `Default Search API Key` to access the [search route](/reference/api/search). This is the one you want to use in your front end.
7979

80-
Both keys are automatically added to Vercel along with the Meilisearch URL.
80+
The Search and Admin API keys are automatically added to Vercel along with the Meilisearch URL. For more information on the other default keys, consult the [security documentation](/learn/security/basic_security#obtaining-api-keys).
8181

8282
<Tip>
8383
The master key–which hasn’t been added to Vercel–grants users full control over an instance. You can find it in your project’s overview on your [Meilisearch Cloud dashboard](https://cloud.meilisearch.com/projects/?utm_campaign=oss&utm_source=docs&utm_medium=vercel-integration). Read more about [Meilisearch security](https://www.meilisearch.com/docs/learn/security/master_api_keys).

learn/security/basic_security.mdx

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Restart Meilisearch with the argument above to use this new and secure master ke
8383

8484
## Obtaining API keys
8585

86-
When your project is protected, Meilisearch automatically generates two API keys: `Default Search API Key` and `Default Admin API Key`. API keys are authorization tokens designed to safely communicate with the Meilisearch API.
86+
When your project is protected, Meilisearch automatically generates four API keys: `Default Search API Key`, `Default Admin API Key`, `Default Read-Only Admin API Key`, and `Default Chat API Key`. API keys are authorization tokens designed to safely communicate with the Meilisearch API.
8787

8888
### Obtaining API keys in Meilisearch Cloud
8989

@@ -103,7 +103,7 @@ Use your master key to query the `/keys` endpoint to view all API keys in your i
103103
Only use the master key to manage API keys. Never use the master key to perform searches or other common operations.
104104
</Warning>
105105

106-
Meilisearch's response will include at least the two default API keys:
106+
Meilisearch's response will include at least the default API keys:
107107

108108
```json
109109
{
@@ -112,7 +112,7 @@ Meilisearch's response will include at least the two default API keys:
112112
"name": "Default Search API Key",
113113
"description": "Use it to search from the frontend",
114114
"key": "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33",
115-
"uid": "123-345-456-987-abc",
115+
"uid": "74c9c733-3368-4738-bbe5-1d18a5fecb37",
116116
"actions": [
117117
"search"
118118
],
@@ -127,7 +127,7 @@ Meilisearch's response will include at least the two default API keys:
127127
"name": "Default Admin API Key",
128128
"description": "Use it for anything that is not a search operation. Caution! Do not expose it on a public frontend",
129129
"key": "62cdb7020ff920e5aa642c3d4066950dd1f01f4d",
130-
"uid": "123-345-456-987-abc",
130+
"uid": "20f7e4c4-612c-4dd1-b783-7934cc038213",
131131
"actions": [
132132
"*"
133133
],
@@ -137,6 +137,38 @@ Meilisearch's response will include at least the two default API keys:
137137
"expiresAt": null,
138138
"createdAt": "2024-01-25T16:19:53.94816Z",
139139
"updatedAt": "2024-01-25T16:19:53.94816Z"
140+
},
141+
{
142+
"name": "Default Read-Only Admin API Key",
143+
"description": "Use it to read information across the whole database. Caution! Do not expose this key on a public frontend",
144+
"key": "9e32fb64e3569a749b0b87900d1026074e798743",
145+
"uid": "7dc1ec09-94fb-49b5-b77b-03ce75af89a0",
146+
"actions": [
147+
"*.get",
148+
"keys.get"
149+
],
150+
"indexes": [
151+
"*"
152+
],
153+
"expiresAt": null,
154+
"createdAt": "2024-01-25T16:19:53.94716Z",
155+
"updatedAt": "2024-01-25T16:19:53.94716Z"
156+
},
157+
{
158+
"name": "Default Chat API Key",
159+
"description": "Use it to chat and search from the frontend",
160+
"key": "0acaa4f3d57517e4b4d7c0052b02772620bd375a",
161+
"uid": "d4e13ace-2a00-428c-90d1-b1c99eec98bd",
162+
"actions": [
163+
"chatCompletions",
164+
"search"
165+
],
166+
"indexes": [
167+
"*"
168+
],
169+
"expiresAt": null,
170+
"createdAt": "2024-01-25T16:19:53.94606Z",
171+
"updatedAt": "2024-01-25T16:19:53.94606Z"
140172
}
141173
],
142174
@@ -155,6 +187,21 @@ Then use the `Default Search API Key` to perform search operations in the index
155187

156188
<CodeSamplesBasicSecurityTutorialSearch1 />
157189

190+
### Admin API keys
191+
192+
Meilisearch provides two admin API keys for managing your instance:
193+
194+
- The `Default Admin API Key` grants full access to all Meilisearch operations except API key management. Use it to configure index settings, add documents, and perform other administrative tasks.
195+
- The `Default Read-Only Admin API Key` allows read-only access to the whole database. Use it when you need to retrieve information from your Meilisearch instance without being able to modify it.
196+
197+
<Warning>
198+
Do not expose admin API keys on a public frontend.
199+
</Warning>
200+
201+
### Chat API key
202+
203+
The `Default Chat API Key` is designed for frontend usage with [conversational search](/learn/chat/getting_started_with_chat). It has access to both `search` and `chatCompletions` actions, allowing users to both perform searches and interact with the chat completions feature.
204+
158205
## Conclusion
159206

160207
You have successfully secured Meilisearch by configuring a master key. You then saw how to access the Meilisearch API by adding an API key to your request's authorization header.

learn/security/differences_master_api_keys.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ API keys grant access to a specific set of indexes, routes, and endpoints. You c
2424

2525
**Use API keys for all API operations except API key management.** This includes search, configuring index settings, managing indexes, and adding and updating documents.
2626

27-
In many cases, the default API keys are all you need to safely manage your Meilisearch project. Use the `Default Search API key` for searching, and the `Default Admin API Key` to configure index settings, add documents, and other operations.
27+
In many cases, the default API keys are all you need to safely manage your Meilisearch project:
28+
29+
- Use the `Default Search API Key` for search operations from the frontend
30+
- Use the `Default Admin API Key` to configure index settings, add documents, and other operations. Do not expose it on a public frontend
31+
- Use the `Default Read-Only Admin API Key` for read-only access to all indexes, documents, and settings. Do not expose it on a public frontend
32+
- Use the `Default Chat API Key` for [conversational search](/learn/chat/getting_started_with_chat). It can be safely used from the frontend

reference/api/keys.mdx

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Results can be paginated using the `offset` and `limit` query parameters.
198198
},
199199
{
200200
"name": "Default Search API Key",
201-
"description": "Use it to search from the frontend code",
201+
"description": "Use it to search from the frontend",
202202
"key": "0a6e572506c52ab0bd6195921575d23092b7f0c284ab4ac86d12346c33057f99",
203203
"uid": "74c9c733-3368-4738-bbe5-1d18a5fecb37",
204204
"actions": [
@@ -225,11 +225,43 @@ Results can be paginated using the `offset` and `limit` query parameters.
225225
"expiresAt": null,
226226
"createdAt": "2021-08-11T10:00:00Z",
227227
"updatedAt": "2021-08-11T10:00:00Z"
228+
},
229+
{
230+
"name": "Default Read-Only Admin API Key",
231+
"description": "Use it to read information across the whole database. Caution! Do not expose this key on a public frontend",
232+
"key": "9e32fb64e3569a749b0b87900d1026074e798743cde77bf44c9ef33884100923",
233+
"uid": "7dc1ec09-94fb-49b5-b77b-03ce75af89a0",
234+
"actions": [
235+
"*.get",
236+
"keys.get"
237+
],
238+
"indexes": [
239+
"*"
240+
],
241+
"expiresAt": null,
242+
"createdAt": "2021-08-11T10:00:00Z",
243+
"updatedAt": "2021-08-11T10:00:00Z"
244+
},
245+
{
246+
"name": "Default Chat API Key",
247+
"description": "Use it to chat and search from the frontend",
248+
"key": "0acaa4f3d57517e4b4d7c0052b02772620bd375a2a5e742aaebf7f6b8b9638cc",
249+
"uid": "d4e13ace-2a00-428c-90d1-b1c99eec98bd",
250+
"actions": [
251+
"chatCompletions",
252+
"search"
253+
],
254+
"indexes": [
255+
"*"
256+
],
257+
"expiresAt": null,
258+
"createdAt": "2021-08-11T10:00:00Z",
259+
"updatedAt": "2021-08-11T10:00:00Z"
228260
}
229261
],
230262
"offset": 0,
231-
"limit": 3,
232-
"total": 7
263+
"limit": 20,
264+
"total": 5
233265
}
234266
```
235267

0 commit comments

Comments
 (0)