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)
9
+
```yaml
10
+
{ { file.docker-compose.yaml } }
11
+
```
12
+
13
+
And add secure Token(s) to `api.tokens`. See [API TOKENs](#api-tokens).
10
14
11
15
> [!IMPORTANT]
12
16
> This Documentation will be using `sec-signal-api:8880` as the service host,
13
-
> this **won't work**, instead use your containers IP + Port.
17
+
> this **is just for simplicty**, instead use your containers or hosts IP + Port.
14
18
> Or a hostname if applicable. See [Reverse Proxy](#reverse-proxy)
15
19
16
-
```yaml
17
-
{ { file.docker-compose.yaml } }
18
-
```
19
-
20
20
### Reverse proxy
21
21
22
22
Take a look at the [traefik](https://github.com/traefik/traefik) implementation:
@@ -76,7 +76,7 @@ Here is a simple example:
76
76
curl -X POST http://sec-signal-api:8880/v2/send?@authorization=API_TOKEN
77
77
```
78
78
79
-
Notice the `@` infront of `authorization`. See [Formatting](#format).
79
+
Notice the `@` infront of `authorization`. See [KeyValue Pair Injection](#keyvalue-pair-injection).
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).
96
94
97
95
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:
123
121
124
-
Supported types include **strings**, **ints** and **arrays**
125
-
126
122
`http://sec-signal-api:8880/?@key=value`
127
123
128
-
| type | example |
129
-
| :--------- | :------ |
130
-
| string | abc |
131
-
| int | 123 |
132
-
| array |[1,2,3]|
133
-
| array(int) | 1,2,3 |
134
-
| array(str) | a,b,c |
135
-
136
-
##### Format
137
-
138
124
In order to differentiate Injection Queries and _regular_ Queries
139
125
you have to add `@` in front of any KeyValue Pair assignment.
140
126
141
-
## Environment Variables
127
+
Supported types include **strings**, **ints** and **arrays**. See [Formatting](#string-to-type).
128
+
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 Files
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
+
#### Token Configs
146
+
147
+
You can also override the `config.yml` file for each individual token by adding configs under `TOKENS_PATH` (default: `config/tokens/`)
148
+
149
+
This way you can permission tokens by further restricting or adding [Endpoints](#blocked-endpoints), [Placeholders](#variables), etc.
150
+
151
+
Here is an example:
152
+
153
+
```yaml
154
+
{ { file.examples/token.yml } }
155
+
```
156
+
157
+
### Environment
158
+
159
+
Suppose you want to set a new [Placeholder](#placeholders)`NUMBER` in your Environment...
160
+
161
+
```yaml
162
+
environment:
163
+
VARIABLES__NUMBER: "000"
164
+
```
165
+
166
+
This would internally be converted into `variables.number` matching the config formatting.
167
+
168
+
> [!IMPORTANT]
169
+
> Underscores `_` are removed during Conversion, Double Underscores `__` on the other hand convert the Variable into a nested Object (`__` replaced by `.`)
170
+
171
+
### String To Type
172
+
173
+
> [!TIP]
174
+
> This formatting applies to almost every situation where the only (allowed) Input Type is a string and other Output Types are needed.
175
+
176
+
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...
177
+
178
+
| type | example |
179
+
| :--------- | :---------------- |
180
+
| string | abc |
181
+
| string | +123 |
182
+
| int | 123 |
183
+
| int | -123 |
184
+
| json | {"a":"b","c":"d"} |
185
+
| array(int) | [1,2,3] |
186
+
| array(str) | [a,b,c] |
187
+
188
+
> [!NOTE]
189
+
> 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**.
190
+
> **Double Backslashes** do exist but you could just leave them out completly.
191
+
> An **Odd** number of **Backslashes** **escape** the character in front of them and an **Even** number leave the character **as-is**.
142
192
143
193
### API Token(s)
144
194
145
-
Both `API_TOKEN` and `API_TOKENS` support multiple Tokens seperated by a `,`**Comma**.
146
195
During Authentication Secured Signal API will try to match the given Token against the list of Tokens inside of these Variables.
147
196
148
197
```yaml
149
-
environment:
150
-
API_TOKEN: "token1, token2, token3"
151
-
API_TOKENS: "token1, token2, token3"
198
+
api:
199
+
tokens: [token1, token2, token3]
152
200
```
153
201
154
202
> [!IMPORTANT]
155
-
> It is highly recommended to set this Environment Variable
203
+
> It is highly recommended use API Tokens
156
204
157
205
> _What if I just don't?_
158
206
159
207
Secured Signal API will still work, but important Security Features won't be available
160
208
like Blocked Endpoints and any sort of Auth.
161
209
162
210
> [!NOTE]
163
-
> Blocked Endpoints can be reactivated by manually setting them in the Environment
211
+
> Blocked Endpoints can be reactivated by manually configuring them
164
212
165
213
### Blocked Endpoints
166
214
@@ -177,53 +225,27 @@ Because Secured Signal API is just a Proxy you can use all of the [Signal REST A
177
225
| **/v1/accounts** |
178
226
| **/v1/contacts** |
179
227
180
-
These Endpoints are blocked by default due to Security Risks, but can be modified by setting `BLOCKED_ENDPOINTS` to a Comma seperated List:
228
+
These Endpoints are blocked by default due to Security Risks, but can be modified by setting `blockedEndpoints` in your config:
By default Secured Signal API provides the following Placeholders:
194
-
195
-
- **NUMBER** = _ENV_: `NUMBER`
196
-
- **RECIPIENTS** = _ENV_: `RECIPIENTS`
197
-
198
-
### Customization
199
-
200
-
Placeholders can be added by setting `VARIABLES` inside your Environment.
201
-
202
-
```yaml
203
-
environment:
204
-
VARIABLES: |
205
-
"NUMBER2": "002",
206
-
"GROUP_CHAT_1": [
207
-
"user.id", "000", "001", "group.id"
208
-
]
209
-
```
234
+
### Variables
210
235
211
-
### Recipients
236
+
Placeholders can be added under `variables` and can then be referenced in the Body, Query or URL.
237
+
See [Placeholders](#placeholders).
212
238
213
-
Set this Environment Variable to automatically provide default Recipients:
239
+
> [!NOTE]
240
+
> Every Placeholder Key will be converted into an Uppercase String.
241
+
> Example: `number` becomes `NUMBER` in `{{.NUMBER}}`
214
242
215
243
```yaml
216
-
environment:
217
-
RECIPIENTS: |
218
-
user.id, 000, 001, group.id,
219
-
```
220
-
221
-
example:
222
-
223
-
```json
224
-
{
225
-
"recipients": "{{.RECIPIENTS}}"
226
-
}
244
+
variables:
245
+
number: "001",
246
+
recipients: [
247
+
"user.id", "000", "001", "group.id"
248
+
]
227
249
```
228
250
229
251
### Message Aliases
@@ -244,18 +266,34 @@ To improve compatibility with other services Secured Signal API provides aliases
244
266
245
267
Secured Signal API will pick the best scoring Message Alias (if available) to extract the correct message from the Request Body.
246
268
247
-
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):
269
+
Message Aliases can be added by setting `messageAliases` in your config:
248
270
249
271
```yaml
250
-
environment:
251
-
MESSAGE_ALIASES: |
252
-
[
253
-
{ "alias": "msg", "score": 80 },
254
-
{ "alias": "data.message", "score": 79 },
255
-
{ "alias": "array[0].message", "score": 78 },
256
-
]
272
+
messageAliases:
273
+
[
274
+
{ alias: "msg", score: 80 },
275
+
{ alias: "data.message", score: 79 },
276
+
{ alias: "array[0].message", score: 78 },
277
+
]
257
278
```
258
279
280
+
### Port
281
+
282
+
To change the Port which Secured Signal API uses, you need to set `server.port` in your config. (default: `8880`)
283
+
284
+
### Log Level
285
+
286
+
To change the Log Level set `logLevel` to: (default: `info`)
0 commit comments