Skip to content

Expose part of the Admin API

The Admin API is one gRPC and HTTP service on port 8444. Most of its callers run inside your cluster or on an operator’s workstation, and only one caller runs in a browser: the admin console, when a tenant administrator works on a tenant. This page shows how to give that one caller a public hostname that serves only the paths it uses, while every other caller reaches the full API privately.

The rule: a path is either on the public allowlist or it is not reachable from the internet. There is no “public but authenticated” middle. The edge refuses the rest before any Authwise code runs.

  • An install on Kubernetes with the operator, as in Install on Kubernetes. The Admin API is the Service authwise-api on port 8444.
  • An edge that can match paths: a Gateway API implementation such as the GKE Gateway controller, or a reverse proxy in front of your ingress such as HAProxy or a cloud load balancer with path rules.
  • Identity server 1.52 or later, which honours a forwarded host only for a hostname registered on the install.
  • Operator 0.41.1 or later to have the operator render the allowlist itself with Gateway API, as the first option below.

Before you touch the edge, list every caller of the Admin API, where it runs, and the paths it uses. This table decides everything else:

CallerRunsPathsReaches the API
Admin console, tenant administratorbrowser/v1/tenants/TENANT_ID/…publicly
A second install that checks access at this onein the cluster/v1/access:bulkCheck, /v1/tenantsprivately
The audit serverin the clustertenant readsprivately
awctl and the Terraform providera workstationeverythingprivately, through a port-forward or a private hostname
awtenant (the tenancy admin server, port 9443)a workstation, with a client certificateits own servernever routed

Only the browser row is a candidate for the public hostname. If a browser caller ever needs a path outside one prefix, treat that as a finding about the console, not as a reason for a second prefix.

Pick the shortest prefix that covers the browser row and nothing else. For the console that is /v1/tenants/TENANT_ID/…, so the prefix is /v1/tenants/. Two neighbours must stay private: the bare /v1/tenants, which lists the caller’s tenants and is a server-to-server call, and /v1/access:bulkCheck.

Whether a trailing slash keeps the bare path out depends on your edge:

  • A string prefix, as in HAProxy’s path rules, matches characters. /v1/tenants/ doesn’t match /v1/tenants.
  • Gateway API PathPrefix matches whole path elements and ignores the trailing slash. PathPrefix /v1/tenants/ also matches /v1/tenants, so add an Exact rule for the bare path. Exact takes precedence.

Write the reason for the prefix in a comment next to the rule. Whoever widens it later needs that reason.

With Gateway API, rendered by the operator

Section titled “With Gateway API, rendered by the operator”

Name the prefix on the API audience and let the operator write the routes. paths restricts the audience’s hostnames to those prefixes; every other path matches no rule and is refused at the edge. A prefix with a trailing slash also gets an Exact rule for the bare path that forwards nowhere, so /v1/tenants is refused as well. On GKE, gatewayTLSOptions names the Certificate Manager certificate of each listener, and the operator renders a HealthCheckPolicy per routed Service that checks the pod’s readiness path; delete any policy you wrote by hand for those Services first.

spec:
networking:
gateway:
create:
className: gke-l7-regional-external-managed
issuer:
hosts: [ADMIN_HOST]
gatewayTLSOptions:
networking.gke.io/cert-manager-certs: ADMIN_CERT
api:
hosts: [API_HOST]
gatewayTLSOptions:
networking.gke.io/cert-manager-certs: API_CERT
# The console's tenant pages, and nothing else on this hostname.
paths: [/v1/tenants/]
console:
hosts: [CONSOLE_HOST]
gatewayTLSOptions:
networking.gke.io/cert-manager-certs: CONSOLE_CERT

ADMIN_CERT, API_CERT, and CONSOLE_CERT are Certificate Manager certificate names in the Gateway’s region. paths is refused under networking.ingress, which has no way to refuse the bare path. With a Gateway the operator does not own (networking.gateway.ref), set gateway.healthCheckPolicies: Enabled to get the health checks, and omit gatewayTLSOptions, because the listeners belong to the Gateway’s owner.

For an edge the operator cannot render for, leave networking.ingress and networking.gateway unset in the AuthwiseIdentityServer, so the operator renders no routes, and write the routes yourself. Keep networking.api.hosts set: it registers the public hostname with the identity server, which otherwise ignores the forwarded host. One HTTPRoute for the API hostname, pinned to the HTTPS listener:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: api-tenants
namespace: NAMESPACE
spec:
parentRefs:
- name: GATEWAY_NAME
sectionName: https
hostnames:
- "API_HOST"
rules:
# The console's tenant pages, and nothing else on this hostname.
- matches:
- path: {type: PathPrefix, value: /v1/tenants/}
backendRefs:
- name: authwise-api
port: 8444
# PathPrefix ignores the trailing slash, so the bare path needs its own rule.
- matches:
- path: {type: Exact, value: /v1/tenants}
filters:
- type: RequestRedirect
requestRedirect:
hostname: ADMIN_HOST
path: {type: ReplaceFullPath, replaceFullPath: /}
statusCode: 302
# Everything else. Gateway API has no refusal filter, so redirect.
- matches:
- path: {type: PathPrefix, value: /}
filters:
- type: RequestRedirect
requestRedirect:
hostname: ADMIN_HOST
path: {type: ReplaceFullPath, replaceFullPath: /}
statusCode: 302

Give the plain HTTP listener one route that redirects to HTTPS, and keep any catch-all route for custom domains separate: a route that names a hostname wins over one that doesn’t, so the catch-all never sees the API hostname.

Keep the operator’s ingress as it is, with a plain / for every hostname, and put the allowlist on the proxy that terminates TLS in front of it. In HAProxy, for example, allow /v1/tenants/ on the API hostname and answer 403 for every other path. The proxy is then the whole path control, and the ingress behind it stays simple.

  • The console gets the public hostname through its configuration, https://API_HOST.
  • Workloads in the cluster use the Service, authwise-api.NAMESPACE.svc:8444, in plaintext. Another Authwise install that checks access at this one sets that endpoint in its own custom resource.
  • Operators forward the Service port, as in Reach the Admin API, or use a hostname that resolves only on your private network. Either way, awctl and the Terraform provider never need the public hostname.
  • The tenancy admin server on port 9443 has no route of any kind. Reach it with a port-forward and a client certificate.

For the Service the public route names:

  • Put your web application firewall and request logging on it. On GKE that is a GCPBackendPolicy.
  • Give the load balancer a health check that repeats the pod’s readiness probe, /health on port 8444. The load balancer doesn’t read the probe itself. The operator renders one on a GKE Gateway it creates; write it yourself for any other edge.
  • Set trustedProxies in the install’s configuration to the load balancer’s address ranges, so sign-in records and rate limits see the client’s address rather than the proxy’s.
  • Add an ingress network policy that admits the load balancer’s ranges to the API pods and denies everything else from outside the namespace.

From outside the cluster, with no credential:

Terminal window
curl -si https://API_HOST/v1/tenants/t-01 | head -1
curl -si https://API_HOST/v1/tenants | head -1
curl -si https://API_HOST/v1/tenantsX | head -1
curl -si https://API_HOST/v1/access:bulkCheck | head -1
RequestExpect
/v1/tenants/t-01401. The path is routed and the API asked for a credential. A path the API doesn’t serve answers 404 instead and proves nothing.
/v1/tenants302 with the routes above, an error from the Gateway with the operator’s paths, 403 with a proxy. The bare path is refused.
/v1/tenantsXThe same. A sibling that shares the string prefix is refused.
/v1/access:bulkCheckThe same.

From inside the cluster, the private endpoint answers the bare path. The Service speaks HTTP/2 without TLS, so tell curl so:

Terminal window
curl -si --http2-prior-knowledge http://authwise-api.NAMESPACE.svc:8444/v1/tenants | head -1

Expect 401. Then do the two product checks: a tenant administrator signs in to the console and their tenant’s pages load, and an operator’s awctl command succeeds against the private endpoint.

Only when a browser caller adds a path outside the prefix. Then add the path to your inventory with its reason, add a second match rule rather than shortening the prefix to a parent, keep the refusal rule last, and run the verification again with the new path and with a sibling that must still be refused. If the new path is one that a workload or an operator also uses, stop: the console is reaching for a private API, and the fix belongs in the console.