2096: feat(auth): Tenant token r=Kerollmops a=ManyTheFish

Make meilisearch support JWT authentication signed with meilisearch API keys
using HS256, HS384 or HS512 algorithms.

Related spec: [specifications#89](https://github.com/meilisearch/specifications/pull/89) [rendered](https://github.com/meilisearch/specifications/blob/scoped-api-keys/text/0089-tenant-tokens.md)
Fix #1991 


Co-authored-by: ManyTheFish <many@meilisearch.com>
This commit is contained in:
bors[bot] 2022-01-27 10:38:41 +00:00 committed by GitHub
commit 622c15e825
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 980 additions and 109 deletions

View file

@ -1,3 +1,4 @@
use meilisearch_auth::SearchRules;
use std::collections::BTreeMap;
use std::fmt;
use std::io::Cursor;
@ -559,17 +560,14 @@ where
Ok(stats)
}
pub async fn get_all_stats(&self, index_filter: &Option<Vec<String>>) -> Result<Stats> {
pub async fn get_all_stats(&self, search_rules: &SearchRules) -> Result<Stats> {
let mut last_task: Option<DateTime<_>> = None;
let mut indexes = BTreeMap::new();
let mut database_size = 0;
let processing_task = self.task_store.get_processing_task().await?;
for (index_uid, index) in self.index_resolver.list().await? {
if index_filter
.as_ref()
.map_or(false, |filter| !filter.contains(&index_uid))
{
if !search_rules.is_index_authorized(&index_uid) {
continue;
}