Skip to content

Commit f0dd1c2

Browse files
authored
refactor: use binary and randomize credentials in tinyauth (#4632)
1 parent 951782d commit f0dd1c2

File tree

3 files changed

+57
-68
lines changed

3 files changed

+57
-68
lines changed

ct/alpine-tinyauth.sh

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env bash
22
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
33
# Copyright (c) 2021-2025 community-scripts ORG
4-
# Author: Slaviša Arežina (tremor021)
4+
# Author: Slaviša Arežina (tremor021) | Co-Author: Stavros (steveiliop56)
55
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
66
# Source: https://github.com/steveiliop56/tinyauth
77

8-
APP="Alpine-tinyauth"
8+
APP="Alpine-Tinyauth"
99
var_tags="${var_tags:-alpine;auth}"
1010
var_cpu="${var_cpu:-1}"
11-
var_ram="${var_ram:-512}"
12-
var_disk="${var_disk:-3}"
11+
var_ram="${var_ram:-256}"
12+
var_disk="${var_disk:-2}"
1313
var_os="${var_os:-alpine}"
1414
var_version="${var_version:-3.21}"
1515
var_unprivileged="${var_unprivileged:-1}"
@@ -25,34 +25,23 @@ function update_script() {
2525
exit 1
2626
fi
2727

28-
msg_info "Updating Alpine Packages"
28+
msg_info "Updating packages"
2929
$STD apk -U upgrade
30-
msg_ok "Updated Alpine Packages"
30+
msg_ok "Updated packages"
3131

32-
msg_info "Updating tinyauth"
32+
msg_info "Updating Tinyauth"
3333
RELEASE=$(curl -s https://api.github.com/repos/steveiliop56/tinyauth/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
34+
3435
if [ "${RELEASE}" != "$(cat /opt/tinyauth_version.txt)" ] || [ ! -f /opt/tinyauth_version.txt ]; then
3536
$STD service tinyauth stop
36-
temp_file=$(mktemp)
37-
cp /opt/tinyauth/.env /opt
38-
rm -rf /opt/tinyauth
39-
mkdir -p /opt/tinyauth
40-
curl -fsSL "https://github.com/steveiliop56/tinyauth/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
41-
tar -xzf "$temp_file" -C /opt/tinyauth --strip-components=1
42-
cd /opt/tinyauth/frontend
43-
$STD bun install
44-
$STD bun run build
45-
mv dist /opt/tinyauth/internal/assets/
46-
cd /opt/tinyauth
47-
$STD go mod download
48-
CGO_ENABLED=0 go build -ldflags "-s -w"
49-
cp /opt/.env /opt/tinyauth
50-
echo "${RELEASE}" >/opt/tinyauth_version.txt
51-
rm -f "$temp_file"
52-
msg_info "Restarting tinyauth"
37+
rm -f /opt/tinyauth/tinyauth
38+
curl -fsSL "https://github.com/steveiliop56/tinyauth/releases/download/v${RELEASE}/tinyauth-amd64" -o /opt/tinyauth/tinyauth
39+
chmod +x /opt/tinyauth/tinyauth
40+
echo "${RELEASE}" > /opt/tinyauth_version.txt
41+
msg_info "Restarting Tinyauth"
5342
$STD service tinyauth start
54-
msg_ok "Restarted tinyauth"
55-
msg_ok "Updated tinyauth"
43+
msg_ok "Restarted Tinyauth"
44+
msg_ok "Updated Tinyauth"
5645
else
5746
msg_ok "No update required. ${APP} is already at ${RELEASE}"
5847
fi
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Alpine-tinyauth",
2+
"name": "Alpine-Tinyauth",
33
"slug": "alpine-tinyauth",
44
"categories": [
55
6
@@ -9,19 +9,19 @@
99
"updateable": true,
1010
"privileged": false,
1111
"interface_port": 3000,
12-
"documentation": "https://tinyauth.app/docs/getting-started.html",
13-
"website": "https://tinyauth.app/",
14-
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/tinyauth.webp",
12+
"documentation": "https://tinyauth.app",
1513
"config_path": "/opt/tinyauth/.env",
16-
"description": "Tinyauth is a simple authentication middleware that adds simple username/password login or OAuth with Google, Github and any generic provider to all of your docker apps. It is designed for traefik but it can be extended to work with all reverse proxies like caddy and nginx.",
14+
"website": "https://tinyauth.app",
15+
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/tinyauth.webp",
16+
"description": "Tinyauth is a simple authentication middleware that adds simple username/password login or OAuth with Google, Github and any generic provider to all of your docker apps.",
1717
"install_methods": [
1818
{
1919
"type": "default",
2020
"script": "ct/alpine-tinyauth.sh",
2121
"resources": {
2222
"cpu": 1,
2323
"ram": 256,
24-
"hdd": 3,
24+
"hdd": 2,
2525
"os": "alpine",
2626
"version": "3.21"
2727
}
@@ -32,7 +32,7 @@
3232
"resources": {
3333
"cpu": 1,
3434
"ram": 256,
35-
"hdd": 3,
35+
"hdd": 2,
3636
"os": "alpine",
3737
"version": "3.21"
3838
}
@@ -44,8 +44,8 @@
4444
},
4545
"notes": [
4646
{
47-
"type": "info",
48-
"text": "`cat ~/tinyauth.creds` to view login credentials"
47+
"text": "The default credentials are located in `/opt/tinyauth/credentials.txt`.",
48+
"type": "info"
4949
}
5050
]
5151
}

install/alpine-tinyauth-install.sh

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
# Copyright (c) 2021-2025 community-scripts ORG
4-
# Author: Slaviša Arežina (tremor021)
4+
# Author: Slaviša Arežina (tremor021) | Co-Author: Stavros (steveiliop56)
55
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
66
# Source: https://github.com/steveiliop56/tinyauth
77

@@ -14,44 +14,44 @@ network_check
1414
update_os
1515

1616
msg_info "Installing Dependencies"
17-
$STD apk add --no-cache \
18-
npm \
19-
go
17+
$STD apk add --no-cache curl openssl apache2-utils
2018
msg_ok "Installed Dependencies"
2119

22-
msg_info "Installing tinyauth"
23-
temp_file=$(mktemp)
24-
$STD npm install -g bun
20+
msg_info "Installing Tinyauth"
2521
mkdir -p /opt/tinyauth
22+
2623
RELEASE=$(curl -s https://api.github.com/repos/steveiliop56/tinyauth/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
27-
curl -fsSL "https://github.com/steveiliop56/tinyauth/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
28-
tar -xzf "$temp_file" -C /opt/tinyauth --strip-components=1
29-
cd /opt/tinyauth/frontend
30-
$STD bun install
31-
$STD bun run build
32-
mv dist /opt/tinyauth/internal/assets/
33-
cd /opt/tinyauth
34-
$STD go mod download
35-
CGO_ENABLED=0 go build -ldflags "-s -w"
36-
{
37-
echo "tinyauth Credentials"
38-
echo "Username: [email protected]"
39-
echo "Password: admin"
40-
} >>~/tinyauth.creds
24+
curl -fsSL "https://github.com/steveiliop56/tinyauth/releases/download/v${RELEASE}/tinyauth-amd64" -o /opt/tinyauth/tinyauth
25+
chmod +x /opt/tinyauth/tinyauth
26+
27+
PASSWORD=$(openssl rand -base64 8 | tr -dc 'a-zA-Z0-9' | head -c 8)
28+
USER=$(htpasswd -Bbn "tinyauth" "${PASSWORD}")
29+
30+
cat <<EOF > /opt/tinyauth/credentials.txt
31+
Tinyauth Credentials
32+
Username: tinyauth
33+
Password: ${PASSWORD}
34+
EOF
35+
4136
echo "${RELEASE}" >/opt/tinyauth_version.txt
42-
msg_ok "Installed tinyauth"
37+
msg_ok "Installed Tinyauth"
38+
39+
read -p "${TAB3}Enter your Tinyauth subdomain (e.g. https://tinyauth.example.com): " app_url
40+
41+
msg_info "Creating Tinyauth Service"
42+
SECRET=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | head -c 32)
43+
44+
cat <<EOF >/opt/tinyauth/.env
45+
SECRET=${SECRET}
46+
USERS=${USER}
47+
APP_URL=${app_url}
48+
EOF
4349

44-
msg_info "Enabling tinyauth Service"
45-
SECRET=$(head -c 16 /dev/urandom | xxd -p -c 16 | tr -d '\n')
46-
{
47-
echo "SECRET=${SECRET}"
48-
echo "[email protected]:\$2a\$10\$CrTK.W7WXSClo3ZY1yJUFupg5UdV8WNcynEhZhJFNjhGQB.Ga0ZDm"
49-
echo "APP_URL=http://localhost:3000"
50-
} >>/opt/tinyauth/.env
50+
sed -i -e 's/\$/\$\$/g' /opt/tinyauth/.env
5151

5252
cat <<EOF >/etc/init.d/tinyauth
5353
#!/sbin/openrc-run
54-
description="tinyauth Service"
54+
description="Tinyauth Service"
5555
5656
command="/opt/tinyauth/tinyauth"
5757
directory="/opt/tinyauth"
@@ -72,11 +72,11 @@ EOF
7272

7373
chmod +x /etc/init.d/tinyauth
7474
$STD rc-update add tinyauth default
75-
msg_ok "Enabled tinyauth Service"
75+
msg_ok "Enabled Tinyauth Service"
7676

77-
msg_info "Starting tinyauth"
77+
msg_info "Starting Tinyauth"
7878
$STD service tinyauth start
79-
msg_ok "Started tinyauth"
79+
msg_ok "Started Tinyauth"
8080

8181
motd_ssh
8282
customize

0 commit comments

Comments
 (0)