Skip to content

Commit 226ef21

Browse files
authored
Merge pull request #46 from CodeShellDev/main
Update Dev
2 parents fcfc497 + ea8e9f4 commit 226ef21

File tree

1 file changed

+77
-49
lines changed

1 file changed

+77
-49
lines changed

README.md

Lines changed: 77 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,48 @@
11
<img align="center" width="1048" height="512" alt="Secure Proxy for Signal REST API" src="https://github.com/CodeShellDev/secured-signal-api/raw/refs/heads/main/logo/landscape" />
22

3-
<h5 align="center">Secure Proxy for <a href="https://github.com/bbernhard/signal-cli-rest-api">Signal Messenger REST API</a></h5>
3+
<h3 align="center">Secure Proxy for <a href="https://github.com/bbernhard/signal-cli-rest-api">Signal Messenger REST API</a></h3>
4+
5+
<p align="center">
6+
adding token-based authentication,
7+
endpoint restrictions, placeholders, and flexible configuration.
8+
</p>
9+
10+
<p align="center">
11+
🔒 Secure · ⭐️ Configurable · 🚀 Easy to Deploy with Docker
12+
</p>
13+
14+
<div align="center">
15+
<a href="https://github.com/codeshelldev/secured-signal-api/releases">
16+
<img src="https://img.shields.io/github/v/release/codeshelldev/secured-signal-api?sort=semver&logo=github" alt="GitHub release">
17+
</a>
18+
<a href="https://github.com/codeshelldev/secured-signal-api/pkgs/container/secured-signal-api">
19+
<img src="https://ghcr-badge.egpl.dev/codeshelldev/secured-signal-api/size?color=%2344cc11&tag=latest&label=image+size&trim=" alt="GHCR pulls">
20+
</a>
21+
<a href="./LICENSE">
22+
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT">
23+
</a>
24+
<a href="https://github.com/codeshelldev/secured-signal-api/stargazers">
25+
<img src="https://img.shields.io/github/stars/codeshelldev/secured-signal-api?style=social" alt="GitHub stars">
26+
</a>
27+
</div>
28+
29+
## Contents
30+
31+
- [Getting Started](#getting-started)
32+
- [Setup](#setup)
33+
- [Usage](#usage)
34+
- [Best Practices](#security-best-practices)
35+
- [Configuration](#configuration)
36+
- [Endpoints](#endpoints)
37+
- [Variables](#variables)
38+
- [Contributing](#contributing)
39+
- [Support](#support)
40+
- [License](#license)
441

542
## Getting Started
643

44+
> **Prerequisites**: You need Docker and Docker Compose installed.
45+
746
Get the latest version of the `docker-compose.yaml` file:
847

948
```yaml
@@ -45,11 +84,10 @@ networks:
4584
And add secure Token(s) to `api.tokens`. See [API TOKENs](#api-tokens).
4685

4786
> [!IMPORTANT]
48-
> This Documentation will be using `sec-signal-api:8880` as the service host,
49-
> this **is just for simplicty**, instead use your containers or hosts IP + Port.
50-
> Or a hostname if applicable. See [Reverse Proxy](#reverse-proxy)
87+
> In this documentation, we use `sec-signal-api:8880` as the host for simplicity.
88+
> Replace it with your actual container/host IP, port, or hostname.
5189

52-
### Reverse proxy
90+
### Reverse Proxy
5391

5492
Take a look at the [traefik](https://github.com/traefik/traefik) implementation:
5593

@@ -60,7 +98,8 @@ services:
6098
container_name: secured-signal
6199
environment:
62100
API__URL: http://signal-api:8080
63-
SETTINGS__VARIABLES__RECIPIENTS: ["+123400002", "+123400003", "+123400004"]
101+
SETTINGS__VARIABLES__RECIPIENTS:
102+
["+123400002", "+123400003", "+123400004"]
64103
SETTINGS__VARIABLES__NUMBER: "+123400001"
65104
API__TOKENS: [LOOOOOONG_STRING]
66105
labels:
@@ -87,56 +126,29 @@ networks:
87126
88127
## Setup
89128
90-
Before you can send messages via Secured Signal API you must first setup [Signal rAPI](https://github.com/bbernhard/signal-cli-rest-api/blob/master/doc/EXAMPLES.md)
91-
92-
To be able to use the API you have to either:
129+
Before you can send messages via Secured Signal API you must first set up [Signal rAPI](https://github.com/bbernhard/signal-cli-rest-api/blob/master/doc/EXAMPLES.md)
93130
94-
- **register with your Signal Account**
131+
1. **Register** or **link** a Signal account with `signal-cli-rest-api`
95132

96-
OR
133+
2. Deploy `secured-signal-api` with at least one API token
97134

98-
- **link Signal API to an already registered Signal Device**
135+
3. Confirm you can send a test message (see [Usage](#usage))
99136

100137
> [!TIP]
101-
> It is advised to do Setup directly with Signal rAPI
102-
> if you try to Setup with Secured Signal API you will be blocked from doing so. See [Blocked Endpoints](#blocked-endpoints).
138+
> Run setup directly with Signal rAPI.
139+
> Setup requests via Secured Signal API are blocked. See [Blocked Endpoints](#blocked-endpoints).
103140

104141
## Usage
105142

106143
Secured Signal API provides 3 Ways to Authenticate
107144

108-
### Bearer
109-
110-
To Authenticate add `Authorization: Bearer API_TOKEN` to your request Headers
111-
112-
### Basic Auth
113-
114-
To use Basic Auth as Authorization Method add `Authorization: Basic BASE64_STRING` to your Headers
115-
116-
User is `api` (LOWERCASE)
117-
118-
Formatting for `BASE64_STRING` = `user:API_TOKEN`.
119-
120-
example:
121-
122-
```bash
123-
echo "api:API_TOKEN" | base64
124-
```
125-
126-
=> `YXBpOkFQSV9LRVkK`
127-
128-
### Query Auth
129-
130-
If you are working with a limited Application you may **not** be able to modify Headers or the Request Body
131-
in this case you can use **Query Auth**.
132-
133-
Here is a simple example:
134-
135-
```bash
136-
curl -X POST http://sec-signal-api:8880/v2/send?@authorization=API_TOKEN
137-
```
145+
### Auth
138146

139-
Notice the `@` infront of `authorization`. See [KeyValue Pair Injection](#keyvalue-pair-injection).
147+
| Method | Example |
148+
| :---------- | :--------------------------------------------------------- |
149+
| Bearer Auth | Add `Authorization: Bearer API_TOKEN` to headers |
150+
| Basic Auth | Add `Authorization: Basic BASE64_STRING` (`api:API_TOKEN`) |
151+
| Query Auth | Append `@authorization=API_TOKEN` to request URL |
140152

141153
### Example
142154

@@ -186,6 +198,13 @@ you have to add `@` in front of any KeyValue Pair assignment.
186198
187199
Supported types include **strings**, **ints** and **arrays**. See [Formatting](#string-to-type).
188200
201+
## Security: Best Practices
202+
203+
- Always use API tokens in production
204+
- Run behind a TLS-enabled [Reverse Proxy](#reverse-proxy) (Traefik, Nginx, Caddy)
205+
- Be cautious when overriding Blocked Endpoints
206+
- Use per-token overrides to enforce least privilege
207+
189208
## Configuration
190209
191210
There are multiple ways to configure Secured Signal API, you can optionally use `config.yml` aswell as Environment Variables to override the config.
@@ -271,8 +290,7 @@ If you are using Environment Variables as an example you won't be able to specif
271290
| array(str) | [a,b,c] |
272291

273292
> [!NOTE]
274-
> If you have a string that should not be turned into any other type, then you will need to escape all Type Denotations, `[]` or `{}` (also `-`) with a `\` **Backslash**.
275-
> **Double Backslashes** do exist but you could just leave them out completly.
293+
> If you have a string that should not be turned into any other type, then you will need to escape all Type Denotations, `[]` or `{}` (also `-`) with a `\` **Backslash** (or Double Backslash).
276294
> An **Odd** number of **Backslashes** **escape** the character in front of them and an **Even** number leave the character **as-is**.
277295

278296
### API Token(s)
@@ -299,7 +317,7 @@ Since Secured Signal API is just a Proxy you can use all of the [Signal REST API
299317
| :-------------------- | ------------------ |
300318
| **/v1/about** | **/v1/unregister** |
301319
| **/v1/configuration** | **/v1/qrcodelink** |
302-
| **/v1/devives** | **/v1/contacts** |
320+
| **/v1/devices** | **/v1/contacts** |
303321
| **/v1/register** | **/v1/accounts** |
304322

305323
These Endpoints are blocked by default due to Security Risks.
@@ -345,7 +363,10 @@ settings:
345363

346364
### Message Aliases
347365

348-
To improve compatibility with other services Secured Signal API provides aliases for the `message` attribute by default:
366+
To improve compatibility with other services Secured Signal API provides **Message Aliases** for the `message` attribute.
367+
368+
<details>
369+
<summary><strong>Default Message Aliases</strong></summary>
349370

350371
| Alias | Score | Alias | Score |
351372
| ------------ | ----- | ---------------- | ----- |
@@ -357,6 +378,8 @@ To improve compatibility with other services Secured Signal API provides aliases
357378
| details | 14 | body | 2 |
358379
| data.message | 10 | data | 1 |
359380

381+
</details>
382+
360383
Secured Signal API will pick the best scoring Message Alias (if available) to extract the correct message from the Request Body.
361384

362385
Message Aliases can be added by setting `messageAliases` in your config:
@@ -379,6 +402,9 @@ To change the Port which Secured Signal API uses, you need to set `server.port`
379402

380403
To change the Log Level set `logLevel` to: (default: `info`)
381404

405+
<details>
406+
<summary>Log Levels</summary>
407+
382408
| Level |
383409
| ------- |
384410
| `info` |
@@ -388,6 +414,8 @@ To change the Log Level set `logLevel` to: (default: `info`)
388414
| `fatal` |
389415
| `dev` |
390416

417+
</details>
418+
391419
## Contributing
392420

393421
Found a bug? Want to change or add something?

0 commit comments

Comments
 (0)