Skip to content

Commit f81251e

Browse files
committed
updated README and surrounding files
1 parent f0896d2 commit f81251e

File tree

5 files changed

+105
-71
lines changed

5 files changed

+105
-71
lines changed

.github/templates/README.template.md

Lines changed: 84 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
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 REST API</a></h5>
3+
<h5 align="center">Secure Proxy for <a href="https://github.com/bbernhard/signal-cli-rest-api">Signal Messenger REST API</a></h5>
44

5-
## Installation
5+
## Getting Started
66

77
Get the latest version of the `docker-compose.yaml` file:
88

9-
And add secure Token(s) to `API__TOKEN` / `API__TOKENS`. See [API TOKEN(s)](#api-tokens)
9+
```yaml
10+
{ { file.docker-compose.yaml } }
11+
```
12+
13+
And add secure Token(s) to `api.tokens`. See [API TOKEN(s)](#api-tokens).
1014

1115
> [!IMPORTANT]
1216
> This Documentation will be using `sec-signal-api:8880` as the service host,
1317
> this **is just for simplicty**, instead use your containers or hosts IP + Port.
1418
> Or a hostname if applicable. See [Reverse Proxy](#reverse-proxy)
1519
16-
```yaml
17-
{ { file.docker-compose.yaml } }
18-
```
19-
2020
### Reverse proxy
2121

2222
Take a look at the [traefik](https://github.com/traefik/traefik) implementation:
@@ -90,9 +90,7 @@ curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer API_T
9090

9191
#### Placeholders
9292

93-
If you are not comfortable / don't want to hardcode your Number and/or Recipients in you may use **Placeholders** in your Request.
94-
95-
Built-in Placeholders: `{{ .NUMBER }}` and `{{ .RECIPIENTS }}`
93+
If you are not comfortable / don't want to hardcode your Number for example and/or Recipients in you, may use **Placeholders** in your Request. See [Custom Variables](#variables).
9694

9795
These Placeholders can be used in the Request Query or the Body of a Request like so:
9896

@@ -128,15 +126,42 @@ you have to add `@` in front of any KeyValue Pair assignment.
128126

129127
Supported types include **strings**, **ints** and **arrays**. See [Formatting](#string-to-type).
130128

131-
## Environment Variables
129+
## Configuration
130+
131+
There are multiple ways to configure Secured Signal API, you can optionally use `config.yml` aswell as Environment Variables to override the config.
132+
133+
### Config File
134+
135+
Config files allow **YML** formatting and also `${ENV}` to get Environment Variables.
136+
137+
To change the internal config file location set `CONFIG_PATH` in your **Environment** to an absolute path including the filename.extension. (default: `/config/config.yml`)
138+
139+
This example config shows all of the individual settings that can be applied:
140+
141+
```yaml
142+
{ { file.examples/config.yml } }
143+
```
144+
145+
### Environment
146+
147+
Suppose you want to set a new [Placeholder](#placeholders) `NUMBER` in your Environment...
148+
149+
```yaml
150+
environment:
151+
VARIABLES__NUMBER: "000"
152+
```
153+
154+
This would internally be converted into `variables.number` matching the config formatting.
155+
156+
> [!IMPORTANT]
157+
> Underscores `_` are removed during Conversion, Double Underscores `__` on the other hand convert the Variable into a nested Object (`__` replaced by `.`)
132158

133159
### String To Type
134160

135161
> [!TIP]
136162
> This formatting applies to almost every situation where the only (allowed) Input Type is a string and other Output Types are needed.
137163

138-
In the Environment the only allowed type is a string so to not have to always use a json string you can use the following types,
139-
if you format them correctly...
164+
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...
140165

141166
| type | example |
142167
| :--------- | :---------------- |
@@ -149,30 +174,33 @@ if you format them correctly...
149174
| array(str) | [a,b,c] |
150175

151176
> [!NOTE]
152-
> 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** > **Double Backslashes** do exist in that case you could just leave them out completly.
177+
> 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**.
178+
> **Double Backslashes** do exist but you could just leave them out completly.
153179
> An **Odd** number of **Backslashes** **escape** the character in front of them and an **Even** number leave the character **as-is**.
154180

155181
### API Token(s)
156182

157-
Both `API__TOKEN` and `API__TOKENS` support multiple Tokens seperated by a `,` **Comma** and `[]` **Brackets**. See [Formatting](#string-to-type).
158183
During Authentication Secured Signal API will try to match the given Token against the list of Tokens inside of these Variables.
159184

185+
> [!NOTE]
186+
> Both `api.token` and `api.tokens` support multiple Tokens.
187+
160188
```yaml
161-
environment:
162-
API__TOKEN: [token1, token2, token3]
163-
API__TOKENS: [token1, token2, token3]
189+
api:
190+
token: [token1, token2, token3]
191+
tokens: [token1, token2, token3]
164192
```
165193

166194
> [!IMPORTANT]
167-
> It is highly recommended to set this Environment Variable
195+
> It is highly recommended use API Tokens
168196

169197
> _What if I just don't?_
170198

171199
Secured Signal API will still work, but important Security Features won't be available
172200
like Blocked Endpoints and any sort of Auth.
173201

174202
> [!NOTE]
175-
> Blocked Endpoints can be reactivated by manually setting them in the Environment
203+
> Blocked Endpoints can be reactivated by manually configuring them
176204

177205
### Blocked Endpoints
178206

@@ -189,53 +217,27 @@ Because Secured Signal API is just a Proxy you can use all of the [Signal REST A
189217
| **/v1/accounts** |
190218
| **/v1/contacts** |
191219

192-
These Endpoints are blocked by default due to Security Risks, but can be modified by setting `BLOCKED_ENDPOINTS` to a Comma seperated List:
220+
These Endpoints are blocked by default due to Security Risks, but can be modified by setting `blockedEndpoints` in your config:
193221

194222
```yaml
195-
environment:
196-
BLOCKED_ENDPOINTS: |
197-
/v1/register,
198-
/v1/unregister,
199-
/v1/qrcodelink,
200-
/v1/contacts,
223+
blockedEndpoints: [/v1/register, /v1/unregister, /v1/qrcodelink, /v1/contacts]
201224
```
202225

203-
#### Variables
204-
205-
By default Secured Signal API provides the following Placeholders:
226+
### Variables
206227

207-
- **NUMBER** = _ENV_: `NUMBER`
208-
- **RECIPIENTS** = _ENV_: `RECIPIENTS`
228+
Placeholders can be added under `variables` and can then be referenced in the Body, Query or URL.
229+
See [Placeholders](#placeholders).
209230

210-
### Customization
211-
212-
Placeholders can be added by setting `VARIABLES` inside your Environment.
213-
214-
```yaml
215-
environment:
216-
VARIABLES: |
217-
"NUMBER2": "002",
218-
"GROUP_CHAT_1": [
219-
"user.id", "000", "001", "group.id"
220-
]
221-
```
222-
223-
### Recipients
224-
225-
Set this Environment Variable to automatically provide default Recipients:
231+
> [!NOTE]
232+
> Every Placeholder Key will be converted into an Uppercase String.
233+
> Example: `number` becomes `NUMBER` in `{{.NUMBER}}`
226234

227235
```yaml
228-
environment:
229-
RECIPIENTS: |
230-
[ user.id, 000, 001, group.id ]
231-
```
232-
233-
example:
234-
235-
```json
236-
{
237-
"recipients": "{{.RECIPIENTS}}"
238-
}
236+
variables:
237+
number: "001",
238+
recipients: [
239+
"user.id", "000", "001", "group.id"
240+
]
239241
```
240242

241243
### Message Aliases
@@ -256,18 +258,33 @@ To improve compatibility with other services Secured Signal API provides aliases
256258

257259
Secured Signal API will pick the best scoring Message Alias (if available) to extract the correct message from the Request Body.
258260

259-
Message Aliases can be added by setting `MESSAGE_ALIASES` to a valid json array containing dictionaries of `alias`, the json key to be used for lookup (use `.` dots for using values from a nested dictionary and `[i]` to get values from an array):
261+
Message Aliases can be added by setting `messageAliases` in your config:
260262

261263
```yaml
262-
environment:
263-
MESSAGE_ALIASES: |
264-
[
265-
{ "alias": "msg", "score": 80 },
266-
{ "alias": "data.message", "score": 79 },
267-
{ "alias": "array[0].message", "score": 78 },
268-
]
264+
messageAliases:
265+
[
266+
{ alias: "msg", score: 80 },
267+
{ alias: "data.message", score: 79 },
268+
{ alias: "array[0].message", score: 78 },
269+
]
269270
```
270271

272+
### Port
273+
274+
To change the Port which Secured Signal API uses, you need to set `server.port` in your config. (default: `8880`)
275+
276+
### Log Level
277+
278+
To change the Log Level set `logLevel` to: (default: `info`)
279+
280+
| Level |
281+
| ------- |
282+
| `info` |
283+
| `debug` |
284+
| `warn` |
285+
| `error` |
286+
| `fatal` |
287+
271288
## Contributing
272289

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

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM alpine:latest
22
RUN apk --no-cache add ca-certificates
33

4-
ENV SERVER_PORT=8880
4+
ENV SERVER__PORT=8880
55

66
ENV DEFAULTS_PATH=/app/config/defaults.yml
77

config/defaults.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
server:
22
port: 8880
33

4-
logLevel: "INFO"
4+
logLevel: INFO
55

66
messageAliases:
77
[

docker-compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ services:
2121
- secured-signal-api
2222
environment:
2323
API__URL: http://signal-api:8080
24-
RECIPIENTS: 000,001,002
25-
NUMBER: 123456789
24+
VARIABLES__RECIPIENTS: 000,001,002
25+
VARIABLES__NUMBER: 123456789
2626
API__TOKENS: LOOOOOONG_STRING
2727
ports:
2828
- "8880:8880"

examples/config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Example Config (all configurations shown)
2+
3+
api:
4+
port: 8880
5+
url: http://signal-api:8080
6+
tokens: [token1, token2]
7+
8+
logLevel: INFO
9+
10+
variables:
11+
number: "000"
12+
recipients: ["001", "group.id", "user.id"]
13+
14+
messageAliases: [{ alias: "msg", score: 100 }]
15+
16+
blockedEndpoints:
17+
- /v1/about

0 commit comments

Comments
 (0)