feat(security): add SecureBuffer, VSEC envelopes, authorization, and SecurityAsync Authenticator
This commit is contained in:
1 parent
eb42228604
commit
713d2dc656
20 files changed
+4070
-43
No files matched your search
@@ -179,6 +179,24 @@ if(_has_crypto_async)
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
endif()
|
||||
|
||||
has_modules(_has_security Security Time Functional)
|
||||
if(_has_security)
|
||||
run_consumer(SecurityOnly "${install_prefix}" "SecurityOnly"
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
endif()
|
||||
|
||||
has_modules(_has_security_async SecurityAsync Security Async Time Resilience Functional)
|
||||
if(_has_security_async)
|
||||
run_consumer(SecurityAsyncOnly "${install_prefix}" "SecurityAsyncOnly"
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
endif()
|
||||
|
||||
# Foundation consumer with Core-formatting bridge and zero external packages.
|
||||
has_modules(_has_foundation Math Text Time Functional Binary FunctionalCoreFormatting Memory Core)
|
||||
if(_has_foundation)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidSecurityAsyncOnlyConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS SecurityAsync)
|
||||
|
||||
add_executable(void_security_async_only_consumer main.cpp)
|
||||
target_link_libraries(void_security_async_only_consumer PRIVATE Void::SecurityAsync)
|
||||
target_compile_features(void_security_async_only_consumer PRIVATE cxx_std_26)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME SecurityAsyncOnlyConsumer COMMAND void_security_async_only_consumer)
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <Void/Async/Executor.hpp>
|
||||
#include <Void/Security/Authenticator.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
int main()
|
||||
{
|
||||
auto store = std::make_shared<Void::SecurityAsync::InMemoryAccountSessionStore>();
|
||||
Void::Async::ManualExecutor exec;
|
||||
Void::SecurityAsync::AuthenticatorOptions opts{};
|
||||
opts.dummy_hash_strength = Void::Security::PasswordHashStrength::Interactive;
|
||||
auto auth = Void::SecurityAsync::Authenticator::create(store, exec, opts);
|
||||
if (!auth.has_value()) {
|
||||
return 1;
|
||||
}
|
||||
if ((*auth)->stats().active_password_jobs != 0) {
|
||||
return 2;
|
||||
}
|
||||
(void)(*auth)->close_and_join();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidSecurityOnlyConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS Security)
|
||||
|
||||
add_executable(void_security_only_consumer main.cpp)
|
||||
target_link_libraries(void_security_only_consumer PRIVATE Void::Security)
|
||||
target_compile_features(void_security_only_consumer PRIVATE cxx_std_26)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME SecurityOnlyConsumer COMMAND void_security_only_consumer)
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <Void/Security/Authorization.hpp>
|
||||
#include <Void/Security/Envelope.hpp>
|
||||
#include <Void/Security/SecureBuffer.hpp>
|
||||
#include <Void/Security/Security.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
int main()
|
||||
{
|
||||
Void::Security::SecretKeyRing ring;
|
||||
if (!ring.generate_and_add_key("v1", true).has_value()) {
|
||||
return 1;
|
||||
}
|
||||
const std::vector<unsigned char> pt{'o', 'k'};
|
||||
auto env = ring.seal(pt);
|
||||
if (!env.has_value()) {
|
||||
return 2;
|
||||
}
|
||||
auto dec = ring.open(*env);
|
||||
if (!dec.has_value() || dec->size() != pt.size()) {
|
||||
return 3;
|
||||
}
|
||||
auto policy = Void::Security::PolicySnapshot::create(1, {});
|
||||
if (!policy.has_value()) {
|
||||
return 4;
|
||||
}
|
||||
const Void::Security::Principal p{.subject = "u1"};
|
||||
const Void::Security::ResourceAttributes r{.resource_type = "doc"};
|
||||
if (policy->authorize(p, "read", r).allowed) {
|
||||
return 5;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user