Skip to content

Commit f989ee7

Browse files
committed
updates hedgedoc guide
1 parent 4decd4a commit f989ee7

10 files changed

+105
-110
lines changed

content/docs/guides/hedgedoc.md

+105-110
Original file line numberDiff line numberDiff line change
@@ -7,141 +7,109 @@ lang: en-US
77
keywords:
88
[
99
pomerium,
10-
identity access proxy,
11-
data,
12-
logging,
13-
graphing,
1410
HedgeDoc,
1511
authentication,
1612
authorization,
1713
]
18-
description: This guide covers how to use Pomerium to authenticate and authorize users of HedgeDoc.
14+
description: Learn how to control access to your HedgeDoc web application behind Pomerium.
1915
---
2016

2117
# HedgeDoc
2218

23-
Use Pomerium to secure access to HedgeDoc by providing identity and context.
19+
In this guide, you'll learn how to run a HedgeDoc web application behind Pomerium. You'll also add an authorization policy that enables Pomerium to gran or deny access based on policy criteria.
2420

2521
## What is HedgeDoc?
2622

27-
[HedgeDoc](https://hedgedoc.org/) is a collaborative, web-based Markdown editor that allows you to create notes, graphs, and diagrams in your browser.
23+
[HedgeDoc](https://hedgedoc.org/) is a collaborative, web-based Markdown editor that allows you to create notes, graphs, and diagrams in your browser. You can share a link to your documents with other members of your organization so you can collaborate in real time.
2824

29-
You can share a link to your document with other members of your organization so you can collaborate in real time.
25+
## How to secure HedgeDoc with Pomerium
3026

31-
## Integrate Pomerium with HedgeDoc
27+
HedgeDoc is an open-source project that you can serve behind a [reverse proxy](https://docs.hedgedoc.org/guides/reverse-proxy/).
3228

33-
HedgeDoc is an open-source, self-hosted software that allows you to configure authentication and authorization with a [reverse proxy](https://docs.hedgedoc.org/guides/reverse-proxy/).
29+
In this guide, you'll configure Pomerium to authenticate and authorize users. To do this, you'll add an authorization policy that grants or denies access based on the policy criteria.
3430

35-
You can configure Pomerium so that it authenticates and authorizes users against an Identity Provider (IdP) before users can access HedgeDoc's services.
31+
### Before you start
3632

37-
The flow looks like this:
33+
To complete this guide, you need:
3834

39-
1. User requests to access the secured app
40-
2. Pomerium identifies user
41-
3. Pomerium checks if user is authorized to access routes defined in the authorization [`policy`](https://www.pomerium.com/docs/reference/routes/policy)
42-
4. If authorized, Pomerium authenticates user against IdP
43-
5. After IdP establishes user's identity, Pomerium checks permissions against the secured app
44-
6. User can make authorized requests in the secured app
45-
46-
![Pomerium IAP flow](./img/hedgedoc/pom-auth-flow.png)
47-
48-
### Set up your environment
49-
50-
This guide uses Docker containers to create the minimal development environment required to run Pomerium with another service. Visit the [Pomerium using Docker](https://www.pomerium.com/docs/quickstart) quickstart for more information.
51-
52-
To complete this guide, you need:
53-
54-
- [Docker](https://www.docker.com/)
35+
- [Docker](https://www.docker.com/)
5536
- [Docker Compose](https://docs.docker.com/compose/install/)
56-
- A running Pomerium instance
57-
- A [pre-configured IdP](https://www.pomerium.com/docs/identity-providers)
58-
59-
:::tip
37+
- [mkcert](https://github.com/FiloSottile/mkcert#installation)
6038

61-
**Note**
39+
:::note
6240

63-
This guide uses [GitHub](https://www.pomerium.com/docs/identity-providers/github) as the pre-configured IdP.
41+
If you completed our [**Quickstart guide**](/docs/quickstart), you should have a working Pomerium project with the following YAML files:
6442

65-
:::
66-
67-
### Pomerium configuration
68-
69-
Your Pomerium configuration file must include a [Cookie Secret](https://www.pomerium.com/docs/reference/cookie-secret) and a [Secret Key](https://www.pomerium.com/docs/reference/signing-key).
43+
- `config.yaml`
44+
- `docker-compose.yaml`
7045

71-
To create a Cookie Secret, run the following command in your terminal:
72-
73-
```bash
74-
head -c32 /dev/urandom | base64
75-
```
46+
If you haven't completed the Quickstart:
7647

77-
To create a Secret Key, run the following command:
78-
79-
```bash
80-
cat ec_private.pem | base64
81-
```
82-
83-
:::tip **Note**
84-
85-
This guide assumes you've generated self-signed wildcard certificates. Check [Certificates](https://www.pomerium.com/docs/topics/certificates#self-signed-wildcard-certificate) for more information.
48+
- Create a `config.yaml` file for your Pomerium configuration
49+
- Create a `docker-compose.yaml` file for your Docker configuration
8650

8751
:::
8852

89-
Place your `cookie_secret` and `secret_key` in your `config.yaml` file:
53+
### Set up Pomerium
9054

91-
```yaml
92-
cookie_secret: <cookie secret>
93-
signing_key: <signing key>
94-
```
95-
96-
Then, enable Pomerium to allow [Websocket Connections](https://www.pomerium.com/docs/reference/routes/timeouts#websocket-connections):
55+
Add the following configuration to `config.yaml`:
9756

9857
```yaml
99-
allow_websockets: true
100-
```
58+
authenticate_service_url: https://authenticate.pomerium.app
10159

102-
Lastly, define your routes:
60+
certificate_file: /pomerium/cert.pem
61+
certificate_key_file: /pomerium/privkey.pem
10362

104-
```yaml
10563
routes:
106-
- from: https://verify.localhost.pomerium.io
107-
to: http://verify:8000
108-
pass_identity_headers: true
109-
allow_any_authenticated_user: true
110-
11164
- from: https://hedgedoc.localhost.pomerium.io
112-
to: http://app:3000
113-
pass_identity_headers: true
114-
allow_any_authenticated_user: true
65+
to: http://hedgedoc:3000
66+
allow_websockets: true
67+
policy:
68+
- allow:
69+
or:
70+
- email:
71+
# Replace with your email address
72+
11573
```
11674
117-
To see if Pomerium is configured correctly, run the following command in your terminal:
75+
#### Create a wildcard TLS certificate
11876
119-
```bash
120-
docker-compose up
121-
```
122-
123-
Navigate to `https://authenticate.localhost.pomerium.io`. Pomerium will redirect you to your GitHub OAuth app, where you can authorize the OAuth app to access your GitHub account.
77+
HedgeDoc requires an encrypted TLS connection to add and manage users. For the purposes of this guide, you will use `mkcert` to generate local development certificates:
12478

125-
![GitHub IdP sign-in prompt](./img/hedgedoc/gh-idp-hedgedoc.png)
79+
1. Install `mkcert` with these [instructions](https://github.com/FiloSottile/mkcert#installation)
80+
1. Create a trusted **rootCA**:
81+
```bash
82+
mkcert -install
83+
```
84+
1. Create a wildcard certificate for `*.localhost.pomerium.io`:
85+
```bash
86+
mkcert '*.localhost.pomerium.io'
87+
```
88+
This creates two files in your working directory:
12689

127-
Navigate to `https://authenticate.localhost.pomerium.io/.pomerium/` to see your User Details:
90+
- `_wildcard.localhost.pomerium.io.pem`
91+
- `_wildcard.localhost.pomerium.io-key.pem`
12892

129-
![Pomerium User Details](./img/hedgedoc/user-details-page.png)
93+
In the next section, you'll notice these certificates are mounted in a Docker Compose file.
13094

131-
Congratulations! You've successfully configured and run Pomerium.
95+
### Set up HedgeDoc
13296

133-
### Secure HedgeDoc
134-
135-
In your `docker-compose.yaml` file, add the following code under your Pomerium services:
97+
In your `docker-compose.yaml` file, add the following services:
13698

13799
```yaml
138-
# verify:
139-
# image: pomerium/verify:latest
140-
# expose:
141-
# - 8000
142-
---
143-
144-
database:
100+
version: '3'
101+
services:
102+
pomerium:
103+
image: cr.pomerium.com/pomerium/pomerium:latest
104+
volumes:
105+
# Mount your certificates
106+
- ./_wildcard.localhost.pomerium.io.pem:/pomerium/cert.pem:ro
107+
- ./_wildcard.localhost.pomerium.io-key.pem:/pomerium/privkey.pem:ro
108+
# Mount your config file: https://www.pomerium.com/docs/reference/
109+
- ./config.yaml:/pomerium/config.yaml:ro
110+
ports:
111+
- 443:443
112+
database:
145113
image: postgres:13.4-alpine
146114
environment:
147115
- POSTGRES_USER=hedgedoc
@@ -150,16 +118,18 @@ database:
150118
volumes:
151119
- database:/var/lib/postgresql/data
152120
restart: always
153-
app:
121+
hedgedoc:
154122
# Make sure to use the latest release from https://hedgedoc.org/latest-release
155-
image: quay.io/hedgedoc/hedgedoc:1.9.4
123+
image: quay.io/hedgedoc/hedgedoc:1.9.9
156124
environment:
157125
- CMD_DB_URL=postgres://hedgedoc:password@database:5432/hedgedoc
158126
- CMD_DOMAIN=hedgedoc.localhost.pomerium.io
159127
- CMD_URL_ADDPORT=false
160128
- CMD_EMAIL=true
161129
- CMD_ALLOW_EMAIL_REGISTER=true
162-
- CMD_SESSION_SECRET=<session secret>
130+
# Replace cookie session secret
131+
- CMD_SESSION_SECRET=<replace_session_secret>
132+
- CMD_PROTOCOL_USESSL=true
163133
volumes:
164134
- uploads:/hedgedoc/public/uploads
165135
ports:
@@ -172,34 +142,59 @@ volumes:
172142
uploads:
173143
```
174144

175-
Update your environment variables with the following values:
145+
> See the [HedgeDoc - Configuration](https://docs.hedgedoc.org/configuration/#configuration) page for more information on configuration keys and environment variables.
146+
147+
#### Generate a session secret
148+
149+
HedgeDoc requires a session secret to sign session cookies. If you don't add a session secret, HedgeDoc generates a random one for you upon startup, which will end any active sessions and sign out your users.
150+
151+
Adding a session secret will allow you to resume a session even if you stop your Docker services.
152+
153+
To generate a secret, run:
154+
155+
```shell-session
156+
$ head -c32 /dev/urandom | base64
157+
MPGHgArlo81ohUoMtDtv8qCBLJu0lwXDCPcrml0wF2Q=
158+
```
159+
160+
Replace the value of `CMD_SESSION_SECRET` with the output:
176161

177162
```yaml
178-
- CMD_DOMAIN=hedgedoc.localhost.pomerium.io
163+
- CMD_SESSION_SECRET=MPGHgArlo81ohUoMtDtv8qCBLJu0lwXDCPcrml0wF2Q=
179164
```
180165

181-
:::caution
166+
#### TLS in HedgeDoc
182167

183-
You must add a session secret. If you don't, HedgeDoc will randomly generate a secret, which will log out all users.
168+
To access HedgeDoc over HTTPS, you must set `CMD_PROTOCOL_USESSL` and `CMD_ADDPORT` to `false`.
184169

185-
:::
170+
## Run HedgeDoc and Pomerium
186171

187-
To generate a session secret, run the following command in your terminal:
172+
Run Docker Compose:
188173

189174
```bash
190-
head -c32 /dev/urandom | base64
175+
docker compose up
191176
```
192177

193-
Now, run `docker-compose up`
178+
Navigate to `https://hedgedoc.localhost.pomerium.io/` to access HedgeDoc.
179+
180+
Pomerium will prompt you to authenticate:
181+
182+
![Signing in to Pomerium's identity provider](./img/hedgedoc/cognito-idp.png)
183+
184+
After successful authentication, Pomerium will redirect you to your HedgeDoc URL:
185+
186+
![The HedgeDoc homepage](./img/hedgedoc/hedgedoc-homepage.png)
187+
188+
## Add a user
194189

195-
Navigate to `https://hedgedoc.localhost.pomerium.io/` to access HedgeDoc:
190+
1. Select **Sign In**
191+
1. Enter an **E-Mail** and **Password**
192+
1. Select **Register**
196193

197-
![HedgeDoc service](./img/hedgedoc/hedgedoc.png)
194+
When you sign in, HedgeDoc will take you to your user dashboard:
198195

199-
Great job! You've secured HedgeDoc using Pomerium's identity-aware proxy.
196+
![Secured HedgeDoc user dashboard page](./img/hedgedoc/user-dashboard.png)
200197

201-
#### Resources:
198+
If you check the connection, you'll notice it's secure. Now, you can write your first note and share it with users within your network:
202199

203-
- [Pomerium documentation](https://www.pomerium.com/docs)
204-
- [Pomerium reference doc](https://www.pomerium.com/docs/reference)
205-
- [HedgeDoc documentation](https://docs.hedgedoc.org/)
200+
![Adding a note in HedgeDoc](./img/hedgedoc/hedgedoc-note.png)
33.6 KB
Loading
Binary file not shown.
Loading
Loading
Loading
-48.7 KB
Binary file not shown.
Binary file not shown.
Loading
Binary file not shown.

0 commit comments

Comments
 (0)