Skip to content

Commit 5d666ef

Browse files
committed
update docs and readme
1 parent 71a630e commit 5d666ef

36 files changed

+873
-131
lines changed

.github/templates/README.template.md

Lines changed: 8 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ endpoint restrictions, placeholders, flexible configuration
4646

4747
## Contents
4848

49+
- [Documentation](https://codeshelldev.github.io/secured-signal-api/docs)
50+
4951
- [Getting Started](#getting-started)
5052
- [Setup](#setup)
5153
- [Usage](#usage)
52-
- [Best Practices](#best-practices)
5354
- [Configuration](#configuration)
5455
- [Endpoints](#endpoints)
5556
- [Variables](#variables)
@@ -67,7 +68,7 @@ endpoint restrictions, placeholders, flexible configuration
6768
Get the latest version of the `docker-compose.yaml` file:
6869

6970
```yaml
70-
{{{ #://docker-compose.yaml }}}
71+
{{{ #://docs-src/getting-started/examples/docker-compose.yaml }}}
7172
```
7273

7374
And add secure Token(s) to `api.tokens`. See [API TOKENs](#api-tokens).
@@ -76,32 +77,6 @@ And add secure Token(s) to `api.tokens`. See [API TOKENs](#api-tokens).
7677
> In this documentation, we use `sec-signal-api:8880` as the host for simplicity.
7778
> Replace it with your actual container/host IP, port, or hostname.
7879
79-
### Reverse Proxy
80-
81-
#### Traefik
82-
83-
Take a look at the [traefik](https://github.com/traefik/traefik) implementation:
84-
85-
```yaml
86-
{{{ #://examples/reverse-proxy/traefik/traefik.docker-compose.yaml }}}
87-
```
88-
89-
#### NGINX Proxy
90-
91-
This is the [NGINX](https://github.com/nginx/nginx) `docker-compose.yaml` file:
92-
93-
```yaml
94-
{{{ #://examples/reverse-proxy/nginx/nginx.docker-compose.yaml }}}
95-
```
96-
97-
Create a `nginx.conf` file in the `docker-compose.yaml` folder and mount it to `etc/nginx/conf.d/default.conf`:
98-
99-
```conf
100-
{{{ #://examples/reverse-proxy/nginx/nginx.conf }}}
101-
```
102-
103-
Lastly add your `cert.key` and `cert.crt` into your `certs/` folder and mount it to `/etc/nginx/ssl`.
104-
10580
## Setup
10681

10782
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)
@@ -175,14 +150,7 @@ In some cases you may not be able to access / modify the Request Body, in that c
175150
In order to differentiate Injection Queries and _regular_ Queries
176151
you have to add `@` in front of any KeyValue Pair assignment.
177152

178-
Supported types include **strings**, **ints**, **arrays** and **json dictionaries**. See [Formatting](#string-to-type).
179-
180-
## Best Practices
181-
182-
- Always use API tokens in production
183-
- Run behind a TLS-enabled [Reverse Proxy](#reverse-proxy) (Traefik, Nginx, Caddy)
184-
- Be cautious when overriding Blocked Endpoints
185-
- Use per-token overrides to enforce least privilege
153+
Supported types include **strings**, **ints**, **arrays** and **json dictionaries**. See [Formatting](https://codeshelldev.github.io/secured-signal-api/docs/usage/formatting).
186154

187155
## Configuration
188156

@@ -197,7 +165,7 @@ To change the internal config file location set `CONFIG_PATH` in your **Environm
197165
This example config shows all of the individual settings that can be applied:
198166

199167
```yaml
200-
{{{ #://examples/config.yml }}}
168+
{{{ #://docs-src/configuration/examples/config.yml }}}
201169
```
202170

203171
#### Token Configs
@@ -209,44 +177,9 @@ This way you can permission tokens by further restricting or adding [Endpoints](
209177
Here is an example:
210178

211179
```yaml
212-
{{{ #://examples/token.yml }}}
180+
{{{ #://docs-src/configuration/examples/token.yml }}}
213181
```
214182

215-
### Environment
216-
217-
Suppose you want to set a new [Placeholder](#placeholders) `NUMBER` in your Environment...
218-
219-
```yaml
220-
environment:
221-
SETTINGS__VARIABLES__NUMBER: "+123400001"
222-
```
223-
224-
This would internally be converted into `settings.variables.number` matching the config formatting.
225-
226-
> [!IMPORTANT]
227-
> Underscores `_` are removed during Conversion, Double Underscores `__` on the other hand convert the Variable into a nested Object (`__` replaced by `.`)
228-
229-
### String To Type
230-
231-
> [!TIP]
232-
> This formatting applies to almost every situation where the only (allowed) Input Type is a string and other Output Types are needed.
233-
234-
If you are using Environment Variables as an example you won't be able to specify an Array or a Dictionary of items, in that case you can provide a specifically formatted string which will be translated into the correct type...
235-
236-
| type | example |
237-
| :--------- | :---------------- |
238-
| string | abc |
239-
| string | +123 |
240-
| int | 123 |
241-
| int | -123 |
242-
| json | {"a":"b","c":"d"} |
243-
| array(int) | [1,2,3] |
244-
| array(str) | [a,b,c] |
245-
246-
> [!NOTE]
247-
> 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).
248-
> An **Odd** number of **Backslashes** **escape** the character in front of them and an **Even** number leave the character **as-is**.
249-
250183
### Templating
251184

252185
Secured Signal API uses Golang's [Standard Templating Library](https://pkg.go.dev/text/template).
@@ -260,35 +193,10 @@ Go's templating library is used in the following features:
260193
This makes advanced [Message Templates](#message-templates) like this one possible:
261194

262195
```yaml
263-
settings:
264-
messageTemplate: |
265-
{{- $greeting := "Hello" -}}
266-
{{ $greeting }}, {{ @name }}!
267-
{{ if @age -}}
268-
You are {{ @age }} years old.
269-
{{- else -}}
270-
Age unknown.
271-
{{- end }}
272-
Your friends:
273-
{{- range @friends }}
274-
- {{ . }}
275-
{{- else }}
276-
You have no friends.
277-
{{- end }}
278-
Profile details:
279-
{{- range $key, $value := @profile }}
280-
- {{ $key }}: {{ $value }}
281-
{{- end }}
282-
{{ define "footer" -}}
283-
This is the footer for {{ @name }}.
284-
{{- end }}
285-
{{ template "footer" . -}}
286-
------------------------------------
287-
Content-Type: {{ #Content_Type }}
288-
Redacted Auth Header: {{ #Authorization }}
196+
{{{ #://docs-src/configuration/examples/message-template.yml }}}
289197
```
290198

291-
### API Token(s)
199+
### API Tokens
292200

293201
During Authentication Secured Signal API will try to match the given Token against the list of Tokens inside of these Variables.
294202

@@ -409,28 +317,6 @@ settings:
409317

410318
Use `@` for aliasing Body Keys and `.` for aliasing Variables.
411319

412-
### Port
413-
414-
To change the Port which Secured Signal API uses, you need to set `service.port` in your config. (default: `8880`)
415-
416-
### Log Level
417-
418-
To change the Log Level set `logLevel` to: (default: `info`)
419-
420-
<details>
421-
<summary>Log Levels</summary>
422-
423-
| Level |
424-
| ------- |
425-
| `info` |
426-
| `debug` |
427-
| `warn` |
428-
| `error` |
429-
| `fatal` |
430-
| `dev` |
431-
432-
</details>
433-
434320
## Contributing
435321

436322
Found a bug? Want to change or add something?
File renamed without changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
sidebar_position: 4
3+
title: Best Practices
4+
---
5+
6+
# Best Practices
7+
8+
Here are some common best practices for running **Secured Signal API**, but these generally apply for any service.
9+
10+
## Usage
11+
12+
- Create **seperate configs** for each service
13+
- Use **Placeholders** extensively _(they are your friends)_
14+
- Always keep your stack **up-to-date** _(this is why we have docker)_
15+
16+
## Security
17+
18+
- Always use **API tokens** in production
19+
- Run behind a **tls-enabled** [Reverse Proxy](../reverse-proxy/overview)
20+
- Be cautious when overriding **Blocked Endpoints**
21+
- Use per-token overrides to **enforce least privilege**
22+
- Always allow the least possible access points

docs/configuration/_category_.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Configuration",
3+
"position": 5
4+
}

docs/configuration/api-tokens.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: API Tokens
3+
---
4+
5+
# API Tokens
6+
7+
> [!IMPORTANT]
8+
> Using API Tokens is highly **recommended**, but not mandatory.
9+
> Some important Security Features won't be available (like default Blocked Endpoints).
10+
11+
Defined API Tokens for accessing **Secured Signal API** endpoints.
12+
13+
```yaml
14+
api:
15+
tokens: [token1, token2, token3]
16+
```
17+
18+
> [!NOTE]
19+
> Blocked Endpoints can be reactivated by manually configuring them

docs/configuration/data-aliases.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Data Aliases
3+
---
4+
5+
# Data Aliases
6+
7+
A Compatibility Layer for **Secured Signal API**.
8+
9+
To improve compatibility with other services Secured Signal API provides **Data Aliases** and even a built-in `message` Alias.
10+
11+
<details>
12+
<summary><strong>Default `message` Aliases</strong></summary>
13+
14+
| Alias | Score | Alias | Score |
15+
| ------------ | ----- | ---------------- | ----- |
16+
| msg | 100 | data.content | 9 |
17+
| content | 99 | data.description | 8 |
18+
| description | 98 | data.text | 7 |
19+
| text | 20 | data.summary | 6 |
20+
| summary | 15 | data.details | 5 |
21+
| details | 14 | body | 2 |
22+
| data.message | 10 | data | 1 |
23+
24+
</details>
25+
26+
Secured Signal API will pick the highest scoring **Data Alias** (if available) to set the key to the correct value **using the request body**.
27+
28+
Data Aliases can be added by setting `dataAliases` in your config:
29+
30+
```yaml
31+
settings:
32+
dataAliases:
33+
"@message":
34+
[
35+
{ alias: "msg", score: 80 },
36+
{ alias: "data.message", score: 79 },
37+
{ alias: "array[0].message", score: 78 },
38+
]
39+
".NUMBER": [{ alias: "phone_number", score: 100 }]
40+
```
41+
42+
> [!IMPORTANT]
43+
> Use `@` for aliasing Body Keys and `.` for aliasing Variables.

docs/configuration/endpoints.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: Endpoints
3+
---
4+
5+
# Endpoints
6+
7+
Restrict access to your **Secured Signal API**.
8+
9+
## Default
10+
11+
Secured Signal API is just a Proxy, which means any and **all** of the **Signal CLI REST API** **endpoints are available**,
12+
but by default the following endpoints are **blocked**, because of Security Concerns:
13+
14+
| Endpoint | |
15+
| :-------------------- | ------------------ |
16+
| **/v1/about** | **/v1/unregister** |
17+
| **/v1/configuration** | **/v1/qrcodelink** |
18+
| **/v1/devices** | **/v1/contacts** |
19+
| **/v1/register** | **/v1/accounts** |
20+
21+
## Customize
22+
23+
> [!NOTE]
24+
> Matching works by checking if the requested Endpoints starts with a Blocked or an Allowed Endpoint
25+
26+
You can modify Blocked Endpoints by configuring `blockedEndpoints` in your config:
27+
28+
```yaml
29+
settings:
30+
blockedEndpoints: [/v1/register, /v1/unregister, /v1/qrcodelink, /v1/contacts]
31+
```
32+
33+
You can also override Blocked Endpoints by adding Allowed Endpoints to `allowedEndpoints`.
34+
35+
```yaml
36+
settings:
37+
allowedEndpoints: [/v2/send]
38+
```
39+
40+
| Config (Allow) | (Block) | Result | | | |
41+
| :------------------------------- | :---------------------------------- | :--------: | --- | :---------------: | --- |
42+
| `allowedEndpoints: ["/v2/send"]` | `unset` | **all** | 🛑 | **`/v2/send`** | ✅ |
43+
| `unset` | `blockedEndpoints: ["/v1/receive"]` | **all** | ✅ | **`/v1/receive`** | 🛑 |
44+
| `blockedEndpoints: ["/v2"]` | `allowedEndpoints: ["/v2/send"]` | **`/v2*`** | 🛑 | **`/v2/send`** | ✅ |
File renamed without changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
settings:
2+
messageTemplate: |
3+
{{- $greeting := "Hello" -}}
4+
{{ $greeting }}, {{ @name }}!
5+
{{ if @age -}}
6+
You are {{ @age }} years old.
7+
{{- else -}}
8+
Age unknown.
9+
{{- end }}
10+
Your friends:
11+
{{- range @friends }}
12+
- {{ . }}
13+
{{- else }}
14+
You have no friends.
15+
{{- end }}
16+
Profile details:
17+
{{- range $key, $value := @profile }}
18+
- {{ $key }}: {{ $value }}
19+
{{- end }}
20+
{{ define "footer" -}}
21+
This is the footer for {{ @name }}.
22+
{{- end }}
23+
{{ template "footer" . -}}
24+
------------------------------------
25+
Content-Type: {{ #Content_Type }}
26+
Redacted Auth Header: {{ #Authorization }}
File renamed without changes.

0 commit comments

Comments
 (0)