Skip to content

Commit 9dccd09

Browse files
Automated README update (#100)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: CodeShell <[email protected]>
1 parent 24a0f8c commit 9dccd09

File tree

1 file changed

+113
-87
lines changed

1 file changed

+113
-87
lines changed

README.md

Lines changed: 113 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ Check out the official [Documentation](https://codeshelldev.github.io/secured-si
5454
- [Configuration](#configuration)
5555
- [Endpoints](#endpoints)
5656
- [Variables](#variables)
57-
- [Data Aliases](#data-aliases)
57+
- [Field Policies](#field-policies)
58+
- [Field Mappings](#field-mappings)
5859
- [Message Templates](#message-templates)
5960
- [Integrations](https://codeshelldev.github.io/secured-signal-api/docs/integrations/compatibility)
6061
- [Contributing](#contributing)
@@ -88,10 +89,9 @@ services:
8889
container_name: secured-signal
8990
environment:
9091
API__URL: http://signal-api:8080
91-
SETTINGS__VARIABLES__RECIPIENTS:
92-
'[+123400002, +123400003, +123400004]'
93-
SETTINGS__VARIABLES__NUMBER: "+123400001"
94-
API__TOKENS: '[LOOOOOONG_STRING]'
92+
SETTINGS__MESSAGE__VARIABLES__RECIPIENTS: "[+123400002, +123400003, +123400004]"
93+
SETTINGS__MESSAGE__VARIABLES__NUMBER: "+123400001"
94+
API__TOKENS: "[LOOOOOONG_STRING]"
9595
ports:
9696
- "8880:8880"
9797
restart: unless-stopped
@@ -209,23 +209,24 @@ api:
209209
logLevel: info
210210
211211
settings:
212-
messageTemplate: |
213-
You've got a Notification:
214-
{{@message}}
215-
At {{@data.timestamp}} on {{@data.date}}.
216-
Send using {{.NUMBER}}.
217-
218-
variables:
219-
number: "+123400001"
220-
recipients: ["+123400002", "group.id", "user.id"]
221-
222-
dataAliases:
223-
"@message": [{ alias: "msg", score: 100 }]
224-
225-
blockedEndpoints:
226-
- /v1/about
227-
allowedEndpoints:
228-
- /v2/send
212+
message:
213+
template: |
214+
You've got a Notification:
215+
{{@message}}
216+
At {{@data.timestamp}} on {{@data.date}}.
217+
Send using {{.NUMBER}}.
218+
219+
variables:
220+
number: "+123400001"
221+
recipients: ["+123400002", "group.id", "user.id"]
222+
223+
fieldMappings:
224+
"@message": [{ field: "msg", score: 100 }]
225+
226+
access:
227+
endpoints:
228+
- !/v1/about
229+
- /v2/send
229230
```
230231

231232
#### Token Configs
@@ -240,10 +241,13 @@ Here is an example:
240241
tokens: [LOOOONG_STRING]
241242
242243
overrides:
243-
variables: # Disable Placeholder
244-
blockedEndpoints: # Disable Sending
245-
- /v2/send
246-
dataAliases: # Disable Aliases
244+
message:
245+
fieldMappings: # Disable Mappings
246+
variables: # Disable Placeholder
247+
248+
access:
249+
endpoints: # Disable Sending
250+
- !/v2/send
247251
```
248252

249253
### Templating
@@ -260,31 +264,32 @@ This makes advanced [Message Templates](#message-templates) like this one possib
260264

261265
```yaml
262266
settings:
263-
messageTemplate: |
264-
{{- $greeting := "Hello" -}}
265-
{{ $greeting }}, {{ @name }}!
266-
{{ if @age -}}
267-
You are {{ @age }} years old.
268-
{{- else -}}
269-
Age unknown.
270-
{{- end }}
271-
Your friends:
272-
{{- range @friends }}
273-
- {{ . }}
274-
{{- else }}
275-
You have no friends.
276-
{{- end }}
277-
Profile details:
278-
{{- range $key, $value := @profile }}
279-
- {{ $key }}: {{ $value }}
280-
{{- end }}
281-
{{ define "footer" -}}
282-
This is the footer for {{ @name }}.
283-
{{- end }}
284-
{{ template "footer" . -}}
285-
------------------------------------
286-
Content-Type: {{ #Content_Type }}
287-
Redacted Auth Header: {{ #Authorization }}
267+
message:
268+
template: |
269+
{{- $greeting := "Hello" -}}
270+
{{ $greeting }}, {{ @name }}!
271+
{{ if @age -}}
272+
You are {{ @age }} years old.
273+
{{- else -}}
274+
Age unknown.
275+
{{- end }}
276+
Your friends:
277+
{{- range @friends }}
278+
- {{ . }}
279+
{{- else }}
280+
You have no friends.
281+
{{- end }}
282+
Profile details:
283+
{{- range $key, $value := @profile }}
284+
- {{ $key }}: {{ $value }}
285+
{{- end }}
286+
{{ define "footer" -}}
287+
This is the footer for {{ @name }}.
288+
{{- end }}
289+
{{ template "footer" . -}}
290+
------------------------------------
291+
Content-Type: {{ #Content_Type }}
292+
Redacted Auth Header: {{ #Authorization }}
288293
```
289294

290295
### API Tokens
@@ -319,25 +324,26 @@ These Endpoints are blocked by default due to Security Risks.
319324
> [!NOTE]
320325
> Matching works by checking if the requested Endpoints starts with a Blocked or an Allowed Endpoint
321326

322-
You can modify Blocked Endpoints by configuring `blockedEndpoints` in your config:
327+
You can modify endpoints by configuring `access.endpoints` in your config:
323328

324329
```yaml
325330
settings:
326-
blockedEndpoints: [/v1/register, /v1/unregister, /v1/qrcodelink, /v1/contacts]
331+
access:
332+
endpoints:
333+
- !/v1/register
334+
- !/v1/unregister
335+
- !/v1/qrcodelink
336+
- !/v1/contacts
337+
- /v2/send
327338
```
328339

329-
You can also override Blocked Endpoints by adding Allowed Endpoints to `allowedEndpoints`.
340+
By default adding an endpoint explictly allows access to it, use `!` to block it instead.
330341

331-
```yaml
332-
settings:
333-
allowedEndpoints: [/v2/send]
334-
```
335-
336-
| Config (Allow) | (Block) | Result | | | |
337-
| :------------------------------- | :---------------------------------- | :--------: | --- | :---------------: | --- |
338-
| `allowedEndpoints: ["/v2/send"]` | `unset` | **all** | 🛑 | **`/v2/send`** | ✅ |
339-
| `unset` | `blockedEndpoints: ["/v1/receive"]` | **all** | ✅ | **`/v1/receive`** | 🛑 |
340-
| `blockedEndpoints: ["/v2"]` | `allowedEndpoints: ["/v2/send"]` | **`/v2*`** | 🛑 | **`/v2/send`** | ✅ |
342+
| Config (Allow) | (Block) | Result | | | |
343+
| :------------- | :------------- | :--------: | --- | :---------------: | --- |
344+
| `/v2/send` | `unset` | **all** | 🛑 | **`/v2/send`** | ✅ |
345+
| `unset` | `!/v1/receive` | **all** | ✅ | **`/v1/receive`** | 🛑 |
346+
| `/v2` | `!/v2/send` | **`/v2*`** | 🛑 | **`/v2/send`** | ✅ |
341347

342348
### Variables
343349

@@ -350,35 +356,54 @@ See [Placeholders](#placeholders).
350356

351357
```yaml
352358
settings:
353-
variables:
354-
number: "+123400001",
355-
recipients: ["+123400002", "group.id", "user.id"]
359+
message:
360+
variables:
361+
number: "+123400001",
362+
recipients: ["+123400002", "group.id", "user.id"]
356363
```
357364

358365
### Message Templates
359366

360367
To customize the `message` attribute you can use **Message Templates** to build your message by using other Body Keys and Variables.
361-
Use `messageTemplate` to configure:
368+
Use `message.template` to configure:
362369

363370
```yaml
364371
settings:
365-
messageTemplate: |
366-
Your Message:
367-
{{@message}}.
368-
Sent with Secured Signal API.
372+
message:
373+
template: |
374+
Your Message:
375+
{{@message}}.
376+
Sent with Secured Signal API.
369377
```
370378

371379
Message Templates support [Standard Golang Templating](#templating).
372380
Use `@data.key` to reference Body Keys, `#Content_Type` for Headers and `.KEY` for Variables.
373381

374-
### Data Aliases
382+
### Field Policies
383+
384+
**Field Policies** allow for blocking or specifically allowing certain fields with set values from being used in the requests body or headers.
385+
386+
Configure them by using `access.fieldPolicies` like so:
387+
388+
```yaml
389+
settings:
390+
access:
391+
fieldPolicies:
392+
"@number": { value: "+123400002", action: block }
393+
```
394+
395+
Set the wanted action on encounter, available options are `block` and `allow`.
396+
397+
Use `@` for Body Keys and `#` for Headers.
398+
399+
### Field Mappings
375400

376-
To improve compatibility with other services Secured Signal API provides **Data Aliases** and a built-in `message` Alias.
401+
To improve compatibility with other services Secured Signal API provides **Field Mappings** and a built-in `message` Mapping.
377402

378403
<details>
379-
<summary><strong>Default `message` Aliases</strong></summary>
404+
<summary><strong>Default `message` Mapping</strong></summary>
380405

381-
| Alias | Score | Alias | Score |
406+
| Field | Score | Field | Score |
382407
| ------------ | ----- | ---------------- | ----- |
383408
| msg | 100 | data.content | 9 |
384409
| content | 99 | data.description | 8 |
@@ -390,23 +415,24 @@ To improve compatibility with other services Secured Signal API provides **Data
390415

391416
</details>
392417

393-
Secured Signal API will pick the best scoring Data Alias (if available) to extract set the Key to the correct Value from the Request Body.
418+
Secured Signal API will pick the best scoring Field (if available) to set the Key to the correct Value from the Request Body.
394419

395-
Data Aliases can be added by setting `dataAliases` in your config:
420+
Field Mappings can be added by setting `message.fieldMappings` in your config:
396421

397422
```yaml
398423
settings:
399-
dataAliases:
400-
"@message":
401-
[
402-
{ alias: "msg", score: 80 },
403-
{ alias: "data.message", score: 79 },
404-
{ alias: "array[0].message", score: 78 },
405-
]
406-
".NUMBER": [{ alias: "phone_number", score: 100 }]
424+
message:
425+
fieldMappings:
426+
"@message":
427+
[
428+
{ field: "msg", score: 80 },
429+
{ field: "data.message", score: 79 },
430+
{ field: "array[0].message", score: 78 },
431+
]
432+
".NUMBER": [{ field: "phone_number", score: 100 }]
407433
```
408434

409-
Use `@` for aliasing Body Keys and `.` for aliasing Variables.
435+
Use `@` for mapping to Body Keys and `.` for mapping to Variables.
410436

411437
## Contributing
412438

0 commit comments

Comments
 (0)