Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2d2d00d
Merge pull request #5 from CodeShellDev/main
CodeShellDev Jun 22, 2025
2f7836c
Merge pull request #6 from CodeShellDev/main
CodeShellDev Jun 24, 2025
988c5aa
Merge pull request #7 from CodeShellDev/main
CodeShellDev Jun 26, 2025
7ff6e5d
fix dockerfile
CodeShellDev Jun 26, 2025
2506feb
testing dockerfile
CodeShellDev Jun 26, 2025
765386b
updated Dockerfile
CodeShellDev Jun 26, 2025
c2be725
testing
CodeShellDev Jun 26, 2025
7741d10
fix dockerfile?
CodeShellDev Jun 26, 2025
6b96f22
testing
CodeShellDev Jun 26, 2025
c478c7b
added ARG for TARGETOS and TARGETARCH
CodeShellDev Jun 26, 2025
49e89d5
moved ARG like in docker docs
CodeShellDev Jun 26, 2025
2604958
added more debug logs
CodeShellDev Jun 26, 2025
e692224
fixed main() calling log.Init() twice
CodeShellDev Jun 26, 2025
8a86a4f
where's the binary?
CodeShellDev Jun 26, 2025
801c0ce
added missing default PORT ENV in Dockerfile
CodeShellDev Jun 26, 2025
fd49bcf
return Auth Required Headers
CodeShellDev Jun 26, 2025
22013cd
update `Content-Length` to match `req.Body` length
CodeShellDev Jun 26, 2025
c4ec34e
add key-value Pairs to Body by using `@key=value` in the req Query. Q…
CodeShellDev Jun 26, 2025
2afcd2e
remove query params with `@` after successful injection into JSON Body
CodeShellDev Jun 26, 2025
547467d
debug
CodeShellDev Jun 26, 2025
64aee27
debugging auth middleware
CodeShellDev Jun 26, 2025
c22d1f7
fixed middleware chain order
CodeShellDev Jun 26, 2025
a71747e
add templating debug logs
CodeShellDev Jun 27, 2025
eb474d6
fix: update Content-Length calculation in TemplatingMiddleware
CodeShellDev Jun 27, 2025
a046fe8
added further debugging for Body templating
CodeShellDev Jun 27, 2025
c94f86d
added type detection for query variables
CodeShellDev Jun 27, 2025
fdb0867
refactored type detection for query
CodeShellDev Jun 27, 2025
feecd9d
added new EVN `VARIABLES` which can be used to set custom data, which…
CodeShellDev Jun 27, 2025
526f056
handle empty API TOKEN
CodeShellDev Jun 27, 2025
7c3fc58
update README for new Release
CodeShellDev Jun 27, 2025
dcf0663
Update README.md
github-actions[bot] Jun 27, 2025
656b5f1
added missing variable in ENV
CodeShellDev Jun 27, 2025
956ba2a
Merge branch 'dev' of https://github.com/CodeShellDev/secured-signal-…
CodeShellDev Jun 27, 2025
52ba21a
Update README.md
github-actions[bot] Jun 27, 2025
4c9b5ed
updated README for upcoming fix
CodeShellDev Jun 27, 2025
5a4f396
Merge branch 'dev' of https://github.com/CodeShellDev/secured-signal-…
CodeShellDev Jun 27, 2025
84ae547
Update README.md
github-actions[bot] Jun 27, 2025
78d86b5
[TODO] Escape Array Strings in JSON
CodeShellDev Jun 27, 2025
235600b
Merge branch 'dev' of https://github.com/CodeShellDev/secured-signal-…
CodeShellDev Jun 27, 2025
b02d846
- refactored `utils`
CodeShellDev Jun 28, 2025
12c46be
fixing JSON templating
CodeShellDev Jun 28, 2025
5972c44
removed panic and added debug
CodeShellDev Jun 28, 2025
44e89a2
debugging error
CodeShellDev Jun 28, 2025
956a0ea
testing changes
CodeShellDev Jun 28, 2025
2fa273b
fix panic error
CodeShellDev Jun 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 126 additions & 19 deletions .github/templates/README.template.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Secured Signal Api

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

## Installation

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

And set `API_TOKEN` to a long secure string

```yaml
{ { file.docker-compose.yaml } }
```
Expand All @@ -24,44 +26,149 @@ Before you can send messages via `secured-signal-api` you must first setup [`sig

to send messages you have to either:

- register a Signal Account
- **register a Signal Account**

OR

- link Signal Api to a already registered Signal Device
- **link Signal API to an already registered Signal Device**

## Usage

Secured Signal API implements 3 Ways to Authenticate

### Bearer

To Authenticate with `secured-signal-api` add `Authorization: Bearer TOKEN` to your request Headers

### Basic Auth

To use Basic Auth as Authorization Method add `Authorization: Basic base64{user:pw}` to your Headers

### Query Auth

If you are working with a limited Application you may **not** be able to modify Headers or the Request Body
in this case you should use **Query Auth**.

Here is a simple example:

```bash
curl -X POST http://signal-api:8880/v2/send?@authorization=TOKEN
```

To send a message to `number`: `1234567`:

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

### Configuration

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:

```python
DEFAULT_BLOCKED_ENDPOINTS = [
"/v1/about",
"/v1/configuration",
"/v1/devices",
"/v1/register",
"/v1/unregister",
"/v1/qrcodelink",
"/v1/accounts",
"/v1/contacts"
]
### Advanced

#### Placeholders

If you are not comfortable with hardcoding your Number and/or Recipients in you may use **Placeholders** in your request like:

`{{ .NUMBER }}` or `{{ .RECIPIENTS }}`

These _Placeholders_ can be used in the Query or the Body of a Request like so:

**Body**

```json
{
"number": "{{ .NUMBER }}",
"recipients": "{{ .RECIPIENTS }}"
}
```

**Query**

```
http://.../?@number={{.NUMBER}}
```

**Path**

```
http://signal-api:8880/v1/receive/{{.NUMBER}}
```

#### KeyValue Pair Injection

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:

```
http://signal-api:8880/?@key=value
```

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
**Format**
In order to differentiate Injection Queries and _regular_ Queries
you have to add `@` in front of any KeyValue Pair assignment

### Environment Variables

#### API Token

> [!IMPORTANT]
> It is highly recommended to set this Environment Variable to a long secure string

_What if I just don't?_

Well Secured Signal API will still work, but important Security Features won't be available
like Blocked Endpoints and anyone with access to your Docker Container will be able to send Messages in your Name

> [!NOTE]
> Blocked Endpoints can be reactivated by manually setting them in the environment

#### Blocked Endpoints

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:

- **/v1/about**

- **/v1/configuration**

- **/v1/devices**

- **/v1/register**

- **/v1/unregister**

- **/v1/qrcodelink**

- **/v1/accounts**

- **/v1/contacts**

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

```yaml
environment:
BLOCKED_ENDPOINTS: '[ "/v1/register","/v1/unregister","/v1/qrcodelink","/v1/contacts" ]'
```

#### Variables

By default Secured Signal API provides the following **Placeholders**:

- **NUMBER** = _ENV_: `SENDER`
- **RECIPIENTS** = _ENV_: `DEFAULT_RECIPIENTS`

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

```yaml
environment:
VARIABLES: ' "NUMBER2": "002", "GROUP_CHAT_1": [ "user.id", "000", "001", "group.id" ] '
```

#### Default Recipients

Set this environment variable to automatically provide default Recipients:

```yaml
environment:
DEFAULT_RECIPIENTS: ' [ "user.id", "000", "001", "group.id" ] '
```

## Contributing

Found a bug? Want to change or add something?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-image-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
update:
uses: codeshelldev/gh-actions/.github/workflows/docker-image.yml@main
uses: codeshelldev/gh-actions/.github/workflows/docker-image-go.yml@main
with:
registry: ghcr.io
flavor: |
Expand Down
20 changes: 9 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
FROM golang:1.24
FROM alpine:latest
RUN apk --no-cache add ca-certificates

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download
ENV PORT=8880

COPY *.go ./
ARG TARGETOS
ARG TARGETARCH

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

ENV PORT=8880
COPY dist/${TARGETOS}/${TARGETARCH}/app .

EXPOSE ${PORT}
RUN ls

CMD ["/secured-signal-api"]
CMD ["./app"]
Loading