chore: rename plugin to mx autologin

This commit is contained in:
Marek Miklewicz
2026-06-30 20:33:54 +02:00
parent 4a1c9d0db4
commit bb6a01fdca
17 changed files with 55 additions and 41 deletions
+3 -3
View File
@@ -71,7 +71,7 @@ final class Http
return '<!doctype html><html lang="pl"><head><meta charset="utf-8">'
. '<meta name="viewport" content="width=device-width, initial-scale=1">'
. '<meta http-equiv="refresh" content="0;url=' . $safeUrl . '">'
. '<title>Serwer poczty</title></head><body>'
. '<title>Zaloguj do serwera poczty</title></head><body>'
. '<script>(function(){var target=' . $jsonUrl . ';'
. 'try{if(window.top){window.top.location.replace(target);return;}}catch(e){}'
. 'window.location.replace(target);}());</script>'
@@ -84,8 +84,8 @@ final class Http
$safe = htmlspecialchars($message, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
$body = '<!doctype html><html lang="pl"><head><meta charset="utf-8">'
. '<meta name="viewport" content="width=device-width, initial-scale=1">'
. '<title>Serwer poczty</title></head><body>'
. '<h1>Serwer poczty</h1><p>' . $safe . '</p>'
. '<title>Zaloguj do serwera poczty</title></head><body>'
. '<h1>Zaloguj do serwera poczty</h1><p>' . $safe . '</p>'
. '</body></html>';
self::sendResponse($status, [
'Content-Type' => 'text/html; charset=UTF-8',
+2 -2
View File
@@ -3,8 +3,8 @@ declare(strict_types=1);
final class Settings
{
public const BASE_DIR = '/usr/local/hitme_plugins/mail-login';
public const PLUGIN_DIR = '/usr/local/directadmin/plugins/mail-login';
public const BASE_DIR = '/usr/local/hitme_plugins/mx_autologin';
public const PLUGIN_DIR = '/usr/local/directadmin/plugins/mx_autologin';
public const SECRET_DIR = self::BASE_DIR . '/secrets';
public const LOG_DIR = self::BASE_DIR . '/logs';
public const STATE_DIR = self::BASE_DIR . '/state';
+1 -1
View File
@@ -1 +1 @@
<a href="/CMD_PLUGINS/mail-login/login.raw" target="_top"><img src="/CMD_PLUGINS/mail-login/images/user_icon.svg" width="16" height="16" alt="Serwer poczty"/></a>
<a href="/CMD_PLUGINS/mx_autologin/login.raw" target="_top"><img src="/CMD_PLUGINS/mx_autologin/images/user_icon.svg" width="16" height="16" alt="Zaloguj do serwera poczty"/></a>
+1 -1
View File
@@ -1 +1 @@
<a href="/CMD_PLUGINS/mail-login/login.raw" target="_top">Serwer poczty</a>
<a href="/CMD_PLUGINS/mx_autologin/login.raw" target="_top">Zaloguj do serwera poczty</a>
+1 -1
View File
@@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="img" aria-label="Serwer poczty">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="img" aria-label="Zaloguj do serwera poczty">
<rect x="2" y="5" width="20" height="14" rx="2" fill="#14532d"/>
<path d="M4 7l8 6 8-6" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M7 16h10" fill="none" stroke="#bbf7d0" stroke-width="2" stroke-linecap="round"/>

Before

Width:  |  Height:  |  Size: 408 B

After

Width:  |  Height:  |  Size: 420 B

+3 -3
View File
@@ -1,6 +1,6 @@
# Ten plik jest runtime configuration pluginu.
# Plugin czyta ustawienia bezpośrednio z:
# /usr/local/directadmin/plugins/mail-login/plugin-settings.conf
# /usr/local/directadmin/plugins/mx_autologin/plugin-settings.conf
# Czy plugin jest domyślnie dostępny dla wszystkich użytkowników.
DEFAULT_ENABLE=true
@@ -42,8 +42,8 @@ MAIL_LOGIN_REMOTE_TRANSPORT=ssh
MAIL_LOGIN_SSH_HOST=mx1.mojserwer.pl
MAIL_LOGIN_SSH_PORT=22
MAIL_LOGIN_SSH_USER=root
MAIL_LOGIN_SSH_IDENTITY=/usr/local/hitme_plugins/mail-login/secrets/mx1_ed25519
MAIL_LOGIN_SSH_KNOWN_HOSTS=/usr/local/hitme_plugins/mail-login/secrets/known_hosts
MAIL_LOGIN_SSH_IDENTITY=/usr/local/hitme_plugins/mx_autologin/secrets/mx1_ed25519
MAIL_LOGIN_SSH_KNOWN_HOSTS=/usr/local/hitme_plugins/mx_autologin/secrets/known_hosts
MAIL_LOGIN_CONNECT_TIMEOUT_SECONDS=5
# Limity bezpieczeństwa na źródłowym serwerze DirectAdmin.
+3 -3
View File
@@ -1,8 +1,8 @@
name=mail-login
id=mail-login
name=MX-Autologin
id=mx_autologin
type=user
author=HITME.PL
version=1.0.12
version=1.0.13
active=no
installed=no
user_run_as=root
+3 -3
View File
@@ -1,8 +1,8 @@
#!/bin/sh
set -eu
BASE_DIR="/usr/local/hitme_plugins/mail-login"
PLUGIN_DIR="/usr/local/directadmin/plugins/mail-login"
BASE_DIR="/usr/local/hitme_plugins/mx_autologin"
PLUGIN_DIR="/usr/local/directadmin/plugins/mx_autologin"
mkdir -p "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state/rate-limit"
chmod 700 "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state" "$BASE_DIR/state/rate-limit"
@@ -14,4 +14,4 @@ fi
touch "$BASE_DIR/logs/audit.log"
chmod 600 "$BASE_DIR/logs/audit.log"
echo "mail-login installed; configuration is read from $PLUGIN_DIR/plugin-settings.conf"
echo "MX-Autologin installed; configuration is read from $PLUGIN_DIR/plugin-settings.conf"
+4 -4
View File
@@ -1,11 +1,11 @@
#!/bin/sh
set -eu
KEY_DIR="${MAIL_LOGIN_KEY_DIR:-/usr/local/hitme_plugins/mail-login/secrets}"
KEY_DIR="${MAIL_LOGIN_KEY_DIR:-/usr/local/hitme_plugins/mx_autologin/secrets}"
KEY_NAME="${MAIL_LOGIN_KEY_NAME:-mx1_ed25519}"
KEY_PATH="$KEY_DIR/$KEY_NAME"
MX_MODE="${MX_LOGIN_MODE:-1}"
SETTINGS_FILE="${MAIL_LOGIN_SETTINGS_FILE:-/usr/local/directadmin/plugins/mail-login/plugin-settings.conf}"
SETTINGS_FILE="${MAIL_LOGIN_SETTINGS_FILE:-/usr/local/directadmin/plugins/mx_autologin/plugin-settings.conf}"
HELPER_COMMAND="${MAIL_LOGIN_HELPER_COMMAND:-/usr/local/hitme_plugins/mail-login-helper/bin/create-login-url}"
config_value() {
@@ -154,7 +154,7 @@ chmod 700 "$KEY_DIR"
if [ ! -f "$KEY_PATH" ]; then
umask 077
ssh-keygen -q -t ed25519 -a 100 -N "" -f "$KEY_PATH" -C "KLUCZ PLUGINU mail-autologin DLA SERWERA $SERVER_LABEL"
ssh-keygen -q -t ed25519 -a 100 -N "" -f "$KEY_PATH" -C "KLUCZ PLUGINU MX-Autologin DLA SERWERA $SERVER_LABEL"
fi
if [ ! -f "$KEY_PATH.pub" ]; then
@@ -177,7 +177,7 @@ else
AUTH_OPTIONS="$BASE_OPTIONS"
fi
COMMENT="KLUCZ PLUGINU mail-autologin DLA SERWERA $SERVER_LABEL"
COMMENT="KLUCZ PLUGINU MX-Autologin DLA SERWERA $SERVER_LABEL"
cat <<EOF
Private key:
+2 -2
View File
@@ -11,7 +11,7 @@ ROOT_DIR="$(cd .. && pwd)"
ARCHIVE_DIR="$ROOT_DIR/archives/$VERSION"
mkdir -p "$ARCHIVE_DIR"
tar -czf "$ARCHIVE_DIR/mail-login.tar.gz" \
tar -czf "$ARCHIVE_DIR/mx_autologin.tar.gz" \
--exclude='./.git' \
--exclude='./tests' \
--exclude='./scripts/package.sh' \
@@ -22,4 +22,4 @@ tar -czf "$ARCHIVE_DIR/mail-login.tar.gz" \
--exclude='./.DS_Store' \
.
echo "$ARCHIVE_DIR/mail-login.tar.gz"
echo "$ARCHIVE_DIR/mx_autologin.tar.gz"
+3 -3
View File
@@ -1,11 +1,11 @@
#!/bin/sh
set -eu
BASE_DIR="/usr/local/hitme_plugins/mail-login"
BASE_DIR="/usr/local/hitme_plugins/mx_autologin"
if [ "${PURGE_MAIL_LOGIN_DATA:-0}" = "1" ]; then
rm -rf "$BASE_DIR"
echo "mail-login data purged"
echo "MX-Autologin data purged"
else
echo "mail-login uninstalled; external data preserved at $BASE_DIR"
echo "MX-Autologin uninstalled; external data preserved at $BASE_DIR"
fi
+3 -3
View File
@@ -1,8 +1,8 @@
#!/bin/sh
set -eu
BASE_DIR="/usr/local/hitme_plugins/mail-login"
PLUGIN_DIR="/usr/local/directadmin/plugins/mail-login"
BASE_DIR="/usr/local/hitme_plugins/mx_autologin"
PLUGIN_DIR="/usr/local/directadmin/plugins/mx_autologin"
mkdir -p "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state/rate-limit"
chmod 700 "$BASE_DIR/secrets" "$BASE_DIR/logs" "$BASE_DIR/state" "$BASE_DIR/state/rate-limit"
@@ -12,4 +12,4 @@ fi
touch "$BASE_DIR/logs/audit.log"
chmod 600 "$BASE_DIR/logs/audit.log"
echo "mail-login updated; configuration is read from $PLUGIN_DIR/plugin-settings.conf"
echo "MX-Autologin updated; configuration is read from $PLUGIN_DIR/plugin-settings.conf"
+2 -2
View File
@@ -21,7 +21,7 @@ test('keygen script creates plugin key and direct ssh authorized keys line', fun
assert_contains('from="203.0.113.10"', $output);
assert_contains('restrict,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-pty', $output);
assert_not_contains('command=', $output);
assert_contains('KLUCZ PLUGINU mail-autologin DLA SERWERA h4', $output);
assert_contains('KLUCZ PLUGINU MX-Autologin DLA SERWERA h4', $output);
});
test('keygen script detects source ip without parameters', function (): void {
@@ -108,5 +108,5 @@ test('keygen script prints helper forced command line when mx login mode is help
assert_same(0, $code, implode("\n", $out));
$output = implode("\n", $out);
assert_contains('command="/usr/local/hitme_plugins/mail-login-helper/bin/create-login-url"', $output);
assert_contains('KLUCZ PLUGINU mail-autologin DLA SERWERA h4', $output);
assert_contains('KLUCZ PLUGINU MX-Autologin DLA SERWERA h4', $output);
});
+19 -5
View File
@@ -5,20 +5,20 @@ test('plugin metadata and packaging docs match project rules', function (): void
$conf = file_get_contents(PLUGIN_ROOT . '/plugin.conf') ?: '';
$packing = file_get_contents(PROJECT_ROOT . '/PACKING.md') ?: '';
assert_contains('name=mail-login', $conf);
assert_contains('id=mail-login', $conf);
assert_contains('name=MX-Autologin', $conf);
assert_contains('id=mx_autologin', $conf);
assert_contains('type=user', $conf);
assert_contains('version=1.0.12', $conf);
assert_contains('version=1.0.13', $conf);
assert_contains('user_run_as=root', $conf);
assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/src', $packing);
assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/archives/X.Y.Z/mail-login.tar.gz', $packing);
assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/archives/X.Y.Z/mx_autologin.tar.gz', $packing);
});
test('package source excludes local-only files and dangerous placeholders', function (): void {
$package = file_get_contents(PLUGIN_ROOT . '/scripts/package.sh') ?: '';
assert_contains("--exclude='./.git'", $package);
assert_contains("--exclude='./tests'", $package);
assert_contains('mail-login.tar.gz', $package);
assert_contains('mx_autologin.tar.gz', $package);
assert_true(is_file(PLUGIN_ROOT . '/scripts/keygen.sh'));
$bad = [];
@@ -38,3 +38,17 @@ test('package source excludes local-only files and dangerous placeholders', func
}
assert_same([], $bad);
});
test('directadmin entry points use mx autologin directory and display label', function (): void {
$txt = file_get_contents(PLUGIN_ROOT . '/hooks/user_txt.html') ?: '';
$img = file_get_contents(PLUGIN_ROOT . '/hooks/user_img.html') ?: '';
$login = file_get_contents(PLUGIN_ROOT . '/user/login.raw') ?: '';
$index = file_get_contents(PLUGIN_ROOT . '/user/index.html') ?: '';
assert_contains('/CMD_PLUGINS/mx_autologin/login.raw', $txt);
assert_contains('Zaloguj do serwera poczty', $txt);
assert_contains('/CMD_PLUGINS/mx_autologin/images/user_icon.svg', $img);
assert_contains('alt="Zaloguj do serwera poczty"', $img);
assert_contains('/usr/local/directadmin/plugins/mx_autologin/php.ini', $login);
assert_contains('/CMD_PLUGINS/mx_autologin/login.raw', $index);
});
+1 -1
View File
@@ -18,7 +18,7 @@ test('settings expose secure defaults from plugin-settings.conf', function (): v
});
test('settings runtime file is the directadmin plugin settings file', function (): void {
assert_same('/usr/local/directadmin/plugins/mail-login/plugin-settings.conf', Settings::EXTERNAL_SETTINGS);
assert_same('/usr/local/directadmin/plugins/mx_autologin/plugin-settings.conf', Settings::EXTERNAL_SETTINGS);
});
test('settings reject login key ttl outside production range', function (): void {
+3 -3
View File
@@ -1,4 +1,4 @@
#!/usr/local/bin/php -nc/usr/local/directadmin/plugins/mail-login/php.ini
#!/usr/local/bin/php -nc/usr/local/directadmin/plugins/mx_autologin/php.ini
<?php
declare(strict_types=1);
@@ -7,6 +7,6 @@ header('Cache-Control: no-store, private');
header('Referrer-Policy: no-referrer');
echo '<!doctype html><html lang="pl"><head><meta charset="utf-8">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
echo '<title>Serwer poczty</title></head><body>';
echo '<p><a href="/CMD_PLUGINS/mail-login/login.raw">Zaloguj do serwera poczty</a></p>';
echo '<title>Zaloguj do serwera poczty</title></head><body>';
echo '<p><a href="/CMD_PLUGINS/mx_autologin/login.raw">Zaloguj do serwera poczty</a></p>';
echo '</body></html>';
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/local/bin/php -nc/usr/local/directadmin/plugins/mail-login/php.ini
#!/usr/local/bin/php -nc/usr/local/directadmin/plugins/mx_autologin/php.ini
<?php
declare(strict_types=1);