feat(auth): API keys

implements:
https://github.com/meilisearch/specifications/blob/develop/text/0085-api-keys.md

- Add tests on API keys management route (meilisearch-http/tests/auth/api_keys.rs)
- Add tests checking authorizations on each meilisearch routes (meilisearch-http/tests/auth/authorization.rs)
- Implement API keys management routes (meilisearch-http/src/routes/api_key.rs)
- Create module to manage API keys and authorizations (meilisearch-auth)
- Reimplement GuardedData to extend authorizations (meilisearch-http/src/extractors/authentication/mod.rs)
- Change X-MEILI-API-KEY by Authorization Bearer (meilisearch-http/src/extractors/authentication/mod.rs)
- Change meilisearch routes to fit to the new authorization feature (meilisearch-http/src/routes/)

- close #1867
This commit is contained in:
many 2021-11-08 18:31:27 +01:00
parent fa196986c2
commit ffefd0caf2
No known key found for this signature in database
GPG key ID: 2CEF23B75189EACA
44 changed files with 3155 additions and 361 deletions

34
Cargo.lock generated
View file

@ -314,6 +314,16 @@ dependencies = [
"stable_deref_trait",
]
[[package]]
name = "assert-json-diff"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f1c3703dd33532d7f0ca049168930e9099ecac238e23cf932f3a69c42f06da"
dependencies = [
"serde",
"serde_json",
]
[[package]]
name = "async-stream"
version = "0.3.2"
@ -1600,12 +1610,33 @@ dependencies = [
"syn 0.15.44",
]
[[package]]
name = "maplit"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]]
name = "matches"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "meilisearch-auth"
version = "0.24.0"
dependencies = [
"chrono",
"enum-iterator",
"heed",
"meilisearch-error",
"rand",
"serde",
"serde_json",
"sha2",
"thiserror",
]
[[package]]
name = "meilisearch-error"
version = "0.24.0"
@ -1629,6 +1660,7 @@ dependencies = [
"actix-web-static-files",
"anyhow",
"arc-swap",
"assert-json-diff",
"async-stream",
"async-trait",
"bstr",
@ -1649,6 +1681,8 @@ dependencies = [
"indexmap",
"itertools",
"log",
"maplit",
"meilisearch-auth",
"meilisearch-error",
"meilisearch-lib",
"meilisearch-tokenizer 0.2.5",