Skip to content

Commit fdcf11f

Browse files
committed
Add information about turnstile
1 parent 37dd4c0 commit fdcf11f

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ Quick Start Guide 👉 [https://docs.httpsms.com](https://docs.httpsms.com)
3737
- [Self Host Setup - Docker](#self-host-setup---docker)
3838
- [1. Setup Firebase](#1-setup-firebase)
3939
- [2. Setup SMTP Email service](#2-setup-smtp-email-service)
40-
- [3. Download the code](#3-download-the-code)
41-
- [4. Setup the environment variables](#4-setup-the-environment-variables)
42-
- [5. Build and Run](#5-build-and-run)
43-
- [6. Create the System User](#6-create-the-system-user)
44-
- [7. Build the Android App.](#7-build-the-android-app)
40+
- [3. Setup Cloudflare Turnstile](#3-setup-cloudflare-turnstile)
41+
- [4. Download the code](#4-download-the-code)
42+
- [5. Setup the environment variables](#5-setup-the-environment-variables)
43+
- [6. Build and Run](#6-build-and-run)
44+
- [7. Create the System User](#7-create-the-system-user)
45+
- [8. Build the Android App.](#8-build-the-android-app)
4546
- [License](#license)
4647

4748
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -164,15 +165,23 @@ const firebaseConfig = {
164165
The httpSMS application uses [SMTP](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol) to send emails to users e.g. when your Android phone has been offline for a long period of time.
165166
You can use a service like [mailtrap](https://mailtrap.io/) to create an SMTP server for development purposes.
166167

167-
### 3. Download the code
168+
### 3. Setup Cloudflare Turnstile
169+
170+
The message search route (`/v1/messages/search`) is protected by a [Cloudflare Turnstile](https://developers.cloudflare.com/turnstile/get-started/) captcha to prevent abuse. You need to set up a Turnstile widget for the search messages feature to work.
171+
172+
1. Go to the [Cloudflare dashboard](https://dash.cloudflare.com/) and navigate to **Turnstile**.
173+
2. Add a new site and configure it for your self-hosted domain (e.g., `localhost` for local development).
174+
3. Note down the **Site Key** and **Secret Key** — you will need them for the frontend and backend environment variables respectively.
175+
176+
### 4. Download the code
168177

169178
Clone the httpSMS GitHub repository
170179

171180
```bash
172181
git clone https://github.com/NdoleStudio/httpsms.git
173182
```
174183

175-
### 4. Setup the environment variables
184+
### 5. Setup the environment variables
176185

177186
- Copy the `.env.docker` file in the `web` directory into `.env`
178187

@@ -190,6 +199,9 @@ FIREBASE_STORAGE_BUCKET=
190199
FIREBASE_MESSAGING_SENDER_ID=
191200
FIREBASE_APP_ID=
192201
FIREBASE_MEASUREMENT_ID=
202+
203+
# Cloudflare Turnstile site key from step 3
204+
CLOUDFLARE_TURNSTILE_SITE_KEY=
193205
```
194206

195207
- Copy the `.env.docker` file in the `api` directory into `.env`
@@ -198,7 +210,7 @@ FIREBASE_MEASUREMENT_ID=
198210
cp api/.env.docker api/.env
199211
```
200212

201-
- Update the environment variables in the `.env` file in the `api` directory with your firebase service account credentials and SMTP server details.
213+
- Update the environment variables in the `.env` file in the `api` directory with your firebase service account credentials, SMTP server details, and Cloudflare Turnstile secret key.
202214

203215
```dotenv
204216
# SMTP email server settings
@@ -212,11 +224,14 @@ FIREBASE_CREDENTIALS=
212224
213225
# This is the `projectId` from your firebase web config
214226
GCP_PROJECT_ID=
227+
228+
# Cloudflare Turnstile secret key from step 3
229+
CLOUDFLARE_TURNSTILE_SECRET_KEY=
215230
```
216231

217232
- Don't bother about the `EVENTS_QUEUE_USER_API_KEY` and `EVENTS_QUEUE_USER_ID` settings. We will set that up later.
218233

219-
### 5. Build and Run
234+
### 6. Build and Run
220235

221236
- Build and run the API, the web UI, database and cache using the `docker-compose.yml` file. It takes a while for build and download all the docker images.
222237
When it's finished, you'll be able to access the web UI at http://localhost:3000 and the API at http://localhost:8000
@@ -225,7 +240,7 @@ GCP_PROJECT_ID=
225240
docker compose up --build
226241
```
227242

228-
### 6. Create the System User
243+
### 7. Create the System User
229244

230245
- The application uses the concept of a system user to process events async. You should manually create this user in `users` table in your database. Make sure you use the same `id` and `api_key` as the `EVENTS_QUEUE_USER_ID`, and `EVENTS_QUEUE_USER_API_KEY` in your `.env` file.
231246

@@ -236,7 +251,7 @@ docker compose up --build
236251
> [!IMPORTANT]
237252
> Restart your API docker container after modifying `EVENTS_QUEUE_USER_ID`, and `EVENTS_QUEUE_USER_API_KEY` in your `.env` file so that the httpSMS API can pick up the changes.
238253
239-
### 7. Build the Android App.
254+
### 8. Build the Android App.
240255

241256
- Before building the Android app in [Android Studio](https://developer.android.com/studio), you need to replace the `google-services.json` file in the `android/app` directory with the file which you got from step 1. You need to do this for the firebase FCM messages to work properly.
242257

api/.env.docker

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@ PUSHER_APP_ID=
5858
PUSHER_KEY=
5959
PUSHER_SECRET=
6060
PUSHER_CLUSTER=
61+
62+
# Cloudflare Turnstile secret key for validating captcha tokens on the /v1/messages/search route
63+
# Get your secret key at https://developers.cloudflare.com/turnstile/get-started/
64+
CLOUDFLARE_TURNSTILE_SECRET_KEY=

web/.env.docker

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ FIREBASE_STORAGE_BUCKET=httpsms-docker.appspot.com
1515
FIREBASE_MESSAGING_SENDER_ID=668063041624
1616
FIREBASE_APP_ID=668063041624:web:29b9e3b7027965ba08a22d
1717
FIREBASE_MEASUREMENT_ID=G-18VRYL22PZ
18+
19+
# Cloudflare Turnstile site key for captcha on the search messages page
20+
# Get your site key at https://developers.cloudflare.com/turnstile/get-started/
21+
CLOUDFLARE_TURNSTILE_SITE_KEY=

0 commit comments

Comments
 (0)