Skip to content

Commit 08e09af

Browse files
Update README.md
1 parent 5d666ef commit 08e09af

File tree

1 file changed

+8
-275
lines changed

1 file changed

+8
-275
lines changed

README.md

Lines changed: 8 additions & 275 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,39 +68,7 @@ endpoint restrictions, placeholders, flexible configuration
6768
Get the latest version of the `docker-compose.yaml` file:
6869

6970
```yaml
70-
services:
71-
signal-api:
72-
image: bbernhard/signal-cli-rest-api:latest
73-
container_name: signal-api
74-
environment:
75-
- MODE=normal
76-
volumes:
77-
- ./data:/home/.local/share/signal-cli
78-
restart: unless-stopped
79-
networks:
80-
backend:
81-
aliases:
82-
- signal-api
83-
84-
secured-signal:
85-
image: ghcr.io/codeshelldev/secured-signal-api:latest
86-
container_name: secured-signal
87-
environment:
88-
API__URL: http://signal-api:8080
89-
SETTINGS__VARIABLES__RECIPIENTS:
90-
'[+123400002, +123400003, +123400004]'
91-
SETTINGS__VARIABLES__NUMBER: "+123400001"
92-
API__TOKENS: '[LOOOOOONG_STRING]'
93-
ports:
94-
- "8880:8880"
95-
restart: unless-stopped
96-
networks:
97-
backend:
98-
aliases:
99-
- secured-signal-api
100-
101-
networks:
102-
backend:
71+
file not found: /home/runner/work/secured-signal-api/secured-signal-api/docs-src/getting-started/examples/docker-compose.yaml
10372
```
10473
10574
And add secure Token(s) to `api.tokens`. See [API TOKENs](#api-tokens).
@@ -108,120 +77,6 @@ And add secure Token(s) to `api.tokens`. See [API TOKENs](#api-tokens).
10877
> In this documentation, we use `sec-signal-api:8880` as the host for simplicity.
10978
> Replace it with your actual container/host IP, port, or hostname.
11079

111-
### Reverse Proxy
112-
113-
#### Traefik
114-
115-
Take a look at the [traefik](https://github.com/traefik/traefik) implementation:
116-
117-
```yaml
118-
services:
119-
secured-signal:
120-
image: ghcr.io/codeshelldev/secured-signal-api:latest
121-
container_name: secured-signal
122-
environment:
123-
API__URL: http://signal-api:8080
124-
SETTINGS__VARIABLES__RECIPIENTS:
125-
'[+123400002,+123400003,+123400004]'
126-
SETTINGS__VARIABLES__NUMBER: "+123400001"
127-
API__TOKENS: '[LOOOOOONG_STRING]'
128-
labels:
129-
- traefik.enable=true
130-
- traefik.http.routers.signal-api.rule=Host(`signal-api.mydomain.com`)
131-
- traefik.http.routers.signal-api.entrypoints=websecure
132-
- traefik.http.routers.signal-api.tls=true
133-
- traefik.http.routers.signal-api.tls.certresolver=cloudflare
134-
- traefik.http.routers.signal-api.service=signal-api-svc
135-
- traefik.http.services.signal-api-svc.loadbalancer.server.port=8880
136-
- traefik.docker.network=proxy
137-
restart: unless-stopped
138-
networks:
139-
proxy:
140-
backend:
141-
aliases:
142-
- secured-signal-api
143-
144-
networks:
145-
backend:
146-
proxy:
147-
external: true
148-
```
149-
150-
#### NGINX Proxy
151-
152-
This is the [NGINX](https://github.com/nginx/nginx) `docker-compose.yaml` file:
153-
154-
```yaml
155-
services:
156-
secured-signal:
157-
image: ghcr.io/codeshelldev/secured-signal-api:latest
158-
container_name: secured-signal-api
159-
environment:
160-
API__URL: http://signal-api:8080
161-
SETTINGS__VARIABLES__RECIPIENTS: "[+123400002,+123400003,+123400004]"
162-
SETTINGS__VARIABLES__NUMBER: "+123400001"
163-
API__TOKENS: "[LOOOOOONG_STRING]"
164-
restart: unless-stopped
165-
networks:
166-
backend:
167-
aliases:
168-
- secured-signal-api
169-
170-
nginx:
171-
image: nginx:latest
172-
container_name: secured-signal-proxy
173-
volumes:
174-
- ./nginx.conf:/etc/nginx/conf.d/default.conf
175-
# Load SSL certificates: cert.key, cert.crt
176-
- ./certs:/etc/nginx/ssl
177-
ports:
178-
- "443:443"
179-
- "80:80"
180-
restart: unless-stopped
181-
networks:
182-
frontend:
183-
backend:
184-
185-
networks:
186-
backend:
187-
frontend:
188-
```
189-
190-
Create a `nginx.conf` file in the `docker-compose.yaml` folder and mount it to `etc/nginx/conf.d/default.conf`:
191-
192-
```conf
193-
server {
194-
# Allow SSL on Port 443
195-
listen 443 ssl;
196-
197-
# Add allowed hostnames which nginx should respond to
198-
# `_` for any
199-
server_name localhost;
200-
201-
ssl_certificate /etc/nginx/ssl/cert.crt;
202-
ssl_certificate_key /etc/nginx/ssl/cert.key;
203-
204-
location / {
205-
# Use whatever network alias you set in the docker-compose file
206-
proxy_pass http://secured-signal-api:8880;
207-
proxy_set_header Host $host;
208-
proxy_set_header X-Real-IP $remote_addr;
209-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
210-
proxy_set_header X-Forwarded-Host $host;
211-
proxy_set_header X-Fowarded-Proto $scheme;
212-
}
213-
}
214-
215-
# Redirect HTTP to HTTPs
216-
server {
217-
listen 80;
218-
server_name localhost;
219-
return 301 https://$host$request_uri;
220-
}
221-
```
222-
223-
Lastly add your `cert.key` and `cert.crt` into your `certs/` folder and mount it to `/etc/nginx/ssl`.
224-
22580
## Setup
22681

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

298-
Supported types include **strings**, **ints**, **arrays** and **json dictionaries**. See [Formatting](#string-to-type).
299-
300-
## Best Practices
301-
302-
- Always use API tokens in production
303-
- Run behind a TLS-enabled [Reverse Proxy](#reverse-proxy) (Traefik, Nginx, Caddy)
304-
- Be cautious when overriding Blocked Endpoints
305-
- 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).
306154

307155
## Configuration
308156

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

319167
```yaml
320-
# Example Config (all configurations shown)
321-
service:
322-
port: 8880
323-
324-
api:
325-
url: http://signal-api:8080
326-
tokens: [token1, token2]
327-
328-
logLevel: info
329-
330-
settings:
331-
messageTemplate: |
332-
You've got a Notification:
333-
{{@message}}
334-
At {{@data.timestamp}} on {{@data.date}}.
335-
Send using {{.NUMBER}}.
336-
337-
variables:
338-
number: "+123400001"
339-
recipients: ["+123400002", "group.id", "user.id"]
340-
341-
dataAliases:
342-
"@message": [{ alias: "msg", score: 100 }]
343-
344-
blockedEndpoints:
345-
- /v1/about
346-
allowedEndpoints:
347-
- /v2/send
168+
file not found: /home/runner/work/secured-signal-api/secured-signal-api/docs-src/configuration/examples/config.yml
348169
```
349170

350171
#### Token Configs
@@ -356,50 +177,9 @@ This way you can permission tokens by further restricting or adding [Endpoints](
356177
Here is an example:
357178

358179
```yaml
359-
tokens: [LOOOONG_STRING]
360-
361-
overrides:
362-
variables: # Disable Placeholder
363-
blockedEndpoints: # Disable Sending
364-
- /v2/send
365-
dataAliases: # Disable Aliases
366-
```
367-
368-
### Environment
369-
370-
Suppose you want to set a new [Placeholder](#placeholders) `NUMBER` in your Environment...
371-
372-
```yaml
373-
environment:
374-
SETTINGS__VARIABLES__NUMBER: "+123400001"
180+
file not found: /home/runner/work/secured-signal-api/secured-signal-api/docs-src/configuration/examples/token.yml
375181
```
376182

377-
This would internally be converted into `settings.variables.number` matching the config formatting.
378-
379-
> [!IMPORTANT]
380-
> Underscores `_` are removed during Conversion, Double Underscores `__` on the other hand convert the Variable into a nested Object (`__` replaced by `.`)
381-
382-
### String To Type
383-
384-
> [!TIP]
385-
> This formatting applies to almost every situation where the only (allowed) Input Type is a string and other Output Types are needed.
386-
387-
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...
388-
389-
| type | example |
390-
| :--------- | :---------------- |
391-
| string | abc |
392-
| string | +123 |
393-
| int | 123 |
394-
| int | -123 |
395-
| json | {"a":"b","c":"d"} |
396-
| array(int) | [1,2,3] |
397-
| array(str) | [a,b,c] |
398-
399-
> [!NOTE]
400-
> 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).
401-
> An **Odd** number of **Backslashes** **escape** the character in front of them and an **Even** number leave the character **as-is**.
402-
403183
### Templating
404184

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

415195
```yaml
416-
settings:
417-
messageTemplate: |
418-
{{- $greeting := "Hello" -}}
419-
{{ $greeting }}, {{ @name }}!
420-
{{ if @age -}}
421-
You are {{ @age }} years old.
422-
{{- else -}}
423-
Age unknown.
424-
{{- end }}
425-
Your friends:
426-
{{- range @friends }}
427-
- {{ . }}
428-
{{- else }}
429-
You have no friends.
430-
{{- end }}
431-
Profile details:
432-
{{- range $key, $value := @profile }}
433-
- {{ $key }}: {{ $value }}
434-
{{- end }}
435-
{{ define "footer" -}}
436-
This is the footer for {{ @name }}.
437-
{{- end }}
438-
{{ template "footer" . -}}
439-
------------------------------------
440-
Content-Type: {{ #Content_Type }}
441-
Redacted Auth Header: {{ #Authorization }}
196+
file not found: /home/runner/work/secured-signal-api/secured-signal-api/docs-src/configuration/examples/message-template.yml
442197
```
443198

444-
### API Token(s)
199+
### API Tokens
445200

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

@@ -562,28 +317,6 @@ settings:
562317

563318
Use `@` for aliasing Body Keys and `.` for aliasing Variables.
564319

565-
### Port
566-
567-
To change the Port which Secured Signal API uses, you need to set `service.port` in your config. (default: `8880`)
568-
569-
### Log Level
570-
571-
To change the Log Level set `logLevel` to: (default: `info`)
572-
573-
<details>
574-
<summary>Log Levels</summary>
575-
576-
| Level |
577-
| ------- |
578-
| `info` |
579-
| `debug` |
580-
| `warn` |
581-
| `error` |
582-
| `fatal` |
583-
| `dev` |
584-
585-
</details>
586-
587320
## Contributing
588321

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

0 commit comments

Comments
 (0)