Service Extensions enables Application Load Balancers to send callouts to backend services to insert custom processing in the processing path. Authorization extensions run in the request processing path when the load balancer receives request headers and after the URL map chooses the backend service. This page describes how to configure authorization extensions to use a custom authorization engine defined in an authorization policy.
For an overview about Application Load Balancer extensions, see Cloud Load Balancing extensions overview.
Introduction
Cloud Load Balancing lets you configure authorization policies that enforce access control on traffic entering load balancers. Sometimes, complex authorization decisions cannot be readily expressed using an authorization policy.
You can configure authorization policies with authorization extensions to delegate authorization decisions to custom authorization engines. In the data path, authorization extensions are executed after route extensions but before traffic extensions. For more information about authorization policies, see Authorization policy overview.
For each authorization request, the proxy forwards the request headers to the extension. Depending on the response from the provider, the proxy either forwards or rejects the request.
In Preview, for regional external Application Load Balancers and regional internal Application Load Balancers, you can configure authorization extensions separately for request authorization policies and content authorization policies. Extensions that are based on request authorization policies are configured to run before those based on content authorization policies.
For information about the limits related to Application Load Balancer extensions, see the Quotas and limits page.
Configure a basic authorization extension
The following example shows how to configure an authorization extension,
my-authz-ext, with an authorization policy to delegate authorization
decisions for a global external Application Load Balancer.
gcloud
Create the required resources as described in Configure a callout backend service.
For this exercise, create a global external Application Load Balancer. Name the service
authz-serviceand the forwarding rulefr1.Configure the authorization extension.
Define the extension in a YAML file that associates it with the backend service,
authz-service. Use the sample values provided.cat >authz-extension.yaml <<EOF name: my-authz-ext authority: ext11.com loadBalancingScheme: EXTERNAL_MANAGED service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/authz-service forwardHeaders: - Authorization failOpen: false timeout: "0.1s" forwardAttributes: - request.mcp_param - connection.client_cert_leaf EOFReplace
PROJECT_IDwith the project ID.For more information about the fields in the YAML file, see ExtensionChain in the API documentation. For information about supported attributes, see Supported attributes.
Import the authorization extension. Use the
gcloud service-extensions authz-extensions importcommand with the following sample values.gcloud service-extensions authz-extensions import my-authz-ext \ --source=authz-extension.yaml \ --location=globalIf you want to set the protocol to
ext_authz, use thegcloud beta service-extensions authz-extensions importcommand instead.
Configure an authorization policy with the extension.
Define an authorization policy that associates the extension
my-authz-extwith the forwarding rulefr1. Use the sample values provided. TheCUSTOMaction indicates that an extension is being used.cat >authz-policy.yaml <<EOF name: my-authz-policy target: loadBalancingScheme: EXTERNAL_MANAGED resources: - "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/forwardingRules/fr1" action: CUSTOM customProvider: authzExtension: resources: - "projects/PROJECT_ID/locations/global/authzExtensions/my-authz-ext" EOFImport the authorization policy to the project. Use the
gcloud network-security authz-policies importcommand with the following sample values.gcloud network-security authz-policies import my-authz-policy \ --source=authz-policy.yaml \ --location=global
Configure authorization extensions based on profiles
You can configure authorization extensions separately for request and content authorization policies.
For a request authorization policy
The following example shows how to configure an authorization extension that
applies a request authorization policy to a forwarding rule in us-west1. The
policy requires traffic to pass mutual TLS authentication from a specific
principal before being allowed to reach the destination, example.com/mcp.
gcloud
Configure a callout backend service named
lb-request-authz-serviceinus-west1with a forwarding rule namedfr2.For the service, set up a regional external Application Load Balancer with VM instance group backends.
Configure the authorization extension.
Define the extension in a YAML file that associates the extension with the backend service,
lb-request-authz-service. Use the sample values provided.cat >lb-request-authz-extension.yaml <<EOF name: my-lb-request-authz-ext authority: ext11.com loadBalancingScheme: INTERNAL_MANAGED service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/us-west1/backendServices/lb-authz-request-service forwardHeaders: - Authorization failOpen: false timeout: "0.1s" wireFormat: EXT_AUTHZ_GRPC EOFReplace
PROJECT_IDwith the project ID.The extension must be in the same region as your backend service.
By default, all Service Extensions callouts use the Envoy External Processing or
ext_procprotocol. In the case of authorization callouts, the External Authorization orext_authzprotocol is also supported in Preview. When thewireFormatoption is set toEXT_AUTHZ_GRPC, the callout uses theext_authzprotocol. If the option isn't specified, the callout uses theext_procprotocol.For request authorization policies, the
wireFormatvalue can beEXT_AUTHZ_GRPCso that the callout uses theext_authzprotocol although theext_procprotocol is also supported.By default,
failOpenis set tofalse. If the extension times out or fails, request processing stops. This default option is preferred when prioritizing security or integrity over availability.Import the authorization extension. Use the
gcloud beta service-extensions authz-extensions importcommand with the following sample values.gcloud beta service-extensions authz-extensions import my-lb-request-authz-ext \ --source=lb-request-authz-extension.yaml \ --location=us-west1
In the same project, configure an authorization policy with the extension.
For any request to
example.com/mcp, the policy requires mutual TLS authentication from a specific principal and further delegates the authorization decision to the authorization extension,my-lb-authz-request-ext.Define an authorization policy that associates the
my-lb-request-authz-extextension with the with the forwarding rulefr2. Use the sample values provided.cat >lb-request-authz-policy.yaml <<EOF name: my-lb-request-authz-policy target: resources: - "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/us-west1/forwardingRules/fr2" policyProfile: REQUEST_AUTHZ httpRules: - to: operations: - hosts: - exact: "example.com" - paths: - prefix: "/mcp" from: sources: - principals: - principal_selector: CLIENT_CERT_DNS_NAME_SANS principal: exact: "spiffe://p.global.123.workload.id.goog/ns/ns1/sa/hellomcp" action: CUSTOM customProvider: authzExtension: resources: - "projects/PROJECT_ID/locations/us-west1/authzExtensions/my-lb-request-authz-ext" EOFFor request authorization policies, the value of
policyProfilemust beREQUEST_AUTHZ. This value indicates that the custom policy provider acts on requests to allow or deny traffic.The
CUSTOMaction indicates that an extension is associated with the proxy.For more information about an authorization policy resource, see the
authzPolicyreference documentation.Import the authorization policy to the project. Use the
gcloud beta network-security authz-policies importcommand with the following sample values.gcloud beta network-security authz-policies import my-lb-request-authz-policy \ --source=lb-request-authz-policy.yaml \ --location=us-west1
For a content authorization policy
The following example shows how to configure an authorization extension that
applies a content authorization policy to a forwarding rule in
us-west1. The policy requires a content sanitization service to perform deep
inspection of your application payloads to allow or deny requests or mutate the
requests and responses, as required.
gcloud
Configure a callout backend service named
lb-content-authz-serviceinus-west1with a forwarding rule namedfr3.For the service, set up a regional external Application Load Balancer with VM instance group backends.
Configure the extension server with the
ext_procprotocol inFULL_DUPLEX_STREAMEDbody processing mode and supporting all events.Configure the authorization extension.
Define the extension in a YAML file that associates the extension with the backend service,
lb-content-authz-service. Use the sample values provided.cat >lb-content-authz-extension.yaml <<EOF name: my-lb-content-authz-ext authority: ext11.com loadBalancingScheme: INTERNAL_MANAGED service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/us-west1/backendServices/lb-authz-sdp-service failOpen: false timeout: "0.1s" EOFFor content authorization policies, the value of
policyProfilemust beCONTENT_AUTHZ.For
CONTENT_AUTHZpolicies, thewireFormatvalue need not be set explicitly asEXT_PROC_GRPC. By default, the callout uses theext_procprotocol.Import the authorization extension. Use the
gcloud beta service-extensions authz-extensions importcommand with the following sample values.gcloud beta service-extensions authz-extensions import my-lb-content-authz-ext \ --source=lb-content-authz-extension.yaml \ --location=us-west1
Configure an authorization policy with the extension.
Define an authorization policy that associates the extension
my-lb-content-authz-extwith the forwarding rule,fr3. Use the sample values provided.cat >lb-content-authz-policy.yaml <<EOF name: lb-content-authz-policy target: resources: - "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/us-west1/forwardingRules/fr3" policyProfile: CONTENT_AUTHZ httpRules: - to: operations: - hosts: - exact: "example.com" - paths: - prefix: "/sensitive-stuff" action: CUSTOM customProvider: authzExtension: resources: - "projects/PROJECT_ID/locations/us-west1/authzExtensions/my-lb-authz-content-ext" EOFThe value of
policyProfilemust beCONTENT_AUTHZ.Import the authorization policy to the project. Use the
gcloud beta network-security authz-policies importcommand with the following sample values.gcloud beta network-security authz-policies import my-lb-content-authz-policy \ --source=lb-content-authz-policy.yaml \ --location=us-west1
Limitations for authorization extensions
The following are some limitations of authorization extensions:
- An authorization policy can have only one authorization extension.
- A forwarding rule can be used with several authorization policies of which only one can be a custom authorization policy.
For limitations that are applicable to all extensions, see Limitations for extensions.
What's next
- View Python and Go samples of
ext_authzandext_procservers in the Service Extensions GitHub repository. - Configure a route extension
- Configure a traffic extension
- Manage extensions