Skip to content

Commit 0eb791b

Browse files
committed
first commit
0 parents  commit 0eb791b

39 files changed

+4234
-0
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.gitignore
2+
.git
3+
.github
4+
.env
5+
docker-compose.yaml
6+
LICENSE
7+
*.md
8+
node_modules

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ""
5+
labels: bug
6+
assignees: ""
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**Receiver or Server?**
13+
Describe which component is affected.
14+
15+
**To Reproduce**
16+
Steps to reproduce the behavior:
17+
18+
1. Go to '...'
19+
2. Click on '....'
20+
3. Scroll down to '....'
21+
4. See error
22+
23+
**Expected behavior**
24+
A clear and concise description of what you expected to happen.
25+
26+
**Screenshots**
27+
If applicable, add screenshots to help explain your problem.
28+
29+
**Docker Logs**
30+
Add your Docker Logs here.
31+
32+
**Additional context**
33+
Add any other context about the problem here.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ""
5+
labels: enhancement
6+
assignees: ""
7+
---
8+
9+
**Is your feature request related to a problem? Please describe.**
10+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11+
12+
**Describe the solution you'd like**
13+
A clear and concise description of what you want to happen.
14+
15+
**Describe alternatives you've considered**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
**Additional context**
19+
Add any other context or screenshots about the feature request here.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# Usage: ./replace_placeholders.sh source_file destination_file
4+
5+
SOURCE_FILE="$1"
6+
DEST_FILE="$2"
7+
8+
# Check if source file exists
9+
if [[ ! -f "$SOURCE_FILE" ]]; then
10+
echo "Source file '$SOURCE_FILE' does not exist!"
11+
exit 1
12+
fi
13+
14+
# Read the entire source file into a variable
15+
content=$(<"$SOURCE_FILE")
16+
17+
# Extract unique placeholders: match { { file.xxx } } with arbitrary spaces
18+
placeholders=$(grep -oP '\{\s*{\s*file\.(.*)\s*}\s*}' "$SOURCE_FILE" | sed -E 's/\{\s*\{\s*file\.//;s/\s*\}\s*\}//' | sort -u)
19+
20+
for placeholder in $placeholders; do
21+
if [[ -f "$placeholder" ]]; then
22+
file_content=$(<"$placeholder")
23+
24+
# Escape special characters
25+
escaped_content=$(printf '%s' "$file_content" | perl -pe 's/([\\\/])/\\$1/g; s/\n/\\n/g;')
26+
escaped_placeholder=$(printf '%s' "$placeholder" | perl -pe 's/([\\\/])/\\$1/g; s/\n/\\n/g;')
27+
28+
content=$(printf '%s' "$content" | perl -pe "s/{\s*{\s*file\.${escaped_placeholder}\s*}\s*}/$escaped_content/g")
29+
else
30+
echo "Warning: File '$placeholder' not found, skipping."
31+
fi
32+
done
33+
34+
# Write to destination file
35+
printf '%b\n' "$content" > "$DEST_FILE"
36+
37+
echo "Replacements complete. Output written to '$DEST_FILE'."

.github/templates/README.template.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Mailauth
2+
3+
Mailauth is a Mailbox Manager which securily enables you too select between your Mailboxes and authenticate with your Mailserver, like [mailcow](https://github.com/mailcow/mailcow-dockerized)
4+
5+
## Getting Started
6+
7+
Get the latest version of the `docker-compose.yaml` file:
8+
9+
```yaml
10+
{ { file.docker-compose.yaml } }
11+
```
12+
13+
### Setup
14+
15+
Mailauth _currently_ works by modifying the `email` claim during Token Exchange and Userinfo,
16+
this means that you **will have to** use a IdP (take a look at [authentik](https://goauthentik.com)).
17+
18+
Create a `.env` file inside of you `docker-compose.yaml` directory and copy the template below
19+
20+
```dotenv
21+
{ { file.examples/config.env } }
22+
```
23+
24+
Now you need to setup a Oauth Authentication Method in your mailserver,
25+
but instead of using your IdP's endpoints you use:
26+
27+
- `/oauth/mail/authorize`
28+
- `/oauth/mail/token`
29+
- `/oauth/mail/userinfo`
30+
31+
And for the Redirect Uri set it to the one from your `.env` file.
32+
33+
Next create `init-mongo.js` in your working directory:
34+
35+
```js
36+
{ { file.examples/init-mongo.js } }
37+
```
38+
39+
### Reverse Proxy
40+
41+
When working with Oauth and Auth in general it is recommended to use secure connections,
42+
here you will see a Reverse Proxy implementation with traefik:
43+
44+
```yaml
45+
{ { file.examples/traefik.docker-compose.yaml } }
46+
```
47+
48+
## Usage
49+
50+
When authenticating via mailauth you get redirected to your actual IdP then to `/select`,
51+
where you will be able to select your mailbox, mailauth changes the `email` claim and now you're logged in.
52+
53+
## Contributing
54+
55+
## License
56+
57+
[MIT](https://choosealicense.com/licenses/mit/)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build & Push Dev Image
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
8+
env:
9+
USERNAME: ${{ github.repository_owner }}
10+
IMAGE_NAME: ${{ github.repository }}
11+
REGISTRY: ghcr.io
12+
13+
jobs:
14+
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

.github/workflows/docker-image.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build & Push Image
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
USERNAME: ${{ github.repository_owner }}
9+
IMAGE_NAME: ${{ github.repository }}
10+
REGISTRY: ghcr.io
11+
12+
jobs:
13+
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

.github/workflows/readme-update.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Update README
2+
3+
on:
4+
push:
5+
paths:
6+
- "docker-compose.yaml"
7+
- ".github/templates/README.template.md"
8+
9+
jobs:
10+
update-readme:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Replace File Placeholders in README
18+
run: |
19+
bash .github/helper-scripts/replace_placeholders.sh .github/templates/README.template.md README.md
20+
21+
- name: Commit & Push README.md
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
run: |
25+
git config user.name "github-actions[bot]"
26+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
27+
28+
git add README.md
29+
if git diff --cached --quiet; then
30+
echo "No changes to commit."
31+
else
32+
git commit -m "Update README.md"
33+
git push
34+
fi

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.env
2+
node_modules
3+
**/*.html
4+
!examples

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:latest
2+
3+
WORKDIR /app
4+
5+
COPY . .
6+
7+
RUN npm install
8+
9+
ENV PORT=80
10+
11+
EXPOSE 80
12+
13+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)