Go to the documentation of this file.
23 #include "absl/memory/memory.h"
47 if (!policies_or.ok()) {
48 return policies_or.status();
50 return MakeRefCounted<StaticDataAuthorizationPolicyProvider>(
57 std::
move(policies.allow_policy))),
59 std::
move(policies.deny_policy))) {}
75 return policy_contents;
91 auto provider = MakeRefCounted<FileWatcherAuthorizationPolicyProvider>(
92 authz_policy_path, refresh_interval_sec, &
status);
100 : authz_policy_path_(
std::
string(authz_policy_path)),
101 refresh_interval_sec_(refresh_interval_sec) {
108 auto thread_lambda = [](
void*
arg) {
114 &provider->shutdown_event_,
115 TimeoutSecondsToDeadline(provider->refresh_interval_sec_));
116 if (
value !=
nullptr) {
122 "authorization policy reload status. code=%d error_details=%s",
128 "FileWatcherAuthorizationPolicyProvider_refreshing_thread", thread_lambda,
140 bool contents_changed =
false;
143 if (
cb_ !=
nullptr) {
150 if (!file_contents.
ok()) {
151 return done_early(file_contents.
status());
157 contents_changed =
true;
159 if (!rbac_policies_or.ok()) {
160 return done_early(rbac_policies_or.status());
163 allow_engine_ = MakeRefCounted<GrpcAuthorizationEngine>(
164 std::move(rbac_policies_or->allow_policy));
165 deny_engine_ = MakeRefCounted<GrpcAuthorizationEngine>(
166 std::move(rbac_policies_or->deny_policy));
167 if (
cb_ !=
nullptr) {
172 "authorization policy reload status: successfully loaded new "
193 const char** error_details) {
197 if (!provider_or.ok()) {
203 return provider_or->release();
208 const char* authz_policy_path,
unsigned int refresh_interval_sec,
212 authz_policy_path, refresh_interval_sec);
213 if (!provider_or.ok()) {
219 return provider_or->release();
224 if (provider !=
nullptr) provider->
Unref();
Status InvalidArgumentError(absl::string_view message)
std::chrono::duration< std::int_fast64_t > seconds
RefCountedPtr< T > MakeRefCounted(Args &&... args)
std::unique_ptr< Thread > refresh_thread_
grpc_error_handle grpc_load_file(const char *filename, int add_null_terminator, grpc_slice *output)
FileWatcherAuthorizationPolicyProvider(absl::string_view authz_policy_path, unsigned int refresh_interval_sec, absl::Status *status)
absl::string_view StringViewFromSlice(const grpc_slice &slice)
GPRAPI void gpr_event_set(gpr_event *ev, void *value)
StaticDataAuthorizationPolicyProvider(RbacPolicies policies)
WeakRefCountedPtr< grpc_authorization_policy_provider > WeakRef() GRPC_MUST_USE_RESULT
absl::Status ForceUpdate()
#define GRPC_TRACE_FLAG_ENABLED(f)
grpc_authorization_policy_provider * grpc_authorization_policy_provider_static_data_create(const char *authz_policy, grpc_status_code *code, const char **error_details)
static absl::StatusOr< RefCountedPtr< grpc_authorization_policy_provider > > Create(absl::string_view authz_policy)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
def c_str(s, encoding='ascii')
gpr_event shutdown_event_
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
absl::string_view message() const
GPRAPI grpc_slice grpc_empty_slice(void)
std::string authz_policy_path_
absl::StatusOr< RbacPolicies > GenerateRbacPolicies(absl::string_view authz_policy)
GPRAPI void gpr_event_init(gpr_event *ev)
std::string file_contents_
GPRAPI gpr_timespec gpr_now(gpr_clock_type clock)
GPRAPI void * gpr_event_wait(gpr_event *ev, gpr_timespec abs_deadline)
ABSL_MUST_USE_RESULT bool ok() const
GPRAPI gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b)
grpc_authorization_policy_provider * grpc_authorization_policy_provider_file_watcher_create(const char *authz_policy_path, unsigned int refresh_interval_sec, grpc_status_code *code, const char **error_details)
std::string grpc_error_std_string(grpc_error_handle error)
void grpc_authorization_policy_provider_release(grpc_authorization_policy_provider *provider)
void SetCallbackForTesting(std::function< void(bool contents_changed, absl::Status Status)> cb)
ABSL_MUST_USE_RESULT bool ok() const
#define GRPC_ERROR_UNREF(err)
GPRAPI char * gpr_strdup(const char *src)
constexpr bool empty() const noexcept
static absl::StatusOr< RefCountedPtr< grpc_authorization_policy_provider > > Create(absl::string_view authz_policy_path, unsigned int refresh_interval_sec)
absl::StatusCode code() const
TraceFlag grpc_authz_trace
OPENSSL_EXPORT pem_password_cb * cb
void grpc_slice_unref_internal(const grpc_slice &slice)
const Status & status() const &
GPRAPI gpr_timespec gpr_time_from_seconds(int64_t s, gpr_clock_type clock_type)
#define GRPC_ERROR_IS_NONE(err)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:44