-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Enable metadata for Network::RBAC #5106
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
Changes from all commits
5d5f8b0
e488c26
601be22
9c30406
b352425
f86e182
75754c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,8 @@ RoleBasedAccessControlFilterConfig::RoleBasedAccessControlFilterConfig( | |
| const envoy::config::filter::network::rbac::v2::RBAC& proto_config, Stats::Scope& scope) | ||
| : stats_(Filters::Common::RBAC::generateStats(proto_config.stat_prefix(), scope)), | ||
| engine_(Filters::Common::RBAC::createEngine(proto_config)), | ||
| shadow_engine_(Filters::Common::RBAC::createShadowEngine(proto_config)) {} | ||
| shadow_engine_(Filters::Common::RBAC::createShadowEngine(proto_config)), | ||
| enforcement_type_(proto_config.enforcement_type()) {} | ||
|
|
||
| Network::FilterStatus RoleBasedAccessControlFilter::onData(Buffer::Instance&, bool) { | ||
| ENVOY_LOG( | ||
|
|
@@ -31,15 +32,20 @@ Network::FilterStatus RoleBasedAccessControlFilter::onData(Buffer::Instance&, bo | |
| : "none", | ||
| callbacks_->connection().streamInfo().dynamicMetadata().DebugString()); | ||
|
|
||
| if (shadow_engine_result_ == Unknown) { | ||
| // TODO(quanlin): Pass the shadow engine results to other filters. | ||
| // Only check the engine and increase stats for the first time call to onData(), any following | ||
| // calls to onData() could just use the cached result and no need to increase the stats anymore. | ||
| // When the enforcement type is continuous always do the RBAC checks. If it is a one time check, | ||
| // run the check once and skip it for subsequent onData calls. | ||
| if (config_->enforcementType() == envoy::config::filter::network::rbac::v2::RBAC::CONTINUOUS) { | ||
|
Contributor
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. In the continuous case, shadow rules should stop evaluation if the result is DENY:
Contributor
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. Would you mind to clarify more about why should we stop the shadow rule evaluation if the result is DENY?
Member
Author
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. Thats a good point.. Unlike the real rule that terminates the connection, SHADOW rules simply spit out stats about whether each query was allowed or denied.. |
||
| shadow_engine_result_ = checkEngine(Filters::Common::RBAC::EnforcementMode::Shadow); | ||
| } | ||
|
|
||
| if (engine_result_ == Unknown) { | ||
| engine_result_ = checkEngine(Filters::Common::RBAC::EnforcementMode::Enforced); | ||
| } else { | ||
| if (shadow_engine_result_ == Unknown) { | ||
| // TODO(quanlin): Pass the shadow engine results to other filters. | ||
| shadow_engine_result_ = checkEngine(Filters::Common::RBAC::EnforcementMode::Shadow); | ||
| } | ||
|
|
||
| if (engine_result_ == Unknown) { | ||
| engine_result_ = checkEngine(Filters::Common::RBAC::EnforcementMode::Enforced); | ||
| } | ||
| } | ||
|
|
||
| if (engine_result_ == Allow) { | ||
|
|
||
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.
A general question: how this work with allow-list type of
rules? i.e. during the connection establishment the connection doesn't have enough metadata, but after decoding it will gain the access, won't the connection be dropped during connection establishment? Definitely worth more comment.