Access Control
Blacklist and whitelist functionality is an effective network security mechanism used to control and manage network traffic. This feature relies on a predefined list of rules to determine which entities (IP addresses or IP ranges) are allowed or denied passage through the gateway. The gateway uses blacklists and whitelists to filter incoming network traffic. This method provides simple and direct access control, easy to manage, and effectively prevents known security threats.
As the entry point for cluster traffic, the FSM Gateway manages all traffic entering the cluster. By setting blacklist and whitelist access control policies, it can filter traffic entering the cluster.
FSM Gateway provides two granularities of access control, both targeting L7 HTTP protocol:
- Domain-level access control: A network traffic management strategy based on domain names. It involves implementing access rules for traffic that meets specific domain name conditions, such as allowing or blocking communication with certain domain names.
- Route-level access control: A management strategy based on routes (request headers, methods, paths, parameters), where access control policies are applied to specific routes to manage traffic accessing those routes.
Next, we will demonstrate the use of blacklist and whitelist access control.
Prerequisites
- Kubernetes cluster version v1.21.0 or higher.
- kubectl CLI
- FSM Gateway installed via guide doc.
Demonstration
Deploying a Sample Application
Next, deploy a sample application using the commonly used httpbin service, and create Gateway and HTTP Route (HttpRoute).
Check the gateway and HTTP routes; you should see two routes with different domain names created.
Verify if the HTTP routing is effective by accessing the application.
Domain-Based Access Control
With domain-based access control, we can set one or more domain names in the policy and add a blacklist or whitelist for these domains.
For example, in the policy below:
targetRef
is a reference to the target resource for which the policy is applied, which is theHTTPRoute
resource for HTTP requests.- Through the
hostname
field, we add a blacklist or whitelist policy forfoo.example.com
among the two domains. - With the prevalence of cloud services and distributed network architectures, the direct connection to the gateway is no longer the client but an intermediate proxy. In such cases, we usually use the HTTP header
X-Forwarded-For
to identify the client’s IP address. In FSM Gateway’s policy, theenableXFF
field controls whether to obtain the client’s IP address from theX-Forwarded-For
header. - For denied communications, customize the response with
statusCode
andmessage
.
For detailed configuration, please refer to AccessControlPolicy API Reference.
After the policy is effective, we send requests for testing, remembering to add X-Forwarded-For
to specify the client IP.
From the results, when both a whitelist and a blacklist are present, the blacklist configuration will be ignored.
Route-Based Access Control
Route-based access control allows us to set access control policies for specific routes (path, request headers, method, parameters) to restrict access to these particular routes.
Before setting up the access control policy, we add a route with the path prefix /headers
under the HTTP route foo.example.com
to facilitate the configuration of access control for it.
In the following policy:
- The
match
is used to configure the routes to be matched, here we use path matching. - Other configurations continue to use the settings from above.
After updating the policy, we send requests to test. For the path /headers
, the results are as before.
However, if the path /get
is accessed, there are no restrictions.
This demonstrates the effectiveness and specificity of route-based access control in managing access to different routes within a network infrastructure.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.