Skip to content

Commit 3b8af16

Browse files
committed
Add documentation
Signed-off-by: Federico Busetti <[email protected]>
1 parent 0ae4e78 commit 3b8af16

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This template provides out of the box some commonly used functionalities:
2424
* Async tasks execution using [Dramatiq](https://dramatiq.io/index.html)
2525
* Repository pattern for databases using [SQLAlchemy](https://www.sqlalchemy.org/) and [SQLAlchemy bind manager](https://febus982.github.io/sqlalchemy-bind-manager/stable/)
2626
* Database migrations using [Alembic](https://alembic.sqlalchemy.org/en/latest/) (configured supporting both sync and async SQLAlchemy engines)
27+
* Authentication and Identity Provider using [ORY Zero Trust architecture](https://www.ory.sh/docs/kratos/guides/zero-trust-iap-proxy-identity-access-proxy)
2728
* [TODO] Producer and consumer to emit and consume events using [CloudEvents](https://cloudevents.io/) format on [Confluent Kafka](https://docs.confluent.io/kafka-clients/python/current/overview.html)
2829

2930
## Documentation

docs/.pages

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ nav:
22
- Home: index.md
33
- api-documentation.md
44
- architecture.md
5-
- src packages: packages
5+
- zero_trust.md
66
- inversion-of-control.md
77
- dockerfile.md
8+
- src packages: packages
89
- ...
910
- ADR: adr

docs/zero_trust.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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

Comments
 (0)