Skip to content

Commit 8c3bf51

Browse files
Update HedgeDoc guide (#1265)
* updates hedgedoc guide * updates text * fixes pre-commits * Update content/docs/guides/hedgedoc.md Co-authored-by: cmo-pomerium <[email protected]> --------- Co-authored-by: cmo-pomerium <[email protected]>
1 parent 0843f50 commit 8c3bf51

10 files changed

+109
-113
lines changed

content/docs/guides/hedgedoc.md

+109-113
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,113 @@
11
---
2-
# cSpell:ignore hedgedoc addport
2+
# cSpell:ignore hedgedoc addport privkey USESSL
33

44
title: Securing HedgeDoc with Pomerium
55
sidebar_label: HedgeDoc
66
lang: en-US
7-
keywords:
8-
[
9-
pomerium,
10-
identity access proxy,
11-
data,
12-
logging,
13-
graphing,
14-
HedgeDoc,
15-
authentication,
16-
authorization,
17-
]
18-
description: This guide covers how to use Pomerium to authenticate and authorize users of HedgeDoc.
7+
keywords: [pomerium, HedgeDoc, authentication, authorization]
8+
description: Learn how to control access to your HedgeDoc web application behind Pomerium.
199
---
2010

2111
# HedgeDoc
2212

23-
Use Pomerium to secure access to HedgeDoc by providing identity and context.
13+
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 grant or deny access based on policy criteria.
2414

2515
## What is HedgeDoc?
2616

27-
[HedgeDoc](https://hedgedoc.org/) is a collaborative, web-based Markdown editor that allows you to create notes, graphs, and diagrams in your browser.
17+
[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.
2818

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

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

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/).
23+
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.
3424

35-
You can configure Pomerium so that it authenticates and authorizes users against an Identity Provider (IdP) before users can access HedgeDoc's services.
36-
37-
The flow looks like this:
38-
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.
25+
### Before you start
5126

5227
To complete this guide, you need:
5328

5429
- [Docker](https://www.docker.com/)
5530
- [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
31+
- [mkcert](https://github.com/FiloSottile/mkcert#installation)
6032

61-
**Note**
33+
:::note
6234

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

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).
37+
- `config.yaml`
38+
- `docker-compose.yaml`
7039

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

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.
42+
- Create a `config.yaml` file for your Pomerium configuration
43+
- Create a `docker-compose.yaml` file for your Docker configuration
8644

8745
:::
8846

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

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):
49+
Add the following configuration to `config.yaml`:
9750

9851
```yaml
99-
allow_websockets: true
100-
```
52+
authenticate_service_url: https://authenticate.pomerium.app
10153

102-
Lastly, define your routes:
54+
certificate_file: /pomerium/cert.pem
55+
certificate_key_file: /pomerium/privkey.pem
10356

104-
```yaml
10557
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-
11158
- from: https://hedgedoc.localhost.pomerium.io
112-
to: http://app:3000
113-
pass_identity_headers: true
114-
allow_any_authenticated_user: true
59+
to: http://hedgedoc:3000
60+
allow_websockets: true
61+
policy:
62+
- allow:
63+
or:
64+
- email:
65+
# Replace with your email address
66+
11567
```
11668
117-
To see if Pomerium is configured correctly, run the following command in your terminal:
69+
#### Create a wildcard TLS certificate
70+
71+
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:
72+
73+
1. Install `mkcert` with these [instructions](https://github.com/FiloSottile/mkcert#installation)
74+
1. Create a trusted **rootCA**:
11875

11976
```bash
120-
docker-compose up
77+
mkcert -install
12178
```
12279

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.
80+
1. Create a wildcard certificate for `*.localhost.pomerium.io`:
12481

125-
![GitHub IdP sign-in prompt](./img/hedgedoc/gh-idp-hedgedoc.png)
82+
```bash
83+
mkcert '*.localhost.pomerium.io'
84+
```
12685

127-
Navigate to `https://authenticate.localhost.pomerium.io/.pomerium/` to see your User Details:
86+
This creates two files in your working directory:
12887

129-
![Pomerium User Details](./img/hedgedoc/user-details-page.png)
88+
- `_wildcard.localhost.pomerium.io.pem`
89+
- `_wildcard.localhost.pomerium.io-key.pem`
13090

131-
Congratulations! You've successfully configured and run Pomerium.
91+
In the next section, you'll bind mount these certificates in a Docker Compose file.
13292

133-
### Secure HedgeDoc
93+
### Set up HedgeDoc
13494

135-
In your `docker-compose.yaml` file, add the following code under your Pomerium services:
95+
In your `docker-compose.yaml` file, add the following services:
13696

13797
```yaml
138-
# verify:
139-
# image: pomerium/verify:latest
140-
# expose:
141-
# - 8000
142-
---
143-
144-
database:
98+
version: '3'
99+
services:
100+
pomerium:
101+
image: cr.pomerium.com/pomerium/pomerium:latest
102+
volumes:
103+
# Mount your certificates
104+
- ./_wildcard.localhost.pomerium.io.pem:/pomerium/cert.pem:ro
105+
- ./_wildcard.localhost.pomerium.io-key.pem:/pomerium/privkey.pem:ro
106+
# Mount your config file: https://www.pomerium.com/docs/reference/
107+
- ./config.yaml:/pomerium/config.yaml:ro
108+
ports:
109+
- 443:443
110+
database:
145111
image: postgres:13.4-alpine
146112
environment:
147113
- POSTGRES_USER=hedgedoc
@@ -150,20 +116,22 @@ database:
150116
volumes:
151117
- database:/var/lib/postgresql/data
152118
restart: always
153-
app:
119+
hedgedoc:
154120
# Make sure to use the latest release from https://hedgedoc.org/latest-release
155-
image: quay.io/hedgedoc/hedgedoc:1.9.4
121+
image: quay.io/hedgedoc/hedgedoc:1.9.9
156122
environment:
157123
- CMD_DB_URL=postgres://hedgedoc:password@database:5432/hedgedoc
158124
- CMD_DOMAIN=hedgedoc.localhost.pomerium.io
159125
- CMD_URL_ADDPORT=false
160126
- CMD_EMAIL=true
161127
- CMD_ALLOW_EMAIL_REGISTER=true
162-
- CMD_SESSION_SECRET=<session secret>
128+
# Replace cookie session secret
129+
- CMD_SESSION_SECRET=<replace_session_secret>
130+
- CMD_PROTOCOL_USESSL=true
163131
volumes:
164132
- uploads:/hedgedoc/public/uploads
165133
ports:
166-
- "3000:3000"
134+
- '3000:3000'
167135
restart: always
168136
depends_on:
169137
- database
@@ -172,34 +140,62 @@ volumes:
172140
uploads:
173141
```
174142

175-
Update your environment variables with the following values:
143+
> See the [HedgeDoc - Configuration](https://docs.hedgedoc.org/configuration/#configuration) page for more information on configuration keys and environment variables.
144+
145+
#### Generate a session secret
146+
147+
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.
148+
149+
Adding a session secret will allow you to resume a session even if you stop your Docker services.
150+
151+
To generate a secret, run:
152+
153+
```shell-session
154+
$ head -c32 /dev/urandom | base64
155+
MPGHgArlo81ohUoMtDtv8qCBLJu0lwXDCPcrml0wF2Q=
156+
```
157+
158+
Replace the value of `CMD_SESSION_SECRET` with the output:
176159

177160
```yaml
178-
- CMD_DOMAIN=hedgedoc.localhost.pomerium.io
161+
- CMD_SESSION_SECRET=MPGHgArlo81ohUoMtDtv8qCBLJu0lwXDCPcrml0wF2Q=
179162
```
180163

181-
:::caution
164+
#### TLS in HedgeDoc
182165

183-
You must add a session secret. If you don't, HedgeDoc will randomly generate a secret, which will log out all users.
166+
To configure HedgeDoc to use HTTPS:
184167

185-
:::
168+
- Set `CMD_PROTOCOL_USESSL` to `true`
169+
- Set `CMD_ADDPORT` to `false`
170+
171+
## Run HedgeDoc and Pomerium
186172

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

189175
```bash
190-
head -c32 /dev/urandom | base64
176+
docker compose up
191177
```
192178

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

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

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

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

201-
#### Resources:
199+
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:
202200

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/)
201+
![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)