feat(package,daemon): revoke registry tokens; allow daemon deps updates
This commit is contained in:
1 parent
eb35bb6b6e
commit
c7d2662cf2
11 files changed
+309
-13
No files matched your search
@@ -742,6 +742,33 @@ fetch_tokens(std::string_view registry_url, const RegistryAuth &auth) {
|
||||
return tokens;
|
||||
}
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error>
|
||||
revoke_token(std::string_view registry_url, std::string_view token_id,
|
||||
const RegistryAuth &auth) {
|
||||
auto parsed_url = parse_registry_url(registry_url);
|
||||
if (!parsed_url) {
|
||||
return std::unexpected{parsed_url.error()};
|
||||
}
|
||||
std::map<std::string, std::string, std::less<>> headers;
|
||||
if (!auth.bearer_token.empty()) {
|
||||
headers["Authorization"] = "Bearer " + auth.bearer_token;
|
||||
}
|
||||
const std::string path = "/api/v1/tokens/" + Void::Encoding::Url::encode(token_id);
|
||||
auto reply = send_http_request(*parsed_url, "DELETE", path, headers, {});
|
||||
if (!reply) {
|
||||
return std::unexpected{reply.error()};
|
||||
}
|
||||
if (reply->status != 200) {
|
||||
return std::unexpected{make_error(
|
||||
reply->status == 404 ? Void::System::SystemErrorCode::not_found
|
||||
: reply->status == 401 || reply->status == 403
|
||||
? Void::System::SystemErrorCode::permission_denied
|
||||
: Void::System::SystemErrorCode::io_error,
|
||||
std::format("registry DELETE {} failed with HTTP {}", path, reply->status))};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Void::Result::Result<std::filesystem::path, Void::Result::Error>
|
||||
download_binary_artifact(std::string_view url, std::string_view expected_sha256,
|
||||
const std::filesystem::path &dest_file, const RegistryAuth &auth) {
|
||||
|
||||
Reference in new issue
Block a user