mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
add implementation for no master key set and fix tests
This commit is contained in:
parent
1cf6efa740
commit
f0ecacb58d
3 changed files with 53 additions and 29 deletions
|
@ -50,14 +50,20 @@ impl<P, D> GuardedData<P, D> {
|
|||
{
|
||||
match Self::authenticate(auth, String::new(), None).await? {
|
||||
Some(filters) => match data {
|
||||
Some(data) => Ok(Self {
|
||||
data,
|
||||
filters,
|
||||
_marker: PhantomData,
|
||||
}),
|
||||
Some(data) => {
|
||||
if filters.is_missing_master_key() {
|
||||
Err(AuthenticationError::MissingMasterKey.into())
|
||||
} else {
|
||||
Ok(Self {
|
||||
data,
|
||||
filters,
|
||||
_marker: PhantomData,
|
||||
})
|
||||
}
|
||||
}
|
||||
None => Err(AuthenticationError::IrretrievableState.into()),
|
||||
},
|
||||
None => Err(AuthenticationError::MissingMasterKey.into()),
|
||||
None => Err(AuthenticationError::MissingAuthorizationHeader.into()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,6 +177,9 @@ pub mod policies {
|
|||
token: &str,
|
||||
index: Option<&str>,
|
||||
) -> Option<AuthFilter> {
|
||||
if auth.get_master_key().is_none() && is_keys_action(A) {
|
||||
return Some(AuthFilter::with_no_master_key());
|
||||
}
|
||||
// authenticate if token is the master key.
|
||||
// master key can only have access to keys routes.
|
||||
// if master key is None only keys routes are inaccessible.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue