Skip to content

Commit 2d2d00d

Browse files
authored
Merge pull request #5 from CodeShellDev/main
Update Dev
2 parents 20c9f4a + f5b8b93 commit 2d2d00d

File tree

4 files changed

+51
-132
lines changed

4 files changed

+51
-132
lines changed

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

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,18 @@ on:
44
push:
55
branches:
66
- dev
7-
8-
env:
9-
USERNAME: ${{ github.repository_owner }}
10-
IMAGE_NAME: ${{ github.repository }}
11-
REGISTRY: ghcr.io
7+
paths-ignore:
8+
- ".**"
129

1310
jobs:
1411
update:
15-
runs-on: ubuntu-latest
16-
17-
steps:
18-
- name: Checkout Repository
19-
uses: actions/checkout@v4
20-
21-
- name: Login to Registry
22-
uses: docker/login-action@v3
23-
with:
24-
registry: ${{ env.REGISTRY }}
25-
username: ${{ env.USERNAME }}
26-
password: ${{ secrets.GH_PCKG_TOKEN }}
27-
28-
- name: Setup QEMU
29-
uses: docker/setup-qemu-action@v3
30-
31-
- name: Setup Buildx
32-
uses: docker/setup-buildx-action@v3
33-
34-
- name: Extract Labels and Tags
35-
id: meta
36-
uses: docker/metadata-action@v5
37-
with:
38-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
39-
flavor: |
40-
latest=false
41-
tags: |
42-
type=raw,value=latest-dev
43-
44-
- name: Build and Push Image
45-
uses: docker/build-push-action@v6
46-
with:
47-
context: .
48-
platforms: linux/amd64, linux/arm64
49-
tags: ${{ steps.meta.outputs.tags }}
50-
labels: ${{ steps.meta.outputs.labels }}
51-
push: true
12+
uses: codeshelldev/gh-actions/.github/workflows/docker-image.yml@main
13+
with:
14+
registry: ghcr.io
15+
flavor: |
16+
latest=false
17+
tags: |
18+
type=sha
19+
type=raw,value=latest-dev
20+
secrets:
21+
GH_PCKG_TOKEN: ${{ secrets.GH_PCKG_TOKEN }}

.github/workflows/docker-image.yml

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,10 @@ on:
44
release:
55
types: [published]
66

7-
env:
8-
USERNAME: ${{ github.repository_owner }}
9-
IMAGE_NAME: ${{ github.repository }}
10-
REGISTRY: ghcr.io
11-
127
jobs:
138
update:
14-
runs-on: ubuntu-latest
15-
16-
steps:
17-
- name: Checkout Repository
18-
uses: actions/checkout@v4
19-
20-
- name: Login to Registry
21-
uses: docker/login-action@v3
22-
with:
23-
registry: ${{ env.REGISTRY }}
24-
username: ${{ env.USERNAME }}
25-
password: ${{ secrets.GH_PCKG_TOKEN }}
26-
27-
- name: Setup QEMU
28-
uses: docker/setup-qemu-action@v3
29-
30-
- name: Setup Buildx
31-
uses: docker/setup-buildx-action@v3
32-
33-
- name: Extract Labels and Tags
34-
id: meta
35-
uses: docker/metadata-action@v5
36-
with:
37-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38-
flavor: |
39-
latest=false
40-
tags: |
41-
type=semver,pattern=v{{major}}
42-
type=semver,pattern=v{{version}}
43-
type=semver,pattern=v{{major}}.{{minor}}
44-
type=semver,pattern=latest
45-
46-
- name: Build and Push Image
47-
uses: docker/build-push-action@v6
48-
with:
49-
context: .
50-
platforms: linux/amd64, linux/arm64
51-
tags: ${{ steps.meta.outputs.tags }}
52-
labels: ${{ steps.meta.outputs.labels }}
53-
push: true
9+
uses: codeshelldev/gh-actions/.github/workflows/docker-image.yml@main
10+
with:
11+
registry: ghcr.io
12+
secrets:
13+
GH_PCKG_TOKEN: ${{ secrets.GH_PCKG_TOKEN }}

.github/workflows/readme-update.yml

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,11 @@ name: Update README
33
on:
44
push:
55
paths:
6-
- "docker-compose.yaml"
7-
- ".github/templates/README.template.md"
8-
- "examples/*"
6+
- docker-compose.yaml
7+
- .github/templates/README.template.md
98

109
jobs:
11-
update-readme:
12-
runs-on: ubuntu-latest
13-
14-
steps:
15-
- name: Checkout repository
16-
uses: actions/checkout@v4
17-
18-
- name: Replace File Placeholders in README
19-
run: |
20-
bash .github/helper-scripts/replace_placeholders.sh .github/templates/README.template.md README.md
21-
22-
- name: Commit & Push README.md
23-
env:
24-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25-
run: |
26-
git config user.name "github-actions[bot]"
27-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
28-
29-
git add README.md
30-
if git diff --cached --quiet; then
31-
echo "No changes to commit."
32-
else
33-
git commit -m "Update README.md"
34-
git push
35-
fi
10+
update:
11+
uses: codeshelldev/gh-actions/.github/workflows/readme-update.yml@main
12+
secrets:
13+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

app.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from flask import Flask, Response, request, jsonify, make_response
1+
from flask import Flask, Response, request, jsonify, make_response, g
22
import os
33
import json
44
import requests
55
import re
66
import base64
7-
import logging
8-
from urllib.parse import unquote
7+
import logging
8+
from urllib.parse import unquote, urlencode, parse_qs
99

1010
app = Flask("Secured Signal Api")
1111

@@ -72,33 +72,46 @@ def middlewares():
7272
infoLog(f"Client tried to access Blocked Endpoint [{blockedPath}]")
7373
return Response("Forbidden", 401)
7474

75+
query_string = request.query_string.decode()
76+
7577
if secure:
7678
auth_header = request.headers.get("Authorization", "")
7779

7880
if auth_header.startswith("Bearer "):
79-
token = auth_header.split(" ", 1)[1]
80-
81-
token = unquote(token)
81+
token = auth_header.split(" ", 1)[1]
82+
8283
if token != API_TOKEN:
8384
infoLog(f"Client failed Bearer Auth [token: {token}]")
84-
return UnauthorizedResponse()
85+
return UnauthorizedResponse()
8586
elif auth_header.startswith("Basic "):
8687
try:
8788
decoded = base64.b64decode(auth_header.split(" ", 1)[1]).decode()
88-
username, password = decoded.split(":", 1)
89-
90-
username = unquote(username)
91-
password = unquote(password)
89+
username, password = decoded.split(":", 1)
90+
9291
if username != "api" or password != API_TOKEN:
9392
infoLog(f"Client failed Basic Auth [user: {username}, pw:{password}]")
9493
return UnauthorizedResponse()
9594
except Exception as error:
9695
errorLog(f"Unexpected Error during Basic Auth: {error}")
9796
return UnauthorizedResponse()
97+
elif request.args.get("authorization", None):
98+
token = request.args.get("authorization", "")
99+
100+
token = unquote(token)
101+
102+
if token != API_TOKEN:
103+
infoLog(f"Client failed Query Auth [query: {token}]")
104+
return UnauthorizedResponse()
105+
106+
args = parse_qs(query_string)
107+
108+
args.pop('authorization', None)
109+
query_string = urlencode(args, doseq=True)
98110
else:
99111
infoLog(f"Client did not provide any Auth Method")
100112
return UnauthorizedResponse(True)
101-
113+
114+
g.query_string = query_string
102115

103116
@app.route('/', defaults={'path': ''}, methods=['GET', 'POST', 'PUT'])
104117
@app.route('/<path:path>', methods=['GET', 'POST', 'PUT'])
@@ -114,15 +127,13 @@ def proxy(path):
114127
if "${NUMBER}" in path:
115128
path = path.replace("${NUMBER}", SENDER)
116129

117-
query_string = request.query_string.decode()
130+
query_string = g.query_string
118131

119-
if request.query_string.decode():
120-
query_string= "?" + request.query_string.decode()
132+
if query_string:
133+
query_string = "?" + query_string
121134

122135
targetURL = f"{SIGNAL_API_URL}/{path}{query_string}"
123136

124-
infoLog(json.dumps(jsonData))
125-
126137
resp = requests.request(
127138
method=method,
128139
url=targetURL,

0 commit comments

Comments
 (0)