|
| 1 | +--- |
| 2 | +title: Secure multi-tier applications |
| 3 | +weight: 20 |
| 4 | +aliases: /layered-zero-trust/lzt-secure-multitier |
| 5 | +--- |
| 6 | + |
| 7 | +:toc: |
| 8 | +:imagesdir: /images |
| 9 | +:_mod-docs-content-type: ASSEMBLY |
| 10 | +include::modules/comm-attributes.adoc[] |
| 11 | + |
| 12 | +[id="lzt-secure-multitier"] |
| 13 | += Use case: Secure multi-tier applications |
| 14 | + |
| 15 | +This use case demonstrates securing a common application design pattern: a frontend application using a database for persistent storage. |
| 16 | + |
| 17 | +The Layered Zero Trust Pattern includes the `qtodo` application, which demonstrates a secure just-in-time (JIT) credential mechanism. |
| 18 | + |
| 19 | +Instead of relying on static credentials stored within the application, the `qtodo` application uses a JIT method to dynamically fetch database credentials from a central credential store. |
| 20 | + |
| 21 | +[id="lazt-application-architecture"] |
| 22 | +== Application components and architecture |
| 23 | + |
| 24 | +The `qtodo` application consists of the following key components and their security roles: |
| 25 | + |
| 26 | +* The `qtodo` application: A link:https://quarkus.io[Quarkus-based] frontend application protected by OpenID Connect (OIDC) authentication. Users are managed in an external identity store which uses Red{nbsp}Hat Build of Keycloak (RHBK). |
| 27 | + |
| 28 | +* PostgreSQL: The relational database used by the `qtodo` application. Its credentials are dynamically generated and stored within HashiCorp Vault. |
| 29 | + |
| 30 | +* External Identity store: Contains the provisioned users and configured OIDC clients that enable access to the `qtodo` frontend. |
| 31 | + |
| 32 | +* HashiCorp Vault: Stores sensitive values for components, including PostgreSQL and RHBK. Implements JSON Web Token (JWT)-based authentication to enable access by using Zero Trust Workload Identity Manager (ZTWIM)-based identities. |
| 33 | + |
| 34 | +* Zero Trust Workload Identity Manager: It assigns an identity to the `qtodo` application, allowing it to communicate with HashiCorp Vault and obtain the necessary PostgreSQL credentials. |
| 35 | + |
| 36 | +* link:https://github.com/spiffe/spiffe-helper[spiffe-helper]: A supplemental sidecar component for the `qtodo` application used to dynamically fetch JWT-based identities from the SPIFFE Workload API. |
| 37 | + |
| 38 | +[id="lzt-exploring-qtodo"] |
| 39 | +== Exploring the qtodo application |
| 40 | + |
| 41 | +The `qtodo` application is a key component of the Layered Zero Trust Pattern, demonstrating the secure JIT fetching of credentials. To explore how the application implements Zero Trust principles, use the {ocp} web console of the Hub cluster to investigate the resources in the `qtodo` project. |
| 42 | + |
| 43 | +.Procedure |
| 44 | + |
| 45 | +. In the {ocp} web console, navigate to the *Projects* page and select the `qtodo` project. This namespace contains the `qtodo` Quarkus application and the `qtodo-db` PostgreSQL database. |
| 46 | +. Select *Workloads* -> *Pods* from the left-hand navigation bar. Explore both the `qtodo` and `qtodo-db` pods. |
| 47 | ++ |
| 48 | +[NOTE] |
| 49 | +==== |
| 50 | +The `qtodo` pod uses a series of init containers and sidecar containers to supply the application with the credentials required for operation. |
| 51 | +==== |
| 52 | + |
| 53 | +[id="lzt-locate-app"] |
| 54 | +=== Locating the application address |
| 55 | + |
| 56 | +You can access the `qtodo` application through the {ocp} route. |
| 57 | + |
| 58 | +.Procedure |
| 59 | + |
| 60 | +. In the {ocp} web console, navigate to the *Projects* page and select the `qtodo` project. |
| 61 | +. Select *Networking* -> *Routes* from the left-hand navigation bar. Note the URL for the `qtodo` application in the *Location* column. |
| 62 | +. Open a new browser tab and navigate to the `qtodo` application URL. |
| 63 | +. The RHBK login page appears. |
| 64 | + |
| 65 | +[id="lzt-locate-app-credentials"] |
| 66 | +=== Locating the application credentials |
| 67 | + |
| 68 | +The default External Identity Provider, RHBK, is provisioned with two users: `qtodo-admin` and `qtodo-user`. You can find the initial credentials in a Secret within the `keycloak-system` namespace called `keycloak-users`. |
| 69 | + |
| 70 | +.Procedure |
| 71 | + |
| 72 | +. In the {ocp} web console, navigate to the *Projects* page and select the `keycloak-system` project. |
| 73 | +. Select *Workloads* -> *Secrets* from the left-hand navigation bar. |
| 74 | +. Select the `keycloak-users` secret. |
| 75 | +. Click the *Reveal values* link to see the credentials. |
| 76 | + |
| 77 | +[id="lzt-access-qtodo"] |
| 78 | +=== Accessing the application |
| 79 | + |
| 80 | +.Procedure |
| 81 | + |
| 82 | +. Navigate to the RHBK login page, as described in the xref:lzt-locate-app[Locate the application's address] section. |
| 83 | + |
| 84 | +. Enter the username and password for one of the users, using the values found in the xref:lzt-locate-app-credentials[Locate the application credentials] section. |
| 85 | + |
| 86 | +. After you log in, follow the on-screen instructions to change the temporary password. |
| 87 | + |
| 88 | +. Set a new password and confirm the change. |
| 89 | ++ |
| 90 | +After the password change is complete, the `qtodo` application appears. |
| 91 | + |
| 92 | +[id="lzt-verify-integration"] |
| 93 | +=== Verifying integration |
| 94 | + |
| 95 | +The `qtodo` application uses PostgreSQL for persistent storage. You can verify that the application is correctly integrated with the database by creating a new to-do item. |
| 96 | + |
| 97 | +.Procedure |
| 98 | +. In the `qtodo` application, add new items to the list of to-dos and remove existing items. |
| 99 | +. Refresh the page to verify that the items persist. |
| 100 | + |
| 101 | +By successfully modifying the list, you confirm that the integration between the Quarkus application and the PostgreSQL database—using credentials sourced dynamically from HashiCorp Vault—was successful. |
0 commit comments