102 std::string base_url_;
103 std::optional<std::string> tenant_slug_;
104 std::optional<std::string> tenant_id_;
105 std::optional<std::string> org_slug_;
106 std::optional<std::string> org_id_;
107 unsigned max_concurrent_requests_ = 16;
108 std::string custom_ca_pem_;
109 std::string client_cert_pem_;
110 std::string client_key_pem_;
111 std::chrono::milliseconds connect_timeout_{10000};
112 std::chrono::milliseconds request_timeout_{30000};
114 bool retry_enabled_ =
true;
117 std::chrono::milliseconds decision_memo_ttl_{0};
128 const std::string& totp_code);
135 std::optional<std::string> scope = std::nullopt,
136 std::optional<std::string> subject_id = std::nullopt);
138 std::optional<std::string> scope = std::nullopt,
139 std::optional<std::string> subject_id = std::nullopt);
140 std::vector<AccessDecision>
batch_check(
const std::vector<AccessCheck>& checks);
147 std::future<LoginResult>
login_async(std::string username_or_email, std::string password);
150 std::optional<std::string> scope = std::nullopt,
151 std::optional<std::string> subject_id = std::nullopt);
166 std::function<
void(std::chrono::milliseconds)> sleeper);
199 std::shared_ptr<Impl> p_;
200 explicit Client(std::shared_ptr<Impl> impl);
Builder & tenant_id(std::string id)
Builder & request_timeout(std::chrono::milliseconds ms)
Builder & telemetry_hook(TelemetryHook hook)
§19: install a telemetry sink.
Builder & with_custom_ca(std::string ca_pem)
§6: add a custom CA (PEM) to the trust chain.
Builder & connect_timeout(std::chrono::milliseconds ms)
Builder & retry_enabled(bool enabled)
§16: enable or disable the bounded read-only retry policy.
Client build()
Validates required fields and constructs the client.
Builder & base_url(std::string url)
Server base URL.
Builder & transport(Transport t)
Override the HTTP transport (test seam).
Builder & decision_memo_ttl(std::chrono::milliseconds ttl)
§17: enable the client-side decision memo with a TTL.
Builder & tenant_slug(std::string slug)
Builder & org_slug(std::string slug)
Builder & max_concurrent_requests(unsigned n)
How many requests this client may have in flight at once (default 16).
Builder & org_id(std::string id)
Builder & with_client_cert(std::string cert_pem, std::string key_pem)
§6.1: present a client identity certificate (PEM chain + PEM key) for mutual TLS.
const std::string & tenant_header() const
Tenant identifier injected as X-Tenant-ID on every request (§5).
LoginResult login(const std::string &username_or_email, const std::string &password)
JwksVerifier & jwks()
Shared JWKS verifier bound to this client's transport + base URL.
AccessDecision can(const std::string &action, const std::string &resource_id, std::optional< std::string > scope=std::nullopt, std::optional< std::string > subject_id=std::nullopt)
void close()
Deterministic shutdown (CONTRACT.md §18).
std::future< LoginResult > login_async(std::string username_or_email, std::string password)
LoginResult verify_mfa(const Sensitive< std::string > &challenge_token, const std::string &totp_code)
Complete an MFA challenge.
int refresh_call_count() const
Number of times a network refresh call was actually issued (§9 assertion).
std::future< std::vector< AccessDecision > > batch_check_async(std::vector< AccessCheck > checks)
AccessDecision check_access(const std::string &action, const std::string &resource_id, std::optional< std::string > scope=std::nullopt, std::optional< std::string > subject_id=std::nullopt)
std::future< TokenPair > refresh_async()
LoginResult verify_mfa(const std::string &challenge_token, const std::string &totp_code)
Overload for a challenge token obtained out of band (e.g.
std::optional< std::string > csrf_token() const
Currently-stored CSRF token, if any (§3).
DeviceAuth authenticate_device()
§6.1 device / service-account authentication via the configured mTLS client certificate (POST /api/v1...
bool has_session() const
Whether a session has been established (login/verify_mfa succeeded).
std::future< AccessDecision > check_access_async(std::string action, std::string resource_id, std::optional< std::string > scope=std::nullopt, std::optional< std::string > subject_id=std::nullopt)
void _set_retry_test_seams(std::function< double()> jitter, std::function< void(std::chrono::milliseconds)> sleeper)
Test seam: replace the §16 jitter source and the sleep.
std::vector< AccessDecision > batch_check(const std::vector< AccessCheck > &checks)
Wraps secret material (access tokens, mTLS private keys).
Definition sensitive.hpp:26
Definition authenticator.hpp:40
std::function< HttpResponse(const HttpRequest &)> Transport
The transport seam. Injectable; defaults to the libcurl implementation.
Definition transport.hpp:56
std::function< void(const TelemetryEvent &)> TelemetryHook
A caller-supplied telemetry sink (§19).
Definition telemetry.hpp:134
Result of an access check (CheckAccessResponse).
Definition types.hpp:86
mTLS device authentication result (POST /api/v1/auth/device).
Definition types.hpp:51
Result of login / verify_mfa.
Definition types.hpp:27
Result of a token refresh (§9).
Definition types.hpp:45