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
@@ -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