mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 03:55:07 +08:00
Add new error when using /keys without masterkey set
This commit is contained in:
parent
96acbf815d
commit
1cf6efa740
@ -9,6 +9,8 @@ pub enum AuthenticationError {
|
|||||||
// Triggered on configuration error.
|
// Triggered on configuration error.
|
||||||
#[error("An internal error has occurred. `Irretrievable state`.")]
|
#[error("An internal error has occurred. `Irretrievable state`.")]
|
||||||
IrretrievableState,
|
IrretrievableState,
|
||||||
|
#[error("Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.")]
|
||||||
|
MissingMasterKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ErrorCode for AuthenticationError {
|
impl ErrorCode for AuthenticationError {
|
||||||
@ -17,6 +19,7 @@ impl ErrorCode for AuthenticationError {
|
|||||||
AuthenticationError::MissingAuthorizationHeader => Code::MissingAuthorizationHeader,
|
AuthenticationError::MissingAuthorizationHeader => Code::MissingAuthorizationHeader,
|
||||||
AuthenticationError::InvalidToken => Code::InvalidToken,
|
AuthenticationError::InvalidToken => Code::InvalidToken,
|
||||||
AuthenticationError::IrretrievableState => Code::Internal,
|
AuthenticationError::IrretrievableState => Code::Internal,
|
||||||
|
AuthenticationError::MissingMasterKey => Code::MissingMasterKey,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ impl<P, D> GuardedData<P, D> {
|
|||||||
}),
|
}),
|
||||||
None => Err(AuthenticationError::IrretrievableState.into()),
|
None => Err(AuthenticationError::IrretrievableState.into()),
|
||||||
},
|
},
|
||||||
None => Err(AuthenticationError::MissingAuthorizationHeader.into()),
|
None => Err(AuthenticationError::MissingMasterKey.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +144,7 @@ pub enum Code {
|
|||||||
InvalidStore,
|
InvalidStore,
|
||||||
InvalidToken,
|
InvalidToken,
|
||||||
MissingAuthorizationHeader,
|
MissingAuthorizationHeader,
|
||||||
|
MissingMasterKey,
|
||||||
NoSpaceLeftOnDevice,
|
NoSpaceLeftOnDevice,
|
||||||
DumpNotFound,
|
DumpNotFound,
|
||||||
TaskNotFound,
|
TaskNotFound,
|
||||||
@ -231,6 +232,9 @@ impl Code {
|
|||||||
MissingAuthorizationHeader => {
|
MissingAuthorizationHeader => {
|
||||||
ErrCode::authentication("missing_authorization_header", StatusCode::UNAUTHORIZED)
|
ErrCode::authentication("missing_authorization_header", StatusCode::UNAUTHORIZED)
|
||||||
}
|
}
|
||||||
|
MissingMasterKey => {
|
||||||
|
ErrCode::authentication("missing_master_key", StatusCode::UNAUTHORIZED)
|
||||||
|
}
|
||||||
TaskNotFound => ErrCode::invalid("task_not_found", StatusCode::NOT_FOUND),
|
TaskNotFound => ErrCode::invalid("task_not_found", StatusCode::NOT_FOUND),
|
||||||
DumpNotFound => ErrCode::invalid("dump_not_found", StatusCode::NOT_FOUND),
|
DumpNotFound => ErrCode::invalid("dump_not_found", StatusCode::NOT_FOUND),
|
||||||
NoSpaceLeftOnDevice => {
|
NoSpaceLeftOnDevice => {
|
||||||
|
Loading…
Reference in New Issue
Block a user