-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Audit Logging] Authz policy support for audit logging #32944
Merged
Merged
Changes from 5 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
5f36c9b
audit logging APIs
rockspore 1ef7536
const functions
rockspore d73779e
fix include guards
rockspore 5fa99bc
move .cc to src/cpp/server
rockspore 8a75d02
trailing newline
rockspore e77a037
changed the design
rockspore c6b1174
add register impl in C++
rockspore 6ab33b3
remove extra include
rockspore c623c9e
newlines
rockspore 3b85b67
include port_platform
rockspore ba8b7ae
move API headers inside for now
rockspore f9b7748
Merge branch 'master' of https://github.com/grpc/grpc into audit-log-api
rockspore eb82b4e
put current src into BUILD targets
rockspore c7776d3
generate projects
rockspore 579fb6b
virtual dtors, etc
rockspore ccb3a0c
BUILD
rockspore 70098a0
virtual dtors
rockspore b323fc8
generate projects
rockspore 03a449a
iwyu
rockspore f98b12d
external deps in BUILD
rockspore dc3f3b8
iwyu again
rockspore 0d2fcb5
ctor for audit context
rockspore 07365a4
sanity check
rockspore c5a8598
add tests and move APIs to public headers
rockspore fc810a3
generate projects
rockspore 8e8faec
fix iwyu
rockspore c83b7f0
remove grpc_audit_logging.h from GRPC_PUBLIC_HDRS
rockspore ced9d10
remove unused params
rockspore 8f536de
remove wrapping in C++
rockspore f68d735
Merge branch 'master' of github.com:grpc/grpc into audit-log-api
rockspore 81ef1ed
comments and iwyu
rockspore 8af53a5
iwyu
rockspore ee874d4
add external deps to grpc_public_hdrs
rockspore 2e575a2
comments
rockspore 5dc1b6b
move definition into .cc
rockspore 57c4044
make registry getter private
rockspore daa86a5
generate projects
rockspore 8e5f24d
remove naked include
rockspore e32af2b
fix BUILD
rockspore 930d88b
generate projects
rockspore 8664063
fix cpp header
rockspore a8295ed
constexpr the register func
rockspore 6f6acd1
no lint for unused using decls
rockspore 127f12e
add factory existence API
rockspore df129cc
change registry's parsing API
rockspore 974bb05
remove extraneous directory and file
rockspore d426f9d
address comments
rockspore 06bb361
remove naked include
rockspore 7e51701
Automated change: Fix sanity tests
rockspore 6e4b0ec
Merge pull request #13 from rockspore/create-pull-request/patch-06bb361
rockspore 2f3b29b
change to static members
rockspore dee212e
change to pointers
rockspore e019b5c
remove naked include
rockspore 5f72e8d
audit logging support in rbac policy
rockspore 73fce55
test to propagate error from config parsing
rockspore abbcdbd
Automated change: Fix sanity tests
rockspore bf74d38
remove previous rbac ctor
rockspore da0d370
Merge branch 'master' of github.com:grpc/grpc into rbac_policy
rockspore 8d254a0
Merge pull request #15 from rockspore/create-pull-request/patch-73fce55
rockspore ad9353a
update comment on name
rockspore cdfc43c
address comments
rockspore 80b7305
add assertion on second parsing
rockspore d192bd8
misc
rockspore 107870f
typo
rockspore ae94a3f
iwyu
rockspore ee8f0e1
address comments
rockspore 58c34b7
address comments
rockspore cf6ca41
empty audit logging options
rockspore 8c84dce
dedup include
rockspore 2d49fb2
reject unknown fields
rockspore 7b12304
Merge branch 'master' of github.com:grpc/grpc into rbac_policy
rockspore af73586
address PR comments
rockspore 69baf28
Merge branch 'master' of github.com:grpc/grpc into rbac_policy
rockspore 4b3930c
use new Json APIs
rockspore c8ed194
fix test
rockspore 02f44f5
address PR comments
rockspore c4851c2
iwyu
rockspore File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rockspore marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,14 +345,14 @@ absl::StatusOr<Rbac> ParseDenyRulesArray(const Json& json, | |
absl::string_view name) { | ||
auto policies_or = ParseRulesArray(json); | ||
if (!policies_or.ok()) return policies_or.status(); | ||
return Rbac(Rbac::Action::kDeny, std::move(policies_or.value()), name); | ||
return Rbac(name, Rbac::Action::kDeny, std::move(policies_or.value())); | ||
} | ||
|
||
absl::StatusOr<Rbac> ParseAllowRulesArray(const Json& json, | ||
absl::string_view name) { | ||
auto policies_or = ParseRulesArray(json); | ||
if (!policies_or.ok()) return policies_or.status(); | ||
return Rbac(Rbac::Action::kAllow, std::move(policies_or.value()), name); | ||
return Rbac(name, Rbac::Action::kAllow, std::move(policies_or.value())); | ||
} | ||
|
||
absl::StatusOr<std::unique_ptr<experimental::AuditLoggerFactory::Config>> | ||
|
@@ -374,10 +374,8 @@ ParseAuditLogger(const Json& json, size_t pos) { | |
auto it = json.object().find("is_optional"); | ||
markdroth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (it != json.object().end()) { | ||
switch (it->second.type()) { | ||
case Json::Type::kTrue: | ||
is_optional = true; | ||
break; | ||
case Json::Type::kFalse: | ||
case Json::Type::kBoolean: | ||
is_optional = it->second.boolean(); | ||
break; | ||
default: | ||
return absl::InvalidArgumentError(absl::StrFormat( | ||
|
@@ -394,7 +392,8 @@ ParseAuditLogger(const Json& json, size_t pos) { | |
absl::StrFormat("\"audit_loggers[%d].name\" is not a string.", pos)); | ||
} | ||
absl::string_view name = it->second.string(); | ||
Json config = Json::Object(); | ||
// The config defaults to an empty object. | ||
Json config = Json::FromObject(Json::Object()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can just say There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed. |
||
it = json.object().find("config"); | ||
if (it != json.object().end()) { | ||
if (it->second.type() != Json::Type::kObject) { | ||
|
@@ -420,7 +419,8 @@ ParseAuditLogger(const Json& json, size_t pos) { | |
return result; | ||
} | ||
|
||
absl::Status ParseAuditLoggingOptions(RbacPolicies& rbacs, const Json& json) { | ||
absl::Status ParseAuditLoggingOptions(const Json& json, RbacPolicies* rbacs) { | ||
GPR_ASSERT(rbacs != nullptr); | ||
for (auto it = json.object().begin(); it != json.object().end(); ++it) { | ||
if (it->first == "audit_condition") { | ||
if (it->second.type() != Json::Type::kString) { | ||
|
@@ -445,10 +445,10 @@ absl::Status ParseAuditLoggingOptions(RbacPolicies& rbacs, const Json& json) { | |
return absl::InvalidArgumentError(absl::StrFormat( | ||
"Unsupported \"audit_condition\" value %s.", condition)); | ||
} | ||
if (rbacs.deny_policy != absl::nullopt) { | ||
rbacs.deny_policy->audit_condition = deny_condition; | ||
if (rbacs->deny_policy.has_value()) { | ||
rbacs->deny_policy->audit_condition = deny_condition; | ||
} | ||
rbacs.allow_policy.audit_condition = allow_condition; | ||
rbacs->allow_policy.audit_condition = allow_condition; | ||
} else if (it->first == "audit_loggers") { | ||
if (it->second.type() != Json::Type::kArray) { | ||
return absl::InvalidArgumentError("\"audit_loggers\" is not an array."); | ||
|
@@ -463,19 +463,19 @@ absl::Status ParseAuditLoggingOptions(RbacPolicies& rbacs, const Json& json) { | |
// return ok when marked as optional. | ||
if (result.value() != nullptr) { | ||
// Only move the logger config over if audit condition is not NONE. | ||
if (rbacs.allow_policy.audit_condition != | ||
if (rbacs->allow_policy.audit_condition != | ||
Rbac::AuditCondition::kNone) { | ||
rbacs.allow_policy.logger_configs.push_back( | ||
rbacs->allow_policy.logger_configs.push_back( | ||
std::move(result.value())); | ||
} | ||
if (rbacs.deny_policy != absl::nullopt && | ||
rbacs.deny_policy->audit_condition != | ||
if (rbacs->deny_policy.has_value() && | ||
rbacs->deny_policy->audit_condition != | ||
Rbac::AuditCondition::kNone) { | ||
// Parse again since it returns unique_ptr, but result should be ok | ||
// this time. | ||
auto result = ParseAuditLogger(loggers.at(i), i); | ||
GPR_ASSERT(result.ok()); | ||
rbacs.deny_policy->logger_configs.push_back( | ||
rbacs->deny_policy->logger_configs.push_back( | ||
std::move(result.value())); | ||
} | ||
} | ||
|
@@ -553,7 +553,7 @@ absl::StatusOr<RbacPolicies> GenerateRbacPolicies( | |
return absl::InvalidArgumentError( | ||
"\"audit_logging_options\" is not an object."); | ||
} | ||
absl::Status status = ParseAuditLoggingOptions(rbacs, it->second); | ||
absl::Status status = ParseAuditLoggingOptions(it->second, &rbacs); | ||
if (!status.ok()) { | ||
return status; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well take the name parameter as
std::string
instead ofabsl::string_view
, since we're making a copy anyway. That way, if a caller happens to have a temp string that they don't need to keep, they can pass it in withstd::move()
and avoid the copy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks for the tip!