Skip to content

Commit 66abe18

Browse files
committed
2 parents 226ef21 + 8a8df7c commit 66abe18

File tree

29 files changed

+702
-207
lines changed

29 files changed

+702
-207
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ assignees: ''
77

88
---
99

10-
**Describe the bug**
10+
### Description
1111
A clear and concise description of what the bug is.
1212

13-
**To Reproduce**
13+
### To Reproduce
1414
Steps to reproduce the behavior:
1515
1. Start Container
1616
2. Send Request
1717
3. [...]
1818

19-
**Expected behavior**
19+
### Expected behavior
2020
A clear and concise description of what you expected to happen.
2121

22-
**Additional context**
22+
### Additional Context
2323
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ assignees: ''
77

88
---
99

10-
**Is your feature request related to a problem? Please describe.**
11-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
10+
### Description
11+
A clear and concise description of the feature. (is it related to a problem?)
1212

13-
**Describe the solution you'd like**
13+
### Solution
1414
A clear and concise description of what you want to happen.
1515

16-
**Describe alternatives you've considered**
16+
### Alternatives
1717
A clear and concise description of any alternative solutions or features you've considered.
1818

19-
**Additional context**
19+
### Additional Context
2020
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Summary
2+
Describe what this PR does.
3+
4+
### Changes
5+
* List major changes
6+
7+
### Checklist
8+
- [ ] PR tested
9+
- [ ] Docs updated (if applicable)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Bug fix
3+
about: Submit a Bugfix
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
### Issue
11+
Fixes # (issue)
12+
13+
### Changes
14+
* Describe the fix clearly
15+
* Mention root cause if known
16+
17+
### Verification
18+
- [ ] Tested locally
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Feature addition
3+
about: Add a Feature
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
### Summary
11+
Describe the new feature and motivation.
12+
13+
### Changes
14+
* List major additions
15+
16+
### Checklist
17+
- [ ] Feature tested
18+
- [ ] Docs updated

.github/templates/README.template.md

Lines changed: 83 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<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" />
1+
<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/banner.png" />
22

33
<h3 align="center">Secure Proxy for <a href="https://github.com/bbernhard/signal-cli-rest-api">Signal Messenger REST API</a></h3>
44

55
<p align="center">
6-
adding token-based authentication,
7-
endpoint restrictions, placeholders, and flexible configuration.
6+
token-based authentication,
7+
endpoint restrictions, placeholders, flexible configuration
88
</p>
99

1010
<p align="center">
@@ -15,26 +15,28 @@ endpoint restrictions, placeholders, and flexible configuration.
1515
<a href="https://github.com/codeshelldev/secured-signal-api/releases">
1616
<img src="https://img.shields.io/github/v/release/codeshelldev/secured-signal-api?sort=semver&logo=github" alt="GitHub release">
1717
</a>
18+
<a href="https://github.com/codeshelldev/secured-signal-api/stargazers">
19+
<img src="https://img.shields.io/github/stars/codeshelldev/secured-signal-api?style=flat&logo=github" alt="GitHub stars">
20+
</a>
1821
<a href="https://github.com/codeshelldev/secured-signal-api/pkgs/container/secured-signal-api">
19-
<img src="https://ghcr-badge.egpl.dev/codeshelldev/secured-signal-api/size?color=%2344cc11&tag=latest&label=image+size&trim=" alt="GHCR pulls">
22+
<img src="https://ghcr-badge.egpl.dev/codeshelldev/secured-signal-api/size?color=%2344cc11&tag=latest&label=image+size&trim=" alt="Docker image size">
2023
</a>
2124
<a href="./LICENSE">
2225
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT">
2326
</a>
24-
<a href="https://github.com/codeshelldev/secured-signal-api/stargazers">
25-
<img src="https://img.shields.io/github/stars/codeshelldev/secured-signal-api?style=social" alt="GitHub stars">
26-
</a>
2727
</div>
2828

2929
## Contents
3030

3131
- [Getting Started](#getting-started)
3232
- [Setup](#setup)
3333
- [Usage](#usage)
34-
- [Best Practices](#security-best-practices)
34+
- [Best Practices](#best-practices)
3535
- [Configuration](#configuration)
3636
- [Endpoints](#endpoints)
3737
- [Variables](#variables)
38+
- [Data Aliases](#data-aliases)
39+
- [Message Templates](#message-templates)
3840
- [Contributing](#contributing)
3941
- [Support](#support)
4042
- [License](#license)
@@ -57,12 +59,30 @@ And add secure Token(s) to `api.tokens`. See [API TOKENs](#api-tokens).
5759
5860
### Reverse Proxy
5961

62+
#### Traefik
63+
6064
Take a look at the [traefik](https://github.com/traefik/traefik) implementation:
6165

6266
```yaml
63-
{ { file.examples/traefik.docker-compose.yaml } }
67+
{ { file.examples/reverse-proxy/traefik/traefik.docker-compose.yaml } }
68+
```
69+
70+
#### NGINX Proxy
71+
72+
This is the [NGINX](https://github.com/nginx/nginx) `docker-compose.yaml` file:
73+
74+
```yaml
75+
{ { file.examples/reverse-proxy/nginx/nginx.docker-compose.yaml } }
6476
```
6577

78+
Create a `nginx.conf` file in the `docker-compose.yaml` folder and mount it to `etc/nginx/conf.d/default.conf`:
79+
80+
```conf
81+
{ { file.examples/reverse-proxy/nginx/nginx.conf } }
82+
```
83+
84+
Lastly add your `cert.key` and `cert.crt` into your `certs/` folder and mount it to `/etc/nginx/ssl`.
85+
6686
## Setup
6787

6888
Before you can send messages via Secured Signal API you must first set up [Signal rAPI](https://github.com/bbernhard/signal-cli-rest-api/blob/master/doc/EXAMPLES.md)
@@ -101,31 +121,24 @@ curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer API_T
101121

102122
#### Placeholders
103123

104-
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).
124+
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.
105125

106-
These Placeholders can be used in the Request Query or the Body of a Request like so:
126+
You can use [**Variable**](#variables) `{{.NUMBER}}` Placeholders and **Body** Placeholders `{{@data.key}}`.
107127

108-
**Body**
128+
| Type | Example |
129+
| :---- | :--------------------------------------------------------------- |
130+
| Body | `{"number": "{{ .NUMBER }}", "recipients": "{{ .RECIPIENTS }}"}` |
131+
| Query | `http://sec-signal-api:8880/v1/receive/?@number={{.NUMBER}}` |
132+
| Path | `http://sec-signal-api:8880/v1/receive/{{.NUMBER}}` |
133+
134+
You can also combine them:
109135

110136
```json
111137
{
112-
"number": "{{ .NUMBER }}",
113-
"recipients": "{{ .RECIPIENTS }}"
138+
"content": "{{.NUMBER}} -> {{.RECIPIENTS}}"
114139
}
115140
```
116141

117-
**Query**
118-
119-
```
120-
http://sec-signal-api:8880/v1/receive/?@number={{.NUMBER}}
121-
```
122-
123-
**Path**
124-
125-
```
126-
http://sec-signal-api:8880/v1/receive/{{.NUMBER}}
127-
```
128-
129142
#### KeyValue Pair Injection
130143

131144
In some cases you may not be able to access / modify the Request Body, in that case specify needed values in the Request Query:
@@ -135,9 +148,9 @@ In some cases you may not be able to access / modify the Request Body, in that c
135148
In order to differentiate Injection Queries and _regular_ Queries
136149
you have to add `@` in front of any KeyValue Pair assignment.
137150

138-
Supported types include **strings**, **ints** and **arrays**. See [Formatting](#string-to-type).
151+
Supported types include **strings**, **ints**, **arrays** and **json dictionaries**. See [Formatting](#string-to-type).
139152

140-
## Security: Best Practices
153+
## Best Practices
141154

142155
- Always use API tokens in production
143156
- Run behind a TLS-enabled [Reverse Proxy](#reverse-proxy) (Traefik, Nginx, Caddy)
@@ -275,12 +288,27 @@ settings:
275288
recipients: ["+123400002", "group.id", "user.id"]
276289
```
277290

278-
### Message Aliases
291+
### Message Templates
292+
293+
To customize the `message` attribute you can use **Message Templates** to build your message by using other Body Keys and Variables.
294+
Use `messageTemplate` to configure:
295+
296+
```yaml
297+
settings:
298+
messageTemplate: |
299+
Your Message:
300+
{{@message}}.
301+
Sent with Secured Signal API.
302+
```
303+
304+
Use `{{@data.key}}` to reference Body Keys and `{{.KEY}}` for Variables.
305+
306+
### Data Aliases
279307

280-
To improve compatibility with other services Secured Signal API provides **Message Aliases** for the `message` attribute.
308+
To improve compatibility with other services Secured Signal API provides **Data Aliases** and a built-in `message` Alias.
281309

282310
<details>
283-
<summary><strong>Default Message Aliases</strong></summary>
311+
<summary><strong>Default `message` Aliases</strong></summary>
284312

285313
| Alias | Score | Alias | Score |
286314
| ------------ | ----- | ---------------- | ----- |
@@ -294,23 +322,27 @@ To improve compatibility with other services Secured Signal API provides **Messa
294322

295323
</details>
296324

297-
Secured Signal API will pick the best scoring Message Alias (if available) to extract the correct message from the Request Body.
325+
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.
298326

299-
Message Aliases can be added by setting `messageAliases` in your config:
327+
Data Aliases can be added by setting `dataAliases` in your config:
300328

301329
```yaml
302330
settings:
303-
messageAliases:
304-
[
305-
{ alias: "msg", score: 80 },
306-
{ alias: "data.message", score: 79 },
307-
{ alias: "array[0].message", score: 78 },
308-
]
331+
dataAliases:
332+
"@message":
333+
[
334+
{ alias: "msg", score: 80 },
335+
{ alias: "data.message", score: 79 },
336+
{ alias: "array[0].message", score: 78 },
337+
]
338+
".NUMBER": [{ alias: "phone_number", score: 100 }]
309339
```
310340

341+
Use `@` for aliasing Body Keys and `.` for aliasing Variables.
342+
311343
### Port
312344

313-
To change the Port which Secured Signal API uses, you need to set `server.port` in your config. (default: `8880`)
345+
To change the Port which Secured Signal API uses, you need to set `service.port` in your config. (default: `8880`)
314346

315347
### Log Level
316348

@@ -328,24 +360,32 @@ To change the Log Level set `logLevel` to: (default: `info`)
328360
| `fatal` |
329361
| `dev` |
330362

331-
</details>
363+
</details
332364

333365
## Contributing
334366

335367
Found a bug? Want to change or add something?
336-
Feel free to open up an issue or create a Pull Request!
368+
Feel free to open up an [Issue](https://github.com/codeshelldev/secured-signal-api/issues) or create a [Pull Request](https://github.com/codeshelldev/secured-signal-api/pulls)!
337369

338370
## Support
339371

340372
Has this Repo been helpful 👍️ to you? Then consider ⭐️'ing this Project.
341373

342374
:)
343375

376+
## Help
377+
378+
**Are you having Problems setting up Secured Signal API?**<br>
379+
No worries check out the [Discussions](https://github.com/codeshelldev/secured-signal-api/discussions) Tab and ask for help.
380+
381+
**We are all Volunteers**, so please be friendly and patient.
382+
344383
## License
345384

346385
[MIT](https://choosealicense.com/licenses/mit/)
347386

348-
### Legal
387+
## Legal
349388

350389
Logo designed by [@CodeShellDev](https://github.com/codeshelldev), All Rights Reserved.
390+
351391
This Project is not affiliated with the Signal Foundation.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
.env
2+
.git*/*
3+
!.github/*

Dockerfile

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

4-
ENV SERVER__PORT=8880
4+
ARG IMAGE_TAG
5+
ENV IMAGE_TAG=$IMAGE_TAG
6+
LABEL org.opencontainers.image.version=$IMAGE_TAG
57

6-
ENV DEFAULTS_PATH=/app/config/defaults.yml
8+
ENV SERVICE__PORT=8880
9+
10+
ENV DEFAULTS_PATH=/app/data/defaults.yml
11+
ENV FAVICON_PATH=/app/data/favicon.ico
712

813
ENV CONFIG_PATH=/config/config.yml
914
ENV TOKENS_DIR=/config/tokens
@@ -17,6 +22,4 @@ COPY . .
1722

1823
COPY dist/${TARGETOS}/${TARGETARCH}/app .
1924

20-
RUN ls
21-
2225
CMD ["./app"]

0 commit comments

Comments
 (0)