add registration WIP

This commit is contained in:
2025-09-01 17:25:49 +02:00
parent f64cee12f5
commit 1a2edcfee6
15 changed files with 2296 additions and 35 deletions
+22
View File
@@ -0,0 +1,22 @@
FROM php:8.2-apache
# Installer les dépendances nécessaires pour compiler les extensions PHP
RUN apt-get update && apt-get install -y \
unzip \
git \
libgmp-dev \
libzip-dev \
libxml2-dev \
default-mysql-client \
&& docker-php-ext-install mysqli gmp soap \
&& rm -rf /var/lib/apt/lists/*
# Installer composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Copier l'application
WORKDIR /var/www/html
COPY ./index.php ./srp6.php ./composer.json ./
# Installer les dépendances PHP
RUN composer install --no-dev --optimize-autoloader
+15
View File
@@ -0,0 +1,15 @@
{
"name": "wow/account-web",
"description": "Web panel to create WoW accounts with SRP6 and OIDC authentication",
"require": {
"php": ">=8.0",
"jumbojett/openid-connect-php": "^0.9.6",
"ext-gmp": "*",
"ext-mysqli": "*"
},
"autoload": {
"files": [
"srp6.php"
]
}
}
+58
View File
@@ -0,0 +1,58 @@
<?php
require __DIR__ . '/vendor/autoload.php';
use Jumbojett\OpenIDConnectClient;
// session_start();
// // --- OIDC login ---
// $oidc = new OpenIDConnectClient(
// getenv('OIDC_ISSUER'),
// getenv('OIDC_CLIENT_ID'),
// getenv('OIDC_CLIENT_SECRET')
// );
// if (!isset($_SESSION['user'])) {
// $oidc->authenticate();
// $_SESSION['user'] = $oidc->getVerifiedClaims();
// }
// --- Formulaire pour créer un compte ---
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$user = $_POST['username'];
$pass = $_POST['password'];
$soapUser = 'SOAPUSER';
$soapPass = 'SOAPPASS';
$host = getenv('SOAP_HOST');
$port = getenv('SOAP_PORT');
$command = "account create $user $pass";
$command = "account list";
$client = new SoapClient(NULL, [
"location" => "http://mangosd:7878/",
"uri" => "urn:MaNGOS",
"style" => SOAP_RPC,
'login' => $soapUser,
'password' => $soapPass
]);
try {
// NOTE : ne pas mettre de préfixe ns1:
$result = $client->__soapCall('executeCommand', [new SoapParam($command, 'command')]);
echo "✅ Command executed:\n";
echo $result;
var_dump($result);
} catch (Exception $e) {
echo "❌ Command failed:\n";
echo $e->getMessage();
}
}
?>
<form method="post">
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Create Account</button>
</form>
+50
View File
@@ -0,0 +1,50 @@
<?php
/**
* SRP6 (WoW/MaNGOS) génération de v et s corrects.
* Points clés :
* - USERNAME & PASSWORD en MAJUSCULES
* - x = SHA1( salt || SHA1(USER:PASS) )
* - N = 0x894B...E9BB7 (256-bit), g = 7
* - Endianness : on évite gmp_import et on passe par hex pour ne pas se tromper
* - Hex MAJUSCULE + padding à la longueur de N
*/
final class SRP6
{
// N et g utilisés par WoW (256-bit)
private const N_HEX = '894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7';
private const G_HEX = '07';
public static function createVerifierAndSalt(string $username, string $password): array
{
$U = strtoupper($username);
$P = strtoupper($password);
// 32 octets de sel (=> 64 hex)
$saltBin = random_bytes(32);
// h1 = SHA1(U:P)
$h1 = sha1($U . ':' . $P, true);
// h2 = SHA1(salt || h1)
$h2 = sha1($saltBin . $h1, true);
// x = int( h2 ) (interprété comme un entier non signé big-endian)
// -> on passe par l'hex pour éviter les soucis d'endianness
$x = gmp_init(bin2hex($h2), 16);
$N = gmp_init(self::N_HEX, 16);
$g = gmp_init(self::G_HEX, 16);
// v = g^x mod N
$v = gmp_powm($g, $x, $N);
// Longueur hex attendue = longueur de N en hex (ici 64 chars)
$nLen = strlen(self::N_HEX);
// Hex MAJUSCULE + padding
$vHex = strtoupper(str_pad(gmp_strval($v, 16), $nLen, '0', STR_PAD_LEFT));
$sHex = strtoupper(str_pad(bin2hex($saltBin), 64, '0', STR_PAD_LEFT)); // 32 bytes => 64 hex
return ['v' => $vHex, 's' => $sHex];
}
}