Authorization

Authorization of users and services in Grey Matter is handled by setting up chains of Filters in each Sidecar. These filter chains can be composed into whatever way best suites the needs of the business, but a few reference flows are outlined here.

The contents here focus on HTTP level authorization. Authorization at the TCP level is also supported through the Envoy TCP RBAC filter.

Key Components

Filter

Description

Configuration

gm.inheaders

Set up request headers from certificates to allow authorization actions

gm.ensurevariables

Ensure headers/cookies/query strings are present at needed locations.

gm.jwtsecurity

Establish JWT token for user/service in request for later AuthZ.

gm.listauth

Apply whitelist or blacklist authentication based on USER_DN header field.

envoy.jwt_authn

Authorize requests to route/method based on user/role

envoy.rbac

Authorize requests to route/method based on user/role

Flows

Users, Services, Guests

This authorization flow determines access to the service with 3 different policies. A policy for authenticated users coming through the edge, a policy for authenticated services, and a default policy for anything else.

The service-admin policy in the RBAC filter below allows any request coming in with the header USER_DN: CN=quickstart,OU=Engineering,O=Decipher Technology Studios,L=Alexandria,ST=Virginia,C=US. This policy requires the gm-inheaders filter to be set up at the Edge so that incoming requests have the USER_DN appropriately set from the incoming certificates.

A services policy then follows. This is configured to allow any service using certs issued by the SPIRE integration to access the service. The regex matching permits any service as shown, but exact matches or more restrictive regex can be used to tune it to permit/deny specific services. E.g. exact matches onspiffe://quickstart.greymatter.io/data or spiffe://quickstart.greymatter.io/catalog would permit just those services to perform actions.

The last policy, product-viewer, allows any request that does not match either of the two preceding policies to perform only GET requests. Any other method will be denied. This is useful when only certain users/services should be permitted to perform modifications, but anyone should be able to read.

Config

Simple Access List

This authorization flow is a simple setup to only establish standard headers and then perform whitelisting. The gm.inheaders filter sets up the USER_DN header from incoming user's PKI certificates, and the gm.listauth will allow or deny based on the set whitelist and blacklist.

NOTE: in a typical setup, the gm.inheaders filter is setup on the originating Sidecar (usually the Edge node or an internal egress listener) rather than the destination. This allows common origination points to setup the needed header fields, and then each destination to setup it's own allow/deny rules. Both are shown in the same config below for reference, and because this is also permissible if desired.

Simple Access List Configuration

inheaders + jwt-security + AuthN + rbac

This flow composes a number of filters to perform RBAC on user attributes in JWT tokens from Grey Matter's JWT Security Service. The filter chain here performs the following in sequence:

  1. gm.inheaders: Establish USER_DN header from incoming certs

  2. gm.jwtsecurity: Exchange USER_DN header for a JWT token with complete user claims.

  3. envoy.jwt_authn: Verifies the JWT token and populates internal metadata with the claims.

  4. envoy.rbac: Accesses the envoy.jwt_authn metadata from the JWT token to verify that the user's email address contains the greymatter.io domain and allow access.

Configuration

Allow/Deny Requests Based on IP Address

Another way to create an access/block list is by using RBAC filterarrow-up-right to allow/deny requests based on remote IP addresses.

Network filter vs. HTTP filter

You will notice that there are RBAC Network filterarrow-up-right and RBAC HTTP filterarrow-up-right in Envoy. We can use either filter for checking the remote IP address and determining a policy. We chose a network filter for this guide as we do not need to do any sophisticated analysis of the traffic and it can handle larger load. If you need information in HTTP headers, for example, you want to use a HTTP filter.

Role Based Access Control (RBAC) Filter Configuration

The RBAC filter is used to authorize actions (permissions) by identified downstream clients (principals).

In other words, we want to set up our RBAC filter which will grant/deny access permission based on the IP address of the principals. The simple set up looks like the following:

Note that there is a configuration for envoy_rbac filter, and that filter is set to active by being listed under active_network_filters. In above case, the listener will reject any access unless it is coming from a remote IP address of 192.0.0.1 (CIDRarrow-up-right: 192.0.0.1/32).

RBAC supports enforcement and shadow mode. If you want to do a final check of the configuration and expected behavior in production, you can start with shadow mode which will not affect the actual traffic. By replacing the above "rules" with "shadow_rules", it will only emits logs and stats without enforcing the rule.

If you want to deny any access from a given IP, you can set the action to "DENY" instead of "ALLOW". If you have a list of IP addresses you want to block the access, you can list them all in "principals".

As you can see, it is straight forward to allow/deny access based on the IP address.

Last updated

Was this helpful?