Skip to content
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] Audit logging config translation by rbac service config parser #33145

Merged
merged 23 commits into from May 17, 2023

Conversation

rockspore
Copy link
Contributor

This translates the service config from HTTP RBAC filter into the rbac policy, which is used to construct authorization engines.

Copy link
Contributor

@gtcooke94 gtcooke94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question, otherwise looks good.
Though I am certainly no JSON C++ expert, the code makes logical sense at least :)

src/core/ext/filters/rbac/rbac_service_config_parser.cc Outdated Show resolved Hide resolved
@rockspore rockspore requested a review from markdroth May 16, 2023 22:32
Copy link
Member

@markdroth markdroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good overall! There are some details to address, though.

Please let me know if you have any questions. Thanks!

@rockspore rockspore requested a review from markdroth May 17, 2023 16:52
@rockspore rockspore requested a review from markdroth May 17, 2023 19:09
Copy link
Member

@markdroth markdroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Feel free to merge after addressing the remaining comments.

@@ -200,7 +200,7 @@ struct RbacConfig {
int action;
std::map<std::string, Policy> policies;
// Defaults to 0 since its json field is optional.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/0/kNone/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

EXPECT_EQ(logger_configs_.find("test_logger")->second, "{\"foo\":\"bar\"}");
const auto& loggers =
parsed_rbac_config->authorization_engine(0)->audit_loggers();
ASSERT_EQ(loggers.size(), 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest writing this as:

EXPECT_THAT(
    loggers
    ::testing::ElementsAre(
        ::testing::Property(&AuditLogger::name, "stdout_logger"),
        ::testing::Property(&AuditLogger::name, kLoggerName)));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I had to use

  EXPECT_THAT(parsed_rbac_config->authorization_engine(0)->audit_loggers(),
              ::testing::ElementsAre(::testing::Pointee(::testing::Property(
                                         &AuditLogger::name, "stdout_logger")),
                                     ::testing::Pointee(::testing::Property(
                                         &AuditLogger::name, kLoggerName))));

because the vector stores unique pointers.

@rockspore rockspore merged commit f60d0c7 into grpc:master May 17, 2023
63 of 65 checks passed
@copybara-service copybara-service bot added the imported Specifies if the PR has been imported to the internal repository label May 17, 2023
wanlin31 pushed a commit that referenced this pull request May 18, 2023
…ig parser (#33145)

This translates the service config from HTTP RBAC filter into the rbac
policy, which is used to construct authorization engines.
eugeneo added a commit that referenced this pull request May 18, 2023
veblush pushed a commit that referenced this pull request May 18, 2023
…ice config parser" (#33178)

Reverts #33145

It causes internal breakages.
rockspore added a commit that referenced this pull request May 18, 2023
…t logging (#33183)

This is basically the same as #33145 except that the ctor `Rules()`
cannot be default but have to explicitly set a default audit condition.
eugeneo pushed a commit to eugeneo/grpc that referenced this pull request May 19, 2023
…t logging (grpc#33183)

This is basically the same as grpc#33145 except that the ctor `Rules()`
cannot be default but have to explicitly set a default audit condition.
@yijiem yijiem added release notes: yes Indicates if PR needs to be in release notes and removed release notes: no Indicates if PR should not be in release notes labels May 31, 2023
@erm-g erm-g removed the release notes: yes Indicates if PR needs to be in release notes label Jun 12, 2023
@yijiem yijiem added the release notes: no Indicates if PR should not be in release notes label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bloat/low imported Specifies if the PR has been imported to the internal repository lang/core per-call-memory/neutral per-channel-memory/neutral release notes: no Indicates if PR should not be in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants