Skip to content

Commit c94b292

Browse files
authored
Updates tiddlywiki guide (#1274)
* updates first section * updates tiddlywiki guide * runs prettier * Update content/docs/guides/tiddlywiki.mdx
1 parent d58eb10 commit c94b292

11 files changed

+139
-132
lines changed
Loading
Loading
Loading
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.

content/docs/guides/tiddlywiki.mdx

+139-60
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ title: Securing TiddlyWiki on Node.js
33
sidebar_label: TiddlyWiki
44
lang: en-US
55
keywords: [pomerium, identity access proxy, wiki, tiddlywiki]
6-
description: This guide covers how to add authentication and authorization to a hosted online instance of TiddlyWiki.
6+
description: This guide shows you how to configure an authorization policy and SSO to control access to an online instance of Tiddlywiki with Pomerium.
77
---
88

9-
import DockerCompose from '../../examples/tiddlywiki/docker-compose.yaml.md';
109
import Tabs from '@theme/Tabs';
1110
import TabItem from '@theme/TabItem';
1211

@@ -16,117 +15,197 @@ Learn how to add authentication and authorization to an instance of [TiddlyWiki
1615

1716
## What is TiddlyWiki on Node.js
1817

19-
TiddlyWiki is a personal wiki and a non-linear notebook for organizing and sharing complex information. It is available in two forms:
18+
TiddlyWiki is a personal wiki and a non-linear web notebook for organizing and sharing information.
2019

21-
- a single HTML page
22-
- [a Node.js application](https://www.npmjs.com/package/tiddlywiki)
20+
It is available in two forms:
2321

24-
You will use the Node.js application in this guide.
22+
- As a single HTML page
23+
- As a [Node.js application](https://www.npmjs.com/package/tiddlywiki)
2524

26-
## Authentication with Pomerium
25+
In this guide, you will run Pomerium and your TiddlyWiki Node.js application in Docker containers.
2726

28-
TiddlyWiki allows you to authenticate users with the authenticated-user-header parameter of [listen command](https://tiddlywiki.com/static/ListenCommand.html). Pomerium provides the ability to login with well-known [identity providers](/docs/identity-providers#identity-provider-configuration) (IdP).
27+
## How you will secure TiddlyWiki
2928

30-
Pomerium can forward specific user session data to upstream applications. In the case of this guide, Pomerium will forward the email associated with your IdP to TiddlyWiki.
29+
Securing access to TiddlyWiki involves two steps:
3130

32-
## Set up your environment
31+
- Configuring Pomerium to forward specific user session data in an unsigned header to TiddlyWiki
32+
- Configuring TiddlyWiki to accept a special request header for trusted authentication
33+
34+
In this way, you can implement single sign-on (SSO) for your TiddlyWiki instance, which means an authorized user only needs to authenticate once to access the application.
35+
36+
To configure TiddlyWiki, you'll set its [ListenCommand](https://tiddlywiki.com/static/ListenCommand.html) to use the `authenticated-user-header` parameter. You'll configure Pomerium to forward the user's `email` claim in an unsigned header to TiddlyWiki.
37+
38+
### Before you start
3339

3440
<Tabs>
41+
<TabItem label="Core" value="Core">
3542

36-
<TabItem value="Core" label="Core">
43+
If you completed our [Quickstart guide](/docs/quickstart), you should have a working Pomerium project with the following YAML files:
3744

38-
To complete this guide, you need:
45+
- `config.yaml`
46+
- `docker-compose.yaml`
3947

40-
- [Docker](https://www.docker.com/)
41-
- [Docker Compose](https://docs.docker.com/compose/install/)
48+
If you haven't completed the Quickstart:
4249

43-
Refer to the [quick-start] guide for more information on how to run Pomerium Core with Docker and Docker Compose.
50+
- Install [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/install/)
51+
- Create a `config.yaml` file for your Pomerium configuration
52+
- Create a `docker-compose.yaml` file for your Docker configuration
4453

45-
### Configure Pomerium
54+
### Set up Pomerium
4655

4756
Add the following code in your `config.yaml` file:
4857

4958
```yaml title="config.yaml"
50-
jwt_claims_headers: email
59+
authenticate_service_url: https://authenticate.pomerium.app
60+
61+
jwt_claims_headers:
62+
X-Pomerium-Claim-Email: email
63+
5164
routes:
52-
- from: https://wiki.example.local
65+
- from: https://wiki.localhost.pomerium.io
5366
to: http://tiddlywiki:8080
67+
pass_identity_headers: true
5468
policy:
5569
- allow:
56-
or:
57-
- email:
58-
70+
and:
5971
- email:
60-
72+
# Replace with your email address
73+
6174
```
6275
63-
The [`jwt_claims_header`](/docs/reference/jwt-claim-headers) forwards the email associated with your IdP in the HTTP request header to TiddlyWiki.
76+
Let's review the configuration file:
6477
65-
In the policy above, the emails specified (`[email protected]` and `[email protected]`) will be forwarded to TiddlyWiki.
78+
- The [`jwt_claims_headers`](/docs/reference/jwt-claim-headers) setting will forward the user's email address in an unsigned, HTTP request header. The header follows the custom format specified in the file (in this case, `X-Pomerium-Claim-Email`).
79+
- The [`pass_identity_headers`](/docs/reference/routes/pass-identity-headers-per-route) setting tells Pomerium to forward all identity headers to the upstream application
80+
- The attached policy authorizes users with a matching email address to access TiddlyWiki. Pomerium will forward the address specified in the policy to TiddlyWiki as an unsigned identity header.
6681

67-
### Configure Docker-Compose
82+
### Set up Docker Compose services
6883

6984
Add the following code in your `docker-compose.yaml` file:
7085

71-
<DockerCompose />
86+
```yaml title="docker-compose.yaml"
87+
version: '3'
88+
services:
89+
pomerium:
90+
image: cr.pomerium.com/pomerium/pomerium:latest
91+
volumes:
92+
- ./config.yaml:/pomerium/config.yaml:ro
93+
ports:
94+
- 443:443
95+
96+
tiddlywiki_init:
97+
image: elasticdog/tiddlywiki:latest
98+
volumes:
99+
- ./wiki:/tiddlywiki
100+
command: ['mywiki', '--init', 'server']
101+
102+
tiddlywiki:
103+
image: elasticdog/tiddlywiki:latest
104+
ports:
105+
- 8080:8080
106+
volumes:
107+
- ./wiki:/tiddlywiki
108+
command:
109+
- mywiki
110+
- --listen
111+
- host=0.0.0.0
112+
- authenticated-user-header=X-Pomerium-Claim-Email
113+
depends_on:
114+
- tiddlywiki_init
115+
```
72116

73-
Here is what the code is doing:
117+
Before you test your services, make sure the value of `authenticated-user-header` matches the value of the custom header defined in `config.yaml`.
74118

75-
- `mywiki --listen host=0.0.0.0` starts the TiddlyWiki server, and maps ports `0.0.0.0` and `8080`
76-
- `authenticated-user-header=x-pomerium-claim-email` enables Tiddlywiki to receive the user's email address from Pomerium
77-
- `readers` and `writers` authorizes users to read and/or write to the TiddlyWiki server
78-
- `username` and `password` specify which user can access TiddlyWiki in a session; excluding these variables will result in a `401` error
119+
**Run Docker Compose:**
79120

80-
Run `docker-compose up`.
121+
```bash
122+
docker compose up
123+
```
81124

82125
</TabItem>
83-
<TabItem value="Enterprise" label="Enterprise">
126+
<TabItem label="Enterprise" value="Enterprise">
127+
128+
The Enterprise path to this guide requires a **Pomerium Enterprise** account and administrator access to an Enterprise Console instance.
129+
130+
It also assumes you are using [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/install/) to run your services.
131+
132+
## Set up TiddlyWiki
84133

85-
In your Console, create a policy:
134+
:::enterprise
86135

87-
1. Enter a **Name** (e.g. 'Allow Authenticated Users')
88-
2. Select **Builder**, **ADD ALLOW BLOCK**
89-
3. Select **+** and add an **OR** operator
90-
4. Under the **Criteria** dropdown, select **Email**
91-
5. In the **Value** field, enter **[email protected]**
92-
6. Select **+** and repeat step 5, but enter **[email protected]** instead.
136+
The Docker Compose example below contains the minimal configuration required to run TiddlyWiki. It does not include the configuration for Pomerium Enterprise.
137+
138+
For an example Pomerium Enterprise configuration using Docker Compose, see the [**Enterprise Quickstart**](/docs/deploy/enterprise/quickstart) guide.
139+
140+
:::
141+
142+
In your `docker-compose.yaml` file, add the TiddlyWiki configuration:
143+
144+
```yaml title="docker-compose.yaml"
145+
services:
146+
tiddlywiki_init:
147+
image: elasticdog/tiddlywiki:latest
148+
volumes:
149+
- ./wiki:/tiddlywiki
150+
command: ['mywiki', '--init', 'server']
151+
152+
tiddlywiki:
153+
image: elasticdog/tiddlywiki:latest
154+
ports:
155+
- 8080:8080
156+
volumes:
157+
- ./wiki:/tiddlywiki
158+
command:
159+
- mywiki
160+
- --listen
161+
- host=0.0.0.0
162+
- authenticated-user-header=X-Pomerium-Claim-Email
163+
depends_on:
164+
- tiddlywiki_init
165+
```
166+
167+
## Create a policy
168+
169+
1. In the **Builder** tab, select **ADD ALLOW BLOCK**
170+
1. Select the **AND** operator
171+
1. Select **Email** as the criteria and **Is** as the operator
172+
1. Enter the email address you will authenticate with as the value
93173

94174
Save your policy.
95175

96-
![Build TiddlyWiki policy](img/tiddlywiki/tiddlywiki-policy-builder.png)
176+
![Building a policy for TiddlyWiki in the Enterprise Console](./img/tiddlywiki/tiddlywiki-enterprise-policy.png)
97177

98-
Create a route:
178+
## Create a route
99179

100-
1. Enter a **Name** (e.g. 'TiddlyWiki')
101-
2. In the **From** field, enter the externally accessible URL (e.g. `https://wiki.localhost.pomerium.io`)
102-
3. In the **To** field, enter the host name (e.g. `http://tiddlywiki:8080`)
103-
4. Under **Policies**, select **Add Authenticated Users**
104-
5. Select **Pass Identity Headers**
180+
1. Add a new route and enter a **Name**
181+
1. In **From**, enter the externally accessible URL
182+
1. In **To**, enter the internally accessible URL
183+
1. Add the policy for this route (for example, `TiddlyWiki`)
184+
1. Enable **Pass Identity Headers**
105185

106186
Save your route.
107187

108-
![Create TiddlyWiki route](img/tiddlywiki/tiddlywiki-route.png)
188+
![Adding the TiddlyWiki route and attaching its policy in the Enterprise Console](./img/tiddlywiki/tiddlywiki-enterprise-route.png)
109189

110-
Configure your settings to send JWT claims headers to the upstream application:
190+
## Set identity headers
111191

112-
1. Under **Settings**, select **Proxy**
113-
2. In the **Header Key** field, enter **X-Pomerium-Claim**
114-
3. In the **JWT Claim** field, enter **Email**
192+
1. In the sidebar under **CONFIGURE**, select **Settings**
193+
1. Select the **Proxy** tab
194+
1. In **JWT Claim Headers**, enter the header and expected claim
115195

116196
Save your settings.
117197

118-
![Configure settings](img/tiddlywiki/tiddlywiki-settings.png)
198+
![Configuring JWT Claim Headers to forward the email claim as an identity header in the Enterprise Console](./img/tiddlywiki/enterprise-tiddlywiki-jwt-headers.png)
119199

120200
</TabItem>
121-
122201
</Tabs>
123202

124-
### Test your routes
203+
## Test TiddlyWiki
204+
205+
In your browser, navigate to your TiddlyWiki instance. Pomerium will prompt you to authenticate against its hosted identity provider.
125206

126-
Navigate to your TiddlyWiki instance (e.g. `https://wiki.example.local`) and log in using the following usernames:
207+
After successful authentication, Pomerium will redirect you to your TiddlyWiki instance:
127208

128-
- If you log in as `[email protected]`, you can only read tiddlers
129-
- If you log in as `[email protected]`, you can read and write tiddlers
130-
- If you log in as `[email protected]`, you will receive a 401 error
209+
![Adding a note in the TiddlyWiki dashboard](./img/tiddlywiki/tiddlywiki-first-note.png)
131210

132-
[quick-start]: /docs/quickstart
211+
Great job! You successfully secured TiddlyWiki behind Pomerium.

content/examples/tiddlywiki/README.md

-16
This file was deleted.

content/examples/tiddlywiki/config.yaml

-20
This file was deleted.

content/examples/tiddlywiki/docker-compose.yaml.md

-36
This file was deleted.

0 commit comments

Comments
 (0)