diff --git a/doc/user-guides/auth-for-app-devs-and-platform-engineers.md b/doc/user-guides/auth-for-app-devs-and-platform-engineers.md index bfefd94d5..807b0be62 100644 --- a/doc/user-guides/auth-for-app-devs-and-platform-engineers.md +++ b/doc/user-guides/auth-for-app-devs-and-platform-engineers.md @@ -2,41 +2,37 @@ This guide walks you through the process of setting up a local Kubernetes cluster with Kuadrant where you will protect [Gateway API](https://gateway-api.sigs.k8s.io/) endpoints by declaring Kuadrant AuthPolicy custom resources. -Two AuthPolicies will be declared: +Three AuthPolicies will be declared: -| Use case | AuthPolicy | -|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **App developer** | 1 AuthPolicy targeting a HTTPRoute that routes traffic to a sample Toy Store application, and enforces API key authentication to all requests in this route, as well as requires API key owners to be mapped to `groups:admins` metadata to access a specific HTTPRouteRule of the route. | -| **Platform engineer use-case** | 1 AuthPolicy targeting the `kuadrant-ingressgateway` Gateway that enforces a trivial "deny-all" policy that locks down any other HTTPRoute attached to the Gateway. | +| Use case | AuthPolicies | +|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **App developer** | 2 AuthPolicies targeting a HTTPRoute that routes traffic to a sample "Toy Store" application → enforce API key authentication to all requests in this route; require API key owners to be mapped to `groups:admins` metadata to access a specific HTTPRouteRule of the route. | +| **Platform engineer use-case** | 1 AuthPolicy targeting the `kuadrant-ingressgateway` Gateway → enforces a trivial "deny-all" policy that locks down any other HTTPRoute attached to the Gateway. | Topology: ``` - ┌───────────────┐ - │ (AuthPolicy) │ - │ gw-auth │ - └───────┬───────┘ - │ - ▼ - ┌─────────────────────────┐ - │ (Gateway) │ - │ kuadrant-ingressgateway │ - ┌────►│ │◄───┐ - │ │ * │ │ - │ └─────────────────────────┘ │ - │ │ - ┌────────┴─────────┐ ┌────────┴─────────┐ - │ (HTTPRoute) │ │ (HTTPRoute) │ - │ toystore │ │ other │ - │ │ │ │ - │ api.toystore.com │ │ *.other-apps.com │ - └──────────────────┘ └──────────────────┘ - ▲ - │ - ┌───────┴───────┐ - │ (AuthPolicy) │ - │ toystore │ - └───────────────┘ + ┌─────────────────────────┐ + │ (Gateway) │ ┌───────────────┐ + │ kuadrant-ingressgateway │◄──│ (AuthPolicy) │ + │ │ │ gw-auth │ + │ * │ └───────────────┘ + └─────────────────────────┘ + ▲ ▲ + ┌────────┴─────────┐ ┌────────┴─────────┐ +┌────────────────┐ │ (HTTPRoute) │ │ (HTTPRoute) │ +│ (AuthPolicy) │──►│ toystore │ │ other │ +│ toystore-authn │ │ │ │ │ +└────────────────┘ │ api.toystore.com │ │ *.other-apps.com │ + └──────────────────┘ └──────────────────┘ + ▲ ▲ + ┌─────────┴───────┐ ┌──────┴──────────┐ + | (HTTPRouteRule) | | (HTTPRouteRule) | ┌─────────────────┐ + | rule-1 | | rule-2 |◄──│ (AuthPolicy) │ + | | | | │ toystore-admins │ + | - GET /cars* | | - /admins* | └─────────────────┘ + | - GET /dolls* | └─────────────────┘ + └─────────────────┘ ``` ## Requisites @@ -88,7 +84,7 @@ spec: hostnames: - api.toystore.com rules: - - matches: + - matches: # rule-1 - method: GET path: type: PathPrefix @@ -100,7 +96,7 @@ spec: backendRefs: - name: toystore port: 80 - - matches: + - matches: # rule-2 - path: type: PathPrefix value: "/admin" @@ -137,31 +133,47 @@ curl -H 'Host: api.toystore.com' http://$GATEWAY_URL/admin -i ### ③ Protect the Toy Store application (Persona: _App developer_) -Create the AuthPolicy to enforce the following auth rules: +Create AuthPolicies to enforce the following auth rules: - **Authentication:** - All users must present a valid API key - **Authorization:** - - `/admin*` routes require user mapped to the `admins` group (`kuadrant.io/groups=admins` annotation added to the Kubernetes API key Secret) + - `/admin*` paths (2nd rule of the HTTPRoute) require user mapped to the `admins` group (`kuadrant.io/groups=admins` annotation added to the Kubernetes API key Secret) ```sh kubectl apply -f - <