|
| 1 | +# Zero Trust architecture |
| 2 | + |
| 3 | +This repository implements [ORY Zero Trust architecture](https://www.ory.sh/docs/kratos/guides/zero-trust-iap-proxy-identity-access-proxy) |
| 4 | +using: |
| 5 | + |
| 6 | +* [ORY Kratos Identity Server](https://github.com/ory/kratos) as authentication and identity provider. |
| 7 | +* [ORY Oathkeeper](https://github.com/ory/oathkeeper) as reverse proxy to take care of authentication and access control. |
| 8 | + |
| 9 | +If you access the API docs at `/docs` you will notice that the `/hello/` endpoint |
| 10 | +is protected but the authentication infrastructure doesn't spin up when running |
| 11 | +`docker compuse up dev`. |
| 12 | + |
| 13 | +You can spin up all the authentication infrastructure by running `docker compose up oathkeeper`. |
| 14 | +You should be able to access the authentication UI at [http://127.0.0.1:8080](http://127.0.0.1:8080) and, |
| 15 | +after you will be authenticated, you will be able to access the protected `/hello` |
| 16 | +endpoint at [http://127.0.0.1:8080/hello](http://127.0.0.1:8080/hello) |
| 17 | + |
| 18 | +/// admonition | Cookie-based security |
| 19 | + type: warning |
| 20 | + |
| 21 | +The current setup is built around the example authentication UI provided by ORY, |
| 22 | +which uses the flows for browser-based application, with CSRF protection, and stores |
| 23 | +the session token using Cookies. |
| 24 | + |
| 25 | +While this is not a bad approach, it is not suitable for Single Page Applications |
| 26 | +and API-based clients, because it is open to different vector attacks (CSRF among them). |
| 27 | + |
| 28 | +Reference: [https://www.ory.sh/docs/kratos/self-service/flows/user-login#login-for-api-clients-and-clients-without-browsers](https://www.ory.sh/docs/kratos/self-service/flows/user-login#login-for-api-clients-and-clients-without-browsers) |
| 29 | + |
| 30 | +🚧 An authentication flow using [Oauth2](https://oauth.net/2/), based on [ORY Hydra](https://github.com/ory/hydra) |
| 31 | +and integrated with this setup, will be added in the future. It will provide provide secure flows for SPAs and other |
| 32 | +API based clients. 🚧 |
| 33 | +/// |
| 34 | + |
| 35 | +This is a high level representation of the used components: |
| 36 | + |
| 37 | +```mermaid |
| 38 | +graph TD |
| 39 | +subgraph hn[Host Network] |
| 40 | + B[Browser] |
| 41 | + B-->|Can access URLs via 127.0.0.1:8080|OKPHN |
| 42 | + B-->|Can access URLs via 127.0.0.1:8000|DEVHN |
| 43 | + OKPHN([Reverse Proxy exposed at :8080]) |
| 44 | + DEVHN([Dev Container exposed at :8000]) |
| 45 | +end |
| 46 | +subgraph dn["Internal Docker Network (intranet)"] |
| 47 | + OKPHN-->OO |
| 48 | + DEVHN-->DEV |
| 49 | + OO-->|Proxies URLss /.ory/kratos/public/* to|OK |
| 50 | + OO-->|"Proxies /auth/login, /auth/registration, /dashboard, ... to"|SA |
| 51 | + SA-->|Talks to|OK |
| 52 | + OO-->|Validates auth sessions using|OK |
| 53 | + OO-->|"Proxies /hello to"|DEV |
| 54 | + OK[Ory Kratos] |
| 55 | + OO["Reverse Proxy (Ory Oathkeeper)"] |
| 56 | + SA["SecureApp (Ory Kratos SelfService UI Node Example)"] |
| 57 | + DEV[Dev Container] |
| 58 | +end |
| 59 | +``` |
0 commit comments