Access Control
Qpoint Proxy supports flexible access control mechanisms that can be applied per endpoint to allow or deny access based on IP addresses, user credentials, or JWT claims. SSL/TLS Termination is not required for Access Control.
Default Domain Action Configuration
The default_domain_action
in Qpoint Proxy's YAML configuration specifies the overarching access rule that applies to all domains not explicitly mentioned in the endpoints
section of the configuration file.
ALLOW: If set to
ALLOW
, the proxy permits access to all requests by default. This setting is useful in environments where most of the network traffic should be allowed, and only specific domains need to be restricted.DENY: Conversely, if set to
DENY
, the proxy denies access to all requests by default. This is advisable in more secure or sensitive environments where access should be restricted unless explicitly allowed.
Endpoint Allow and Deny Directives
The allow
and deny
directives define specific exceptions to the action
specified at the domain level. Here’s how they work:
Action: ALLOW – When the action is set to
ALLOW
, access is permitted by default for all users. Thedeny
directive can be used to specify exceptions where access should be blocked.
Action: DENY – When the action is set to
DENY
, access is blocked by default. Theallow
directive is used to specify exceptions where access should be permitted.
IP-Based Access Control
Access can be controlled based on the IP address of the incoming request. This method is useful for restricting or permitting access from specific network locations.
Both IPV4 and IPV6 are supported. CIDR notation is also supported.
Example Configuration
In this example, access to www.example.com
is generally allowed, but requests from the IP address 172.17.0.1
are denied.
Conversely, for www.yahoo.com
, access is denied by default except for requests coming from 172.17.0.0/16.
Username/Password Based Access Control
Access can also be controlled using traditional username and password credentials, either via HTTP basic authorization or proxy authorization.
Example Configuration
In this configuration, access is generally denied, except for specified users who authenticate successfully.
JWT-Based Access Control
JWT is a compact, URL-safe means of representing claims to be transferred between two parties. In the context of Qpoint Proxy, JWTs are used to securely transmit information about a user between the client and the server, enabling the server to enforce access controls based on the contents of the token.
Configuring JWT Claims in YAML
First, the proxy administrator sets up the proxy to check certain JWT claims against its access rules. This is done within the endpoints configuration in the proxy-config.yaml
file.
Example Configuration
Matching JWT Claims with YAML Configuration
When a JWT is presented to the proxy (typically included in the Authorization
header of the request as a Bearer token), Qpoint Proxy performs several steps to determine if the request should be allowed or denied:
Extraction and Verification:
The JWT is extracted from the Authorization header.
The proxy validates the JWT using the configured
jwt_hmac_key
to ensure it is authentic and has not been tampered with.
Claim Evaluation Against Configuration:
Subject (
sub
) Claim: The proxy checks if thesub
claim in the JWT matches anyid
specified in theallow
list for the domain. In the above example, if the JWT'ssub
is "dog", and the configuration specifies anid
of "dog", the request would be considered for allowance.Tags Claim: Similarly, the proxy checks if any of the
tags
in the JWT match the tags specified in theallow
list. If the JWT includes the tag "admin" and the YAML configuration under that domain includestag: "admin"
, the request will be allowed.
Final Decision:
If any of the JWT claims match the allowed conditions in the configuration, the request is permitted.
If no claims match, or if the specified action is
DENY
without a corresponding allow condition being met, the request is denied.
Practical Example
Consider a JWT with the following payload:
For a request to api.github.com
, Qpoint Proxy checks:
If the
sub
matches "dog", the condition is satisfied.If one of the
tags
matches "admin", the condition is also satisfied.
Since either or both conditions meet the allow
criteria in the YAML configuration, the request would be allowed even though the default action is DENY
.
Testing Access Control with Qpoint Proxy
To verify that Qpoint Proxy is correctly handling access control based on your configuration, you can use curl
commands to simulate requests with different types of authentication. Below are examples for each method:
Connect with Proxy Authorization
When testing proxy authorization, use the --proxy-user
option in curl
to pass the credentials.
This command configures curl
to use user1
with password1
as credentials for proxy authorization to access api.github.com
through your proxy.
Connect with Proxy Authorization using JWT
When you need to authenticate with the proxy using a JWT, you can include the JWT in the --proxy-user
option. Here's an example:
This command configures curl
to use Devin
with the provided JWT as credentials for proxy authorization to access api.github.com
through your proxy.
Basic Authentication with Username/Password
For a more traditional approach using Basic Authentication with a username and password, you can simulate this as follows:
This command sends a GET request to api.github.com
with a Basic Auth header, where dXNlcjI6cGFzc3dvcmQy
is the Base64-encoded string of user2:password2
.
Basic Authentication with JWT as Password
You can use Basic Authentication where the JWT is used as the password part of the credential.
This command sends a GET request to api.github.com
using a Basic Auth header.
Verifying the Responses
When you run these commands, look for HTTP status codes in the responses:
2XX
indicates successful access.403
indicates forbidden access.
Last updated