You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<imgalign="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" />
2
2
3
-
<h5align="center">Secure Proxy for <ahref="https://github.com/bbernhard/signal-cli-rest-api">Signal REST API</a></h5>
3
+
<h5align="center">Secure Proxy for <ahref="https://github.com/bbernhard/signal-cli-rest-api">Signal Messenger REST API</a></h5>
4
4
5
-
## Installation
5
+
## Getting Started
6
6
7
7
Get the latest version of the `docker-compose.yaml` file:
8
8
9
-
And add secure Token(s) to `API_TOKEN` / `API_TOKENS`. See [API_TOKEN(s)](#api-tokens)
10
-
11
-
> [!IMPORTANT]
12
-
> This Documentation will be using `sec-signal-api:8880` as the service host,
13
-
> this **won't work**, instead use your containers IP + Port.
14
-
> Or a hostname if applicable. See [Reverse Proxy](#reverse-proxy)
15
-
16
9
```yaml
17
10
services:
18
11
signal-api:
@@ -36,10 +29,10 @@ services:
36
29
aliases:
37
30
- secured-signal-api
38
31
environment:
39
-
SIGNAL_API_URL: http://signal-api:8080
40
-
DEFAULT_RECIPIENTS: '[ "000", "001", "002" ]'
41
-
NUMBER: 123456789
42
-
API_TOKEN: LOOOOOONG_STRING
32
+
API__URL: http://signal-api:8080
33
+
VARIABLES__RECIPIENTS: '[000,001,002]'
34
+
VARIABLES__NUMBER: 123456789
35
+
API__TOKENS: '[LOOOOOONG_STRING]'
43
36
ports:
44
37
- "8880:8880"
45
38
restart: unless-stopped
@@ -48,6 +41,13 @@ networks:
48
41
backend:
49
42
```
50
43
44
+
And add secure Token(s) to `api.tokens`. See [API TOKENs](#api-tokens).
45
+
46
+
> [!IMPORTANT]
47
+
> This Documentation will be using `sec-signal-api:8880` as the service host,
48
+
> this **is just for simplicty**, instead use your containers or hosts IP + Port.
49
+
> Or a hostname if applicable. See [Reverse Proxy](#reverse-proxy)
50
+
51
51
### Reverse proxy
52
52
53
53
Take a look at the [traefik](https://github.com/traefik/traefik) implementation:
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).
155
153
156
154
These Placeholders can be used in the Request Query or the Body of a Request like so:
In some cases you may not be able to access / modify the Request Body, in that case specify needed values in the Request Query:
182
180
183
-
Supported types include **strings**, **ints** and **arrays**
184
-
185
181
`http://sec-signal-api:8880/?@key=value`
186
182
187
-
| type | example |
188
-
| :--------- | :------ |
189
-
| string | abc |
190
-
| int | 123 |
191
-
| array | [1,2,3] |
192
-
| array(int) | 1,2,3 |
193
-
| array(str) | a,b,c |
194
-
195
-
##### Format
196
-
197
183
In order to differentiate Injection Queries and _regular_ Queries
198
184
you have to add `@` in front of any KeyValue Pair assignment.
199
185
200
-
## Environment Variables
186
+
Supported types include **strings**, **ints** and **arrays**. See [Formatting](#string-to-type).
187
+
188
+
## Configuration
189
+
190
+
There are multiple ways to configure Secured Signal API, you can optionally use `config.yml` aswell as Environment Variables to override the config.
191
+
192
+
### Config Files
193
+
194
+
Config files allow **YML** formatting and also `${ENV}` to get Environment Variables.
195
+
196
+
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`)
197
+
198
+
This example config shows all of the individual settings that can be applied:
199
+
200
+
```yaml
201
+
# Example Config (all configurations shown)
202
+
203
+
api:
204
+
port: 8880
205
+
url: http://signal-api:8080
206
+
tokens: [token1, token2]
207
+
208
+
logLevel: INFO
209
+
210
+
variables:
211
+
number: "000"
212
+
recipients: ["001", "group.id", "user.id"]
213
+
214
+
messageAliases: [{ alias: "msg", score: 100 }]
215
+
216
+
blockedEndpoints:
217
+
- /v1/about
218
+
allowedEndpoints:
219
+
- /v2/send
220
+
```
221
+
222
+
#### Token Configs
223
+
224
+
You can also override the `config.yml` file for each individual token by adding configs under `TOKENS_PATH` (default: `config/tokens/`)
225
+
226
+
This way you can permission tokens by further restricting or adding [Endpoints](#blocked-endpoints), [Placeholders](#variables), etc.
227
+
228
+
Here is an example:
229
+
230
+
```yaml
231
+
tokens: [LOOOONG_STRING]
232
+
233
+
overrides:
234
+
variables: # Disable Placeholder
235
+
blockedEndpoints: # Disable Sending
236
+
- /v2/send
237
+
messageAliases: # Disable Aliases
238
+
```
239
+
240
+
### Environment
241
+
242
+
Suppose you want to set a new [Placeholder](#placeholders) `NUMBER` in your Environment...
243
+
244
+
```yaml
245
+
environment:
246
+
VARIABLES__NUMBER: "000"
247
+
```
248
+
249
+
This would internally be converted into `variables.number` matching the config formatting.
250
+
251
+
> [!IMPORTANT]
252
+
> Underscores `_` are removed during Conversion, Double Underscores `__` on the other hand convert the Variable into a nested Object (`__` replaced by `.`)
253
+
254
+
### String To Type
255
+
256
+
> [!TIP]
257
+
> This formatting applies to almost every situation where the only (allowed) Input Type is a string and other Output Types are needed.
258
+
259
+
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...
260
+
261
+
| type | example |
262
+
| :--------- | :---------------- |
263
+
| string | abc |
264
+
| string | +123 |
265
+
| int | 123 |
266
+
| int | -123 |
267
+
| json | {"a":"b","c":"d"} |
268
+
| array(int) | [1,2,3] |
269
+
| array(str) | [a,b,c] |
270
+
271
+
> [!NOTE]
272
+
> 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**.
273
+
> **Double Backslashes** do exist but you could just leave them out completly.
274
+
> An **Odd** number of **Backslashes** **escape** the character in front of them and an **Even** number leave the character **as-is**.
201
275
202
276
### API Token(s)
203
277
204
-
Both `API_TOKEN` and `API_TOKENS` support multiple Tokens seperated by a `,` **Comma**.
205
278
During Authentication Secured Signal API will try to match the given Token against the list of Tokens inside of these Variables.
206
279
207
280
```yaml
208
-
environment:
209
-
API_TOKEN: "token1, token2, token3"
210
-
API_TOKENS: "token1, token2, token3"
281
+
api:
282
+
tokens: [token1, token2, token3]
211
283
```
212
284
213
285
> [!IMPORTANT]
214
-
> It is highly recommended to set this Environment Variable
286
+
> It is highly recommended use API Tokens
215
287
216
288
> _What if I just don't?_
217
289
218
290
Secured Signal API will still work, but important Security Features won't be available
219
291
like Blocked Endpoints and any sort of Auth.
220
292
221
293
> [!NOTE]
222
-
> Blocked Endpoints can be reactivated by manually setting them in the Environment
294
+
> Blocked Endpoints can be reactivated by manually configuring them
223
295
224
-
### Blocked Endpoints
296
+
### Endpoints
225
297
226
298
Because Secured Signal API is just a Proxy you can use all of the [Signal REST API](https://github.com/bbernhard/signal-cli-rest-api/blob/master/doc/EXAMPLES.md) endpoints except for...
227
299
@@ -236,53 +308,42 @@ Because Secured Signal API is just a Proxy you can use all of the [Signal REST A
236
308
| **/v1/accounts** |
237
309
| **/v1/contacts** |
238
310
239
-
These Endpoints are blocked by default due to Security Risks, but can be modified by setting `BLOCKED_ENDPOINTS` to a Comma seperated List:
311
+
> [!NOTE]
312
+
> Matching works by checking if the requested Endpoints startswith a Blocked or Allowed Endpoint
313
+
314
+
These Endpoints are blocked by default due to Security Risks, but can be modified by setting `blockedEndpoints` in your config:
Set this Environment Variable to automatically provide default Recipients:
273
-
274
-
```yaml
275
-
environment:
276
-
RECIPIENTS: |
277
-
user.id, 000, 001, group.id,
278
-
```
334
+
Placeholders can be added under `variables` and can then be referenced in the Body, Query or URL.
335
+
See [Placeholders](#placeholders).
279
336
280
-
example:
337
+
> [!NOTE]
338
+
> Every Placeholder Key will be converted into an Uppercase String.
339
+
> Example: `number` becomes `NUMBER` in `{{.NUMBER}}`
281
340
282
-
```json
283
-
{
284
-
"recipients": "{{.RECIPIENTS}}"
285
-
}
341
+
```yaml
342
+
variables:
343
+
number: "001",
344
+
recipients: [
345
+
"user.id", "000", "001", "group.id"
346
+
]
286
347
```
287
348
288
349
### Message Aliases
@@ -303,18 +364,34 @@ To improve compatibility with other services Secured Signal API provides aliases
303
364
304
365
Secured Signal API will pick the best scoring Message Alias (if available) to extract the correct message from the Request Body.
305
366
306
-
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):
367
+
Message Aliases can be added by setting `messageAliases` in your config:
307
368
308
369
```yaml
309
-
environment:
310
-
MESSAGE_ALIASES: |
311
-
[
312
-
{ "alias": "msg", "score": 80 },
313
-
{ "alias": "data.message", "score": 79 },
314
-
{ "alias": "array[0].message", "score": 78 },
315
-
]
370
+
messageAliases:
371
+
[
372
+
{ alias: "msg", score: 80 },
373
+
{ alias: "data.message", score: 79 },
374
+
{ alias: "array[0].message", score: 78 },
375
+
]
316
376
```
317
377
378
+
### Port
379
+
380
+
To change the Port which Secured Signal API uses, you need to set `server.port` in your config. (default: `8880`)
381
+
382
+
### Log Level
383
+
384
+
To change the Log Level set `logLevel` to: (default: `info`)
0 commit comments