Skip to content

RBAC support for policy dark launch#3554

Merged
mattklein123 merged 2 commits intoenvoyproxy:masterfrom
quanjielin:quanlinplay2
Jun 13, 2018
Merged

RBAC support for policy dark launch#3554
mattklein123 merged 2 commits intoenvoyproxy:masterfrom
quanjielin:quanlinplay2

Conversation

@quanjielin
Copy link
Copy Markdown
Contributor

@quanjielin quanjielin commented Jun 6, 2018

#3552

2nd POC for #3552(1st POC: #3548).

1st POC(#3548) adds an enforcement_mode property at policy level, the problem of this approach is it won't be able to test policy deletion/replacement scenarios; also the implementation isn't correct(evaluation uses OR_rule may returns earlier even without applying dark launch policy)

To address issues mentioned above, this PR groups policies into two independent rules(enforcement/darklaunch) in RBAC config.

Signed-off-by: Quanjie Lin quanlin@google.com

@quanjielin
Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Member

@rodaine rodaine left a comment

Choose a reason for hiding this comment

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

Nice! I like this PoC better than #3548 but some of my comments from there also apply (ie, the name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is_dark_launch (and elsewhere)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated to use enum.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IIRC per the C++ style guide, this should look like: ..., /*is_dark_launch=*/ true)) {

Alternatively, use the enum you added in the protos instead so it's explicit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we add a test for triggering the dark path?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added in rbac_filter_test.cc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use const std::vector& to avoid data copy

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks, done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

per c++ style guide, the variable name should be is_dark_launch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated to use enum.

Copy link
Copy Markdown
Contributor

@diemtvu diemtvu left a comment

Choose a reason for hiding this comment

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

High level question: can we dark launch from rbac-disable to rbac-enable+rules with this? I guess you can simulate rbac-disable with a dummy rule (i.e action = DENY with no policies), but I wonder if there could be a cleaner way?

@quanjielin
Copy link
Copy Markdown
Contributor Author

@diemtvu, another option I could think:
rbac engine has a engine_disabled_ property, which is always set to false by filter right now; we could add a boolean in RBAC config proto, and set engine_disabled_ from that value.

@diemtvu
Copy link
Copy Markdown
Contributor

diemtvu commented Jun 6, 2018

From what I see, I think we can remove this flag (engine_disabled_) completely, and make allowed function returns true (in active mode) if the rules is empty (the RBAC message, not the vector of policies). You can use separated boolean for this but not sure if it has clearer usability.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably do this only when there is actually 'darklaunch' policies, otherwise it could be confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think probably it's fine to log what user expected to see if they switch the mode ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What mode? This means users will see counter for permissive_allowed all the time, even they do not provide any permissive rules. It seems confusing to me. Anyway, it's just my opinion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated to only evaluate/log only when permissive policies is set

@liminw
Copy link
Copy Markdown
Contributor

liminw commented Jun 6, 2018

@quanjielin @diemtvu "engine_disabled_" is used by per-route RBAC config.

I think if we leave the RBAC filter spec empty, the RBAC evaluation logic will not kick in. That is basically the RBAC disabled scenario you are thinking about.

@rodaine Correct me if I am wrong.

@quanjielin
Copy link
Copy Markdown
Contributor Author

@liminw, agree, just did another commit which includes

  1. remove required checking for RBAC.rules (which is for enforcement mode), it's empty indicates rbac disabled; so that we could test rbac disabled -> rbac enabled only for permissive mode case(RBAC.rules is empty, RBAC.permissive_rules is set)
  2. thread rbac config to engine to make the code cleaner

Keep engine_disabled_ for per-route config, probably it also could be removed to re-use logic above from RBACPerRoute.RBAC ?

@quanjielin quanjielin changed the title [WIP, POC] RBAC support for policy dark launch RBAC support for policy dark launch Jun 6, 2018
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could also be removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

as mentioned in above comment, keep this for now because of per-route config; it could be removed if we could decide disable from RBACPerRoute.RBAC field(which this PR uses in other places). I'm not familiar about the RBACPerRoute use case, wait @rodaine to comment whether it's safe to remove disable field from RBACPerRoute proto.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I mean the if statement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh I misunderstand, done.

@quanjielin quanjielin force-pushed the quanlinplay2 branch 2 times, most recently from 55deaa0 to 603d35c Compare June 7, 2018 00:51
@mattklein123
Copy link
Copy Markdown
Member

Quick note that we will need docs on this feature in the main filter config docs / arch overview. I think it's definitely worth calling out. I don't think it's necessary to release note it as we just added the main filter.

I haven't looked at the code yet, but LMK when the first round of reviews is done and I can take a look. Also note that DCO will need to be fixed. Feel free to keep reviewing and then when you are all satisfied squash/rebase force push to fix DCO and then I will review. Thanks!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

as config_ is const, this shouldn't be here but in cluster. You can have policies_ and permissive_policies_ as a member. Creating PolicyMatcher is inefficient.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the if and else is pretty similar, extract to a function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

seems no extra function needed after moving code around :)

@quanjielin quanjielin force-pushed the quanlinplay2 branch 3 times, most recently from d8b2b02 to 6f312b9 Compare June 7, 2018 16:59
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What mode? This means users will see counter for permissive_allowed all the time, even they do not provide any permissive rules. It seems confusing to me. Anyway, it's just my opinion.

const Envoy::Http::HeaderMap& headers) const {
const Envoy::Http::HeaderMap& headers,
EnforcementMode mode) const {
if (engine_disabled_) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm still don't understand the purpose of this boolean. Can we just use the logic with the next two if you've just added?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I also feel it's not needed, it could be inferred from whether rules is set; removed it in c4f5e47. @rodaine let's know if I miss anything here.

config.rbac.v2alpha.RBAC rules = 1 [(validate.rules).message.required = true];
// Specify the enforcement mode RBAC rules to be applied globally.
// Disable the filter for enforcement mode if rules isn't set.
config.rbac.v2alpha.RBAC rules = 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Before we remove "[(validate.rules).message.required = true]", @rodaine can you please review this part? I think you had it there on purpose.

For RBAC disabled case, we can just leave the entire RBAC filter spec empty. RBAC filter will not be invoked in that case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See my other comment on the removal of disabled

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

as just mentioned in another comment, this field could be inferred from whether rules is set(same as logic used in other places in this PR), need @rodaine confirm though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was originally added as an explicit indicator that the filter is disabled for the vhost/route. Likewise, making it by-convention (ie, the config.rbac.v2alpha.RBAC being unset in the above config) permits the pathological configuration of RBAC where the global filter has no policies defined at all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we just keep rules = 1? Otherwise, this would be a breaking change to anyone already consuming them. I understand the desire to clearly indicate that these are the actually enforced rules, but I think that can be accomplished in the comments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please also reserve disabled

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we change the last clause to: ...it is used to test how a new set of policies work before rolling out to production.?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For clarity, please drop the by the filter enforcement mode phrase from allowed/denied, and change the shadow ones to that would be allowed/denied access by the filter's shadow rules.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The passed in config cannot be nil (due to the reference in the engine's constructor), and the RBAC proto has validation to prevent it being set with no policies. We're just bypassing that by returning the zero value in the route specific config's constructor. The engine does not need to know about enabled/disabled as that's a function of the filter, though. This should be encoded in the filter's config logic, not the engine impl, IMO.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can remove the raw string markers: "{}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

seems {} is needed(tried to remove it then test timeout..)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sorry i meant replace R"EOF({})EOF" with just "{}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

@quanjielin quanjielin force-pushed the quanlinplay2 branch 2 times, most recently from cfaf034 to 4cc9c0a Compare June 11, 2018 22:19
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please change back to 1 (and remove the reserved).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove /denied

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove allowed/ (sorry wasn't clearer!)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

@quanjielin quanjielin force-pushed the quanlinplay2 branch 3 times, most recently from 331fec8 to 1765bc7 Compare June 11, 2018 23:19
const std::string& stats_prefix, Stats::Scope& scope);

RoleBasedAccessControlFilterStats& stats() { return stats_; }
const envoy::config::filter::http::rbac::v2::RBAC& config() { return config_; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this used?


bool isEnabled(EnforcementMode mode) const {
return mode == EnforcementMode::ENFORCED ? config_.has_rules() : config_.has_shadow_rules();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can this be resolved at construction so we don't need to hold onto the RBAC config?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

use two boolean member variables instead of holding config _? we could do that that but personally I don't feel too much differences (run-time also should be quick ?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, you can make engine_ and shadow_engien_ an absl::optional

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, looks much cleaner now, thanks !


bool RoleBasedAccessControlFilterConfig::isEnabled(const Router::RouteConstSharedPtr route,
EnforcementMode mode) const {
if (!route || !route->routeEntry()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you extract this part getRouteLocalConfig to another function? It is similar with engine above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not necessary now as after getting rid of this function.


bool isEnabled(EnforcementMode mode) const {
return mode == EnforcementMode::ENFORCED ? config_.has_rules() : config_.has_shadow_rules();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, you can make engine_ and shadow_engien_ an absl::optional

if (!config_->isEnabled(callbacks_->route(), EnforcementMode::ENFORCED) ||
config_->engine(callbacks_->route(), EnforcementMode::ENFORCED)
.allowed(*callbacks_->connection(), headers)) {
config_->stats().allowed_.inc();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we do not increase the stats when config_->isEnabled() is false? Otherwise I'm afraid the stats is not very useful as it is increased when rbac is not enabled.

Copy link
Copy Markdown
Contributor Author

@quanjielin quanjielin Jun 12, 2018

Choose a reason for hiding this comment

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

updated the logic.

// RBAC filter config.
// User sees the shadow rules as replacement to the enforced rules.
// For example, policy A runs in prod in enforced mode, user wants
// to test policy B; in the config, enforced_rules contains {A.mode=enforced},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

encorced_rules -> rules in the comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks, done.

RoleBasedAccessControlRouteSpecificFilterConfig::RoleBasedAccessControlRouteSpecificFilterConfig(
const envoy::config::filter::http::rbac::v2::RBACPerRoute& per_route_config)
: engine_(per_route_config.rbac().rules()),
shadow_engine_(per_route_config.rbac().shadow_rules()), config_(per_route_config.rbac()) {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest to use pointer (unique_ptr<Filters::Common::RBAC::RoleBasedAccessControlEngine>) for engine / shadow_engine, and create them conditionally in the constructor. Later, you then can simply check if engine_ == nullptr before running it. E.g:

RoleBasedAccessControlRouteSpecificFilterConfig::RoleBasedAccessControlRouteSpecificFilterConfig(const envoy::config::filter::http::rbac::v2::RBACPerRoute& per_route_config) config_(per_route_config.rbac()) {
  if (config_.has_rules()) {
    engine_.reset(new Filters::Common::RBAC::RoleBasedAccessControlEngineImpl(config_.rules());
  }
}

then later in decodeHeader

if (shadow_engine_) {
  if (shadow_engine_.allowed(*callbacks_->connection(), headers)) {
    config_->stats().shadow_allowed_.inc();
  } else {
    config_->stats().shadow_denied_.inc();
  }
}

if (engine_ == nullptr) {
 if (engine_.allowed(*callbacks_->connection(), headers)) {
    config_->stats().allowed_.inc();
    return Http::FilterHeadersStatus::Continue;
 } else {
    config_->stats().denied_.inc();
    //...
    return Http::FilterHeadersStatus::StopIteration;
 }
}
// engine_ == nullptr, equivalent to rbac disable. Always accept request.
return Http::FilterHeadersStatus::Continue;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See my comment above, you can use absl::optional instead of a pointer, and check if they are nullopt.

}

if (engine.allowed(*callbacks_->connection(), headers)) {
if (!config_->isEnabled(callbacks_->route(), EnforcementMode::ENFORCED) ||
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would break this if to separate config_.isEnabled() == false to the different part that just return Continue (without counter) to be consistent. See example in the suggestion above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks, done.

Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

LGTM modulo 2 nits

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: const

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: const

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added

lizan
lizan previously approved these changes Jun 12, 2018
Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Thanks. PTAL @rodaine @mattklein123

Signed-off-by: Quanjie Lin <quanlin@google.com>
lizan
lizan previously approved these changes Jun 12, 2018
Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

You didn't have to squash again since DCO was OK.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM, just some small comments. Cool!

// RBAC filter config.
// User sees the shadow rules as replacement to the enforced rules.
// For example, policy A runs in prod in enforced mode, user wants
// to test policy B; in the config, rules contains {A.mode=enforced},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this text is out of data for an old implementation? It doesn't make sense. I think you can just remove and leave to the documentation below to cover.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed.

// Specify the RBAC rules to be applied globally
config.rbac.v2alpha.RBAC rules = 1 [(validate.rules).message.required = true];
// Specify the enforced RBAC rules to be applied globally.
// Filter's decision based on enforced rules has impact on user experience.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would replace these two sentences with: "If absent, no enforcing RBAC policy will be applied."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

config.rbac.v2alpha.RBAC rules = 1;

// Specify the shadow RBAC rules to be applied globally.
// Filter's decision based on shadow rules doesn't impact on user experience,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Replace two sentences with: "Shadow rules are not enforced by the filter (i.e., returning a 403) but will emit stats and logs and can be used for rule testing. If absent, no shadow RBAC policy with be applied."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

// Override the global configuration of the filter with this new config.
RBAC rbac = 2 [(validate.rules).message.required = true];
}
// Override the global configuration of the filter with this new config.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add: "If absent, the global RBAC policy will be disabled for this route."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

block-list (DENY) set of policies based off properties of the connection (IPs, ports, SSL subject)
as well as the incoming request's HTTP headers.
as well as the incoming request's HTTP headers. This filter also supports policy in both enforcement
and shadow mode, shadow mode won't effect real users, it is used to test a new set of policies work
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"it is used to test that a..."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

as well as the incoming request's HTTP headers.
as well as the incoming request's HTTP headers. This filter also supports policy in both enforcement
and shadow mode, shadow mode won't effect real users, it is used to test a new set of policies work
before rolling out to prod.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

s/prod/production here and elsewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

COUNTER(allowed) \
COUNTER(denied)
COUNTER(denied) \
COUNTER(shadow_allowed) \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: slash indent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated.

ALL_RBAC_FILTER_STATS(GENERATE_COUNTER_STRUCT)
};

enum class EnforcementMode { ENFORCED, SHADOW };
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Enforced, Shadow

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated.

engine(const Router::RouteConstSharedPtr route, EnforcementMode mode) const;

private:
const absl::optional<Filters::Common::RBAC::RoleBasedAccessControlEngineImpl>&
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can this derive from RoleBasedAccessControlRouteSpecificFilterConfig? all the code is basically the same.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since RoleBasedAccessControlRouteSpecificFilterConfig is derived from RouteSpecificFilterConfig , I may prefer to keep RoleBasedAccessControlFilterConfig as it is.

Signed-off-by: Quanjie Lin <quanlin@google.com>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM. Will defer to @rodaine for any final comments.

Copy link
Copy Markdown
Member

@rodaine rodaine left a comment

Choose a reason for hiding this comment

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

Awesome work! LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants