Skip to content

Commit e04d854

Browse files
committed
updated Documentation to reflect new changes
1 parent 4bc16c5 commit e04d854

File tree

6 files changed

+64
-63
lines changed

6 files changed

+64
-63
lines changed

.github/templates/README.template.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ Notice the `@` infront of `authorization`. See [KeyValue Pair Injection](#keyval
8080

8181
### Example
8282

83-
To send a message to 1234567:
83+
To send a message to `+123400002`:
8484

8585
```bash
86-
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer API_TOKEN" -d '{"message": "Hello World!", "recipients": ["1234567"]}' http://sec-signal-api:8880/v2/send
86+
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer API_TOKEN" -d '{"message": "Hello World!", "recipients": ["+123400002"]}' http://sec-signal-api:8880/v2/send
8787
```
8888

8989
### Advanced
@@ -160,10 +160,10 @@ Suppose you want to set a new [Placeholder](#placeholders) `NUMBER` in your Envi
160160

161161
```yaml
162162
environment:
163-
VARIABLES__NUMBER: "000"
163+
SETTINGS__VARIABLES__NUMBER: "+123400001"
164164
```
165165
166-
This would internally be converted into `variables.number` matching the config formatting.
166+
This would internally be converted into `settings.variables.number` matching the config formatting.
167167

168168
> [!IMPORTANT]
169169
> Underscores `_` are removed during Conversion, Double Underscores `__` on the other hand convert the Variable into a nested Object (`__` replaced by `.`)
@@ -200,19 +200,15 @@ api:
200200
```
201201

202202
> [!IMPORTANT]
203-
> It is highly recommended use API Tokens
204-
205-
> _What if I just don't?_
206-
207-
Secured Signal API will still work, but important Security Features won't be available
208-
like Blocked Endpoints and any sort of Auth.
203+
> Using API Tokens is highly recommended, but not mandatory.
204+
> Some important Security Features won't be available (like default Blocked Endpoints).
209205

210206
> [!NOTE]
211207
> Blocked Endpoints can be reactivated by manually configuring them
212208

213209
### Endpoints
214210

215-
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...
211+
Since 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...
216212

217213
| Endpoint | |
218214
| :-------------------- | ------------------ |
@@ -221,27 +217,31 @@ Because Secured Signal API is just a Proxy you can use all of the [Signal REST A
221217
| **/v1/devives** | **/v1/contacts** |
222218
| **/v1/register** | **/v1/accounts** |
223219

220+
These Endpoints are blocked by default due to Security Risks.
221+
224222
> [!NOTE]
225-
> Matching works by checking if the requested Endpoints startswith a Blocked or Allowed Endpoint
223+
> Matching works by checking if the requested Endpoints starts with a Blocked or an Allowed Endpoint
226224

227-
These Endpoints are blocked by default due to Security Risks, but can be modified by setting `blockedEndpoints` in your config:
225+
You can modify Blocked Endpoints by configuring `blockedEndpoints` in your config:
228226

229227
```yaml
230-
blockedEndpoints: [/v1/register, /v1/unregister, /v1/qrcodelink, /v1/contacts]
228+
settings:
229+
blockedEndpoints: [/v1/register, /v1/unregister, /v1/qrcodelink, /v1/contacts]
231230
```
232231

233-
Override Blocked Endpoints by explicitly allowing endpoints in `allowedEndpoints`.
232+
You can also override Blocked Endpoints by adding Allowed Endpoints to `allowedEndpoints`.
233+
234+
```yaml
235+
settings:
236+
allowedEndpoints: [/v2/send]
237+
```
234238

235239
| Config (Allow) | (Block) | Result | | | |
236240
| :------------------------------- | :---------------------------------- | :--------: | --- | :---------------: | --- |
237241
| `allowedEndpoints: ["/v2/send"]` | `unset` | **all** | 🛑 | **`/v2/send`** | ✅ |
238242
| `unset` | `blockedEndpoints: ["/v1/receive"]` | **all** | ✅ | **`/v1/receive`** | 🛑 |
239243
| `blockedEndpoints: ["/v2"]` | `allowedEndpoints: ["/v2/send"]` | **`/v2*`** | 🛑 | **`/v2/send`** | ✅ |
240244

241-
```yaml
242-
allowedEndpoints: [/v2/send]
243-
```
244-
245245
### Variables
246246

247247
Placeholders can be added under `variables` and can then be referenced in the Body, Query or URL.
@@ -252,11 +252,10 @@ See [Placeholders](#placeholders).
252252
> Example: `number` becomes `NUMBER` in `{{.NUMBER}}`
253253

254254
```yaml
255-
variables:
256-
number: "001",
257-
recipients: [
258-
"user.id", "000", "001", "group.id"
259-
]
255+
settings:
256+
variables:
257+
number: "+123400001",
258+
recipients: ["+123400002", "group.id", "user.id"]
260259
```
261260

262261
### Message Aliases
@@ -278,12 +277,13 @@ Secured Signal API will pick the best scoring Message Alias (if available) to ex
278277
Message Aliases can be added by setting `messageAliases` in your config:
279278

280279
```yaml
281-
messageAliases:
282-
[
283-
{ alias: "msg", score: 80 },
284-
{ alias: "data.message", score: 79 },
285-
{ alias: "array[0].message", score: 78 },
286-
]
280+
settings:
281+
messageAliases:
282+
[
283+
{ alias: "msg", score: 80 },
284+
{ alias: "data.message", score: 79 },
285+
{ alias: "array[0].message", score: 78 },
286+
]
287287
```
288288

289289
### Port

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
settings:
77
messageAliases:

docker-compose.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,28 @@ services:
66
- MODE=normal
77
volumes:
88
- ./data:/home/.local/share/signal-cli
9+
restart: unless-stopped
910
networks:
1011
backend:
1112
aliases:
1213
- signal-api
13-
restart: unless-stopped
1414

1515
secured-signal:
1616
image: ghcr.io/codeshelldev/secured-signal-api:latest
1717
container_name: secured-signal
18-
networks:
19-
backend:
20-
aliases:
21-
- secured-signal-api
2218
environment:
2319
API__URL: http://signal-api:8080
24-
VARIABLES__RECIPIENTS: 000,001,002
25-
VARIABLES__NUMBER: 123456789
26-
API__TOKENS: LOOOOOONG_STRING
20+
SETTINGS__VARIABLES__RECIPIENTS:
21+
["+123400002", "+123400003", "+123400004"]
22+
SETTINGS__VARIABLES__NUMBER: "+123400001"
23+
API__TOKENS: [LOOOOOONG_STRING]
2724
ports:
2825
- "8880:8880"
2926
restart: unless-stopped
27+
networks:
28+
backend:
29+
aliases:
30+
- secured-signal-api
3031

3132
networks:
3233
backend:

examples/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ logLevel: INFO
99

1010
settings:
1111
variables:
12-
number: "000"
13-
recipients: ["001", "group.id", "user.id"]
12+
number: "+123400001"
13+
recipients: ["+123400002", "group.id", "user.id"]
1414

1515
messageAliases: [{ alias: "msg", score: 100 }]
1616

examples/traefik.docker-compose.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@ services:
22
secured-signal:
33
image: ghcr.io/codeshelldev/secured-signal-api:latest
44
container_name: secured-signal
5-
networks:
6-
proxy:
7-
backend:
8-
aliases:
9-
- secured-signal-api
105
environment:
116
API__URL: http://signal-api:8080
12-
DEFAULT_RECIPIENTS: 000,001,002
13-
NUMBER: 123456789
14-
API__TOKENS: LOOOOOONG_STRING
7+
SETTINGS__VARIABLES__RECIPIENTS: ["123400002", "123400003", "123400004"]
8+
SETTINGS__VARIABLES__NUMBER: "+123400001"
9+
API__TOKENS: [LOOOOOONG_STRING]
1510
labels:
1611
- traefik.enable=true
1712
- traefik.http.routers.signal-api.rule=Host(`signal-api.mydomain.com`)
@@ -22,6 +17,11 @@ services:
2217
- traefik.http.services.signal-api-svc.loadbalancer.server.port=8880
2318
- traefik.docker.network=proxy
2419
restart: unless-stopped
20+
networks:
21+
proxy:
22+
backend:
23+
aliases:
24+
- secured-signal-api
2525

2626
networks:
2727
backend:

utils/config/loader.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,6 @@ var ENV *ENV_ = &ENV_{
4848
INSECURE: false,
4949
}
5050

51-
func InitEnv() {
52-
ENV.PORT = strconv.Itoa(config.Int("server.port"))
53-
54-
ENV.LOG_LEVEL = config.String("loglevel")
55-
56-
ENV.API_URL = config.String("api.url")
57-
58-
transformChildren(config, "variables", func(key string, value any) (string, any) {
59-
return strings.ToUpper(key), value
60-
})
61-
62-
config.Unmarshal("settings", ENV.SETTINGS["*"])
63-
}
64-
6551
func Load() {
6652
LoadDefaults()
6753

@@ -86,6 +72,20 @@ func Load() {
8672
log.Dev("Loaded Token Configs:\n" + utils.ToJson(tokensLayer.All()))
8773
}
8874

75+
func InitEnv() {
76+
ENV.PORT = strconv.Itoa(config.Int("server.port"))
77+
78+
ENV.LOG_LEVEL = config.String("loglevel")
79+
80+
ENV.API_URL = config.String("api.url")
81+
82+
transformChildren(config, "variables", func(key string, value any) (string, any) {
83+
return strings.ToUpper(key), value
84+
})
85+
86+
config.Unmarshal("settings", ENV.SETTINGS["*"])
87+
}
88+
8989
func LoadDefaults() {
9090
_, defErr := LoadFile(ENV.DEFAULTS_PATH, defaultsLayer, yaml.Parser())
9191

0 commit comments

Comments
 (0)