feat(import): bind OpenAPI security schemes safely
This commit is contained in:
1 parent
c562d5368d
commit
41a0e46110
38 files changed
+4651
-590
No files matched your search
@@ -135,6 +135,41 @@ impl ApiError {
|
||||
"OpenAPI document is invalid or unsupported"
|
||||
}
|
||||
}
|
||||
(_, "literal_credentials_rejected") => {
|
||||
if russian {
|
||||
"документ OpenAPI содержит literal credential и отклонён"
|
||||
} else {
|
||||
"OpenAPI document contains literal credential material and was rejected"
|
||||
}
|
||||
}
|
||||
(_, "auth_mapping_required") => {
|
||||
if russian {
|
||||
"для требования аутентификации выберите доступный профиль"
|
||||
} else {
|
||||
"an available Auth Profile mapping is required for this authentication requirement"
|
||||
}
|
||||
}
|
||||
(_, "auth_mapping_unsupported") => {
|
||||
if russian {
|
||||
"это требование аутентификации не поддерживается импортом"
|
||||
} else {
|
||||
"this authentication requirement is not supported by import"
|
||||
}
|
||||
}
|
||||
(_, "auth_mapping_invalid") => {
|
||||
if russian {
|
||||
"привязка аутентификации в запросе импорта некорректна"
|
||||
} else {
|
||||
"OpenAPI import authentication mapping is invalid"
|
||||
}
|
||||
}
|
||||
(_, "auth_binding_unavailable") => {
|
||||
if russian {
|
||||
"выбранный профиль аутентификации недоступен для этого импорта"
|
||||
} else {
|
||||
"selected Auth Profile is unavailable for this import"
|
||||
}
|
||||
}
|
||||
(_, "no_methods") => {
|
||||
if russian {
|
||||
"документ OpenAPI не содержит поддерживаемых методов"
|
||||
@@ -195,6 +230,18 @@ impl ApiError {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn openapi_auth_binding_unavailable(locale: OpenApiUploadLocale) -> Self {
|
||||
let message = if locale == OpenApiUploadLocale::Ru {
|
||||
"выбранный профиль аутентификации недоступен для этого импорта"
|
||||
} else {
|
||||
"selected Auth Profile is unavailable for this import"
|
||||
};
|
||||
Self::unprocessable_with_context(
|
||||
message,
|
||||
json!({ "error_code": "openapi_auth_binding_unavailable" }),
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn rate_limited_with_context(message: impl Into<String>, context: Value) -> Self {
|
||||
Self::RateLimited {
|
||||
message: message.into(),
|
||||
@@ -675,6 +722,10 @@ impl From<RegistryError> for ApiError {
|
||||
"value": value,
|
||||
}),
|
||||
),
|
||||
RegistryError::ImportAuthBindingUnavailable => Self::unprocessable_with_context(
|
||||
"selected Auth Profile is unavailable for this import",
|
||||
json!({ "error_code": "openapi_auth_binding_unavailable" }),
|
||||
),
|
||||
RegistryError::YamlImportJobNotFound { job_id } => Self::validation_with_context(
|
||||
format!("yaml import job {job_id} was not found"),
|
||||
json!({ "job_id": job_id }),
|
||||
|
||||
Reference in new issue
Block a user