Skip to content

Commit 79c1a33

Browse files
authored
Merge pull request #8 from CodeShellDev/dev
Update Main Branch for Release
2 parents 9e4bc48 + 2fa273b commit 79c1a33

File tree

10 files changed

+521
-109
lines changed

10 files changed

+521
-109
lines changed

.github/templates/README.template.md

Lines changed: 126 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Secured Signal Api
22

3-
Secured Signal Api acts as a secured proxy for signal-rest-api.
3+
Secured Signal Api acts as a secure proxy for signal-rest-api.
44

55
## Installation
66

77
Get the latest version of the `docker-compose.yaml` file:
88

9+
And set `API_TOKEN` to a long secure string
10+
911
```yaml
1012
{ { file.docker-compose.yaml } }
1113
```
@@ -24,44 +26,149 @@ Before you can send messages via `secured-signal-api` you must first setup [`sig
2426

2527
to send messages you have to either:
2628

27-
- register a Signal Account
29+
- **register a Signal Account**
2830

2931
OR
3032

31-
- link Signal Api to a already registered Signal Device
33+
- **link Signal API to an already registered Signal Device**
3234

3335
## Usage
3436

37+
Secured Signal API implements 3 Ways to Authenticate
38+
39+
### Bearer
40+
41+
To Authenticate with `secured-signal-api` add `Authorization: Bearer TOKEN` to your request Headers
42+
43+
### Basic Auth
44+
45+
To use Basic Auth as Authorization Method add `Authorization: Basic base64{user:pw}` to your Headers
46+
47+
### Query Auth
48+
49+
If you are working with a limited Application you may **not** be able to modify Headers or the Request Body
50+
in this case you should use **Query Auth**.
51+
52+
Here is a simple example:
53+
54+
```bash
55+
curl -X POST http://signal-api:8880/v2/send?@authorization=TOKEN
56+
```
57+
3558
To send a message to `number`: `1234567`:
3659

3760
```bash
3861
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer TOKEN" -d '{"message": "Hello World!", "recipients": ["1234567"]}' http://signal-api:8880/v2/send
3962
```
4063

41-
### Configuration
42-
43-
Because `secured-signal-api` is just a secure proxy you can use all of the [Signal REST Api](https://github.com/bbernhard/signal-cli-rest-api/blob/master/doc/EXAMPLES.md) endpoints with an Exception of:
44-
45-
```python
46-
DEFAULT_BLOCKED_ENDPOINTS = [
47-
"/v1/about",
48-
"/v1/configuration",
49-
"/v1/devices",
50-
"/v1/register",
51-
"/v1/unregister",
52-
"/v1/qrcodelink",
53-
"/v1/accounts",
54-
"/v1/contacts"
55-
]
64+
### Advanced
65+
66+
#### Placeholders
67+
68+
If you are not comfortable with hardcoding your Number and/or Recipients in you may use **Placeholders** in your request like:
69+
70+
`{{ .NUMBER }}` or `{{ .RECIPIENTS }}`
71+
72+
These _Placeholders_ can be used in the Query or the Body of a Request like so:
73+
74+
**Body**
75+
76+
```json
77+
{
78+
"number": "{{ .NUMBER }}",
79+
"recipients": "{{ .RECIPIENTS }}"
80+
}
81+
```
82+
83+
**Query**
84+
85+
```
86+
http://.../?@number={{.NUMBER}}
87+
```
88+
89+
**Path**
90+
91+
```
92+
http://signal-api:8880/v1/receive/{{.NUMBER}}
93+
```
94+
95+
#### KeyValue Pair Injection
96+
97+
In some cases you may not be able to access / modify the Request Body, if that is the case specify needed values in the Requests Query:
98+
99+
```
100+
http://signal-api:8880/?@key=value
56101
```
57102

58-
Which are blocked by default to increase Security, but you these can be modified by setting the `BLOCKED_ENDPOINTS` environment variable as a valid json array
103+
**Format**
104+
In order to differentiate Injection Queries and _regular_ Queries
105+
you have to add `@` in front of any KeyValue Pair assignment
106+
107+
### Environment Variables
108+
109+
#### API Token
110+
111+
> [!IMPORTANT]
112+
> It is highly recommended to set this Environment Variable to a long secure string
113+
114+
_What if I just don't?_
115+
116+
Well Secured Signal API will still work, but important Security Features won't be available
117+
like Blocked Endpoints and anyone with access to your Docker Container will be able to send Messages in your Name
118+
119+
> [!NOTE]
120+
> Blocked Endpoints can be reactivated by manually setting them in the environment
121+
122+
#### Blocked Endpoints
123+
124+
Because Secured Signal API is just a secure Proxy you can use all of the [Signal REST API](https://github.com/bbernhard/signal-cli-rest-api/blob/master/doc/EXAMPLES.md) endpoints with an Exception of:
125+
126+
- **/v1/about**
127+
128+
- **/v1/configuration**
129+
130+
- **/v1/devices**
131+
132+
- **/v1/register**
133+
134+
- **/v1/unregister**
135+
136+
- **/v1/qrcodelink**
137+
138+
- **/v1/accounts**
139+
140+
- **/v1/contacts**
141+
142+
These Endpoints are blocked by default to Security Risks, but can be modified by setting `BLOCKED_ENDPOINTS` in the environment variable to a valid json array string
59143

60144
```yaml
61145
environment:
62146
BLOCKED_ENDPOINTS: '[ "/v1/register","/v1/unregister","/v1/qrcodelink","/v1/contacts" ]'
63147
```
64148
149+
#### Variables
150+
151+
By default Secured Signal API provides the following **Placeholders**:
152+
153+
- **NUMBER** = _ENV_: `SENDER`
154+
- **RECIPIENTS** = _ENV_: `DEFAULT_RECIPIENTS`
155+
156+
If you are ever missing any **Placeholder** (that isn't built-in) you can add as many as you like to `VARIABLES` inside your environment
157+
158+
```yaml
159+
environment:
160+
VARIABLES: ' "NUMBER2": "002", "GROUP_CHAT_1": [ "user.id", "000", "001", "group.id" ] '
161+
```
162+
163+
#### Default Recipients
164+
165+
Set this environment variable to automatically provide default Recipients:
166+
167+
```yaml
168+
environment:
169+
DEFAULT_RECIPIENTS: ' [ "user.id", "000", "001", "group.id" ] '
170+
```
171+
65172
## Contributing
66173

67174
Found a bug? Want to change or add something?

.github/workflows/docker-image-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
update:
12-
uses: codeshelldev/gh-actions/.github/workflows/docker-image.yml@main
12+
uses: codeshelldev/gh-actions/.github/workflows/docker-image-go.yml@main
1313
with:
1414
registry: ghcr.io
1515
flavor: |

Dockerfile

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
FROM golang:1.24
1+
FROM alpine:latest
2+
RUN apk --no-cache add ca-certificates
23

3-
WORKDIR /app
4-
5-
COPY go.mod go.sum ./
6-
7-
RUN go mod download
4+
ENV PORT=8880
85

9-
COPY *.go ./
6+
ARG TARGETOS
7+
ARG TARGETARCH
108

11-
RUN CGO_ENABLED=0 GOOS=linux go build -o /secured-signal-api
9+
WORKDIR /app
1210

13-
ENV PORT=8880
11+
COPY dist/${TARGETOS}/${TARGETARCH}/app .
1412

15-
EXPOSE ${PORT}
13+
RUN ls
1614

17-
CMD ["/secured-signal-api"]
15+
CMD ["./app"]

0 commit comments

Comments
 (0)