-
Notifications
You must be signed in to change notification settings - Fork 5.3k
authz: RBAC HTTP filter + utilities #3455
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| RBAC | ||
| ==== | ||
|
|
||
| .. toctree:: | ||
| :glob: | ||
| :maxdepth: 1 | ||
|
|
||
| v2alpha/* |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -18,5 +18,6 @@ HTTP filters | |
| ip_tagging_filter | ||
| lua_filter | ||
| rate_limit_filter | ||
| rbac_filter | ||
| router_filter | ||
| squash_filter | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| .. _config_http_filters_rbac: | ||
|
|
||
| Role Based Access Control (RBAC) Filter | ||
| ======================================= | ||
|
|
||
| The RBAC filter is used to authorize actions (permissions) by identified downstream clients | ||
| (principals). This is useful to explicitly manage callers to an application and protect it from | ||
| unexpected or forbidden agents. The filter supports configuration with either a safe-list (ALLOW) or | ||
| 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. | ||
|
|
||
| * :ref:`v2 API reference <envoy_api_msg_config.filter.http.rbac.v2.RBAC>` | ||
|
|
||
| Per-Route Configuration | ||
| ----------------------- | ||
|
|
||
| The RBAC filter configuration can be overridden or disabled on a per-route basis by providing a | ||
| :ref:`RBACPerRoute <envoy_api_msg_config.filter.http.rbac.v2.RBACPerRoute>` configuration on | ||
| the virtual host, route, or weighted cluster. | ||
|
|
||
| Statistics | ||
| ---------- | ||
|
|
||
| The RBAC filter outputs statistics in the *http.<stat_prefix>.rbac.* namespace. The :ref:`stat | ||
| prefix <config_http_conn_man_stat_prefix>` comes from the owning HTTP connection manager. | ||
|
|
||
| .. csv-table:: | ||
| :header: Name, Type, Description | ||
| :widths: 1, 1, 2 | ||
|
|
||
| allowed, Counter, Total requests that were allowed access by the filter | ||
| denied, Counter, Total requests that were denied access by the filter | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| licenses(["notice"]) # Apache 2 | ||
|
|
||
| load( | ||
| "//bazel:envoy_build_system.bzl", | ||
| "envoy_cc_library", | ||
| "envoy_package", | ||
| ) | ||
|
|
||
| envoy_package() | ||
|
|
||
| envoy_cc_library( | ||
| name = "matchers_lib", | ||
| srcs = ["matchers.cc"], | ||
| hdrs = ["matchers.h"], | ||
| deps = [ | ||
| "//include/envoy/http:header_map_interface", | ||
| "//include/envoy/network:connection_interface", | ||
| "//source/common/common:assert_lib", | ||
| "//source/common/http:header_utility_lib", | ||
| "//source/common/network:cidr_range_lib", | ||
| "@envoy_api//envoy/config/rbac/v2alpha:rbac_cc", | ||
| ], | ||
| ) | ||
|
|
||
| envoy_cc_library( | ||
| name = "engine_interface", | ||
| hdrs = ["engine.h"], | ||
| deps = [ | ||
| "//include/envoy/http:filter_interface", | ||
| "//include/envoy/http:header_map_interface", | ||
| "//include/envoy/network:connection_interface", | ||
| ], | ||
| ) | ||
|
|
||
| envoy_cc_library( | ||
| name = "engine_lib", | ||
| srcs = ["engine_impl.cc"], | ||
| hdrs = ["engine_impl.h"], | ||
| deps = [ | ||
| "//source/extensions/filters/common/rbac:engine_interface", | ||
| "//source/extensions/filters/common/rbac:matchers_lib", | ||
| "@envoy_api//envoy/config/filter/http/rbac/v2:rbac_cc", | ||
| ], | ||
| ) |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/http/filter.h" | ||
| #include "envoy/http/header_map.h" | ||
| #include "envoy/network/connection.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Extensions { | ||
| namespace Filters { | ||
| namespace Common { | ||
| namespace RBAC { | ||
|
|
||
| /** | ||
| * Shared logic for evaluating RBAC policies. | ||
| */ | ||
| class RoleBasedAccessControlEngine : public Router::RouteSpecificFilterConfig { | ||
| public: | ||
| virtual ~RoleBasedAccessControlEngine() {} | ||
|
|
||
| /** | ||
| * Returns whether or not the current action is permitted. | ||
| * | ||
| * @param connection the downstream connection used to identify the action/principal. | ||
| * @param headers the headers of the incoming request used to identify the action/principal. An | ||
| * empty map should be used if there are no headers available. | ||
| */ | ||
| virtual bool allowed(const Network::Connection& connection, | ||
| const Envoy::Http::HeaderMap& headers) const PURE; | ||
| }; | ||
|
|
||
| } // namespace RBAC | ||
| } // namespace Common | ||
| } // namespace Filters | ||
| } // namespace Extensions | ||
| } // namespace Envoy |
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.
🎉