diff --git a/config.ini b/config.ini index a798cff..ca26d6d 100644 --- a/config.ini +++ b/config.ini @@ -23,7 +23,6 @@ kdig_path = "/usr/bin/kdig" [ht] enabled = true -letsencrypt_use_production = false ; Path were user's sites will be stored ht_path = "/srv/niver/ht" @@ -61,4 +60,5 @@ ipv6_listen_address = "::1" ipv4_listen_address = "127.0.0.1" internal_onion_http_port = 9080 -user_quota = 20971520 +user_quota_testing = 20971520 +user_quota_trusted = 209715200 diff --git a/db/migrations/003-add-account-type.sql b/db/migrations/003-add-account-type.sql new file mode 100644 index 0000000..248ec12 --- /dev/null +++ b/db/migrations/003-add-account-type.sql @@ -0,0 +1,21 @@ +BEGIN TRANSACTION; + +-- Add column +ALTER TABLE "users" ADD COLUMN "type" TEXT NOT NULL DEFAULT "testing"; + +-- Remove it's default value +CREATE TABLE "users_temp" ( + "id" INTEGER NOT NULL UNIQUE, + "username" TEXT NOT NULL UNIQUE, + "password" TEXT NOT NULL, + "registration_date" TEXT NOT NULL, + "bucket_tokens" INTEGER NOT NULL, + "bucket_last_update" INTEGER NOT NULL, + "type" TEXT NOT NULL, + PRIMARY KEY("id" AUTOINCREMENT) +); +INSERT INTO "users_temp" SELECT "id","username","password","registration_date","bucket_tokens","bucket_last_update","type" FROM "users"; +DROP TABLE "users"; +ALTER TABLE "users_temp" RENAME TO "users"; + +COMMIT; diff --git a/db/schema.sql b/db/schema.sql index 9ac12e6..33cde2c 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -1,38 +1,39 @@ BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "params" ( - "name" TEXT NOT NULL UNIQUE, - "value" TEXT NOT NULL + "name" TEXT NOT NULL UNIQUE, + "value" TEXT NOT NULL ); CREATE TABLE IF NOT EXISTS "registry" ( - "id" INTEGER NOT NULL UNIQUE, - "domain" TEXT NOT NULL UNIQUE, - "username" TEXT NOT NULL, - "last_renewal" TEXT NOT NULL, + "id" INTEGER NOT NULL UNIQUE, + "domain" TEXT NOT NULL UNIQUE, + "username" TEXT NOT NULL, + "last_renewal" TEXT NOT NULL, PRIMARY KEY("id" AUTOINCREMENT) ); CREATE TABLE IF NOT EXISTS "zones" ( - "id" INTEGER NOT NULL UNIQUE, - "zone" TEXT NOT NULL UNIQUE, - "username" TEXT NOT NULL, + "id" INTEGER NOT NULL UNIQUE, + "zone" TEXT NOT NULL UNIQUE, + "username" TEXT NOT NULL, PRIMARY KEY("id" AUTOINCREMENT) ); CREATE TABLE IF NOT EXISTS "users" ( - "id" INTEGER NOT NULL UNIQUE, - "username" TEXT NOT NULL UNIQUE, - "password" TEXT NOT NULL, - "registration_date" TEXT NOT NULL, - "bucket_tokens" INTEGER NOT NULL, + "id" INTEGER NOT NULL UNIQUE, + "username" TEXT NOT NULL UNIQUE, + "password" TEXT NOT NULL, + "registration_date" TEXT NOT NULL, + "bucket_tokens" INTEGER NOT NULL, "bucket_last_update" INTEGER NOT NULL, + "type" TEXT NOT NULL, PRIMARY KEY("id" AUTOINCREMENT) ); CREATE TABLE IF NOT EXISTS "sites" ( - "id" INTEGER NOT NULL UNIQUE, - "username" TEXT NOT NULL, - "site_dir" TEXT NOT NULL, - "domain" TEXT NOT NULL UNIQUE, - "domain_type" TEXT NOT NULL, - "protocol" TEXT NOT NULL, - "creation_date" TEXT NOT NULL, + "id" INTEGER NOT NULL UNIQUE, + "username" TEXT NOT NULL, + "site_dir" TEXT NOT NULL, + "domain" TEXT NOT NULL UNIQUE, + "domain_type" TEXT NOT NULL, + "protocol" TEXT NOT NULL, + "creation_date" TEXT NOT NULL, PRIMARY KEY("id" AUTOINCREMENT) ); INSERT INTO "params"("name", "value") VALUES("instance_bucket_tokens", "0"); diff --git a/pages/auth/index.php b/pages/auth/index.php index 7aa456b..1323844 100644 --- a/pages/auth/index.php +++ b/pages/auth/index.php @@ -1 +1,30 @@ +
+ + Vous utilisez actuellement un compte = (($_SESSION['type'] === 'trusted') ? 'confiancé' : 'de test') ?>. + + Vous n'utilisez actuellement aucun compte. + +
+ +
- Vous avez accès à un espace SFTP, limité à = ((CONF['ht']['user_quota'] >> 30) >= 1) ? CONF['ht']['user_quota'] >> 30 . ' ' . linkToDocs('units', 'Gio') : CONF['ht']['user_quota'] >> 20 . ' ' . linkToDocs('units', 'Mio') ?>. Vous pouvez téléverser vos sites dans /<nom du site>/*
. Indiquez les données ci-dessous à votre client SFTP pour y accéder.
+ Vous avez accès à un espace SFTP, limité à > 30) >= 1) ? $quotaSize >> 30 . ' ' . linkToDocs('units', 'Gio') : $quotaSize >> 20 . ' ' . linkToDocs('units', 'Mio')
+?>. Vous pouvez téléverser vos sites dans /<nom du site>/*
. Indiquez les données ci-dessous à votre client SFTP pour y accéder.
- 🆔 = $_SESSION['username'] ?> /auth/logout'>Se déconnecter + = ($_SESSION['type'] === 'trusted') ? '👤' : '⏳' ?> = $_SESSION['username'] ?> Se déconnecter Anonyme Se connecter diff --git a/sftpgo-auth.php b/sftpgo-auth.php index 82d5c49..0492717 100644 --- a/sftpgo-auth.php +++ b/sftpgo-auth.php @@ -5,11 +5,12 @@ require "router.php"; $authData = json_decode(file_get_contents("php://input"), true); if (userExist($authData['username']) === true AND checkPassword($authData['username'], $authData['password']) === true) { + $quotaSize = (query('select', 'users', ['username' => $authData['username']], 'type')[0] === 'trusted') ? CONF['ht']['user_quota_trusted'] : CONF['ht']['user_quota_testing']; echo ' { "status": 1, "username": "' . $authData['username'] . '", - "quota_size": ' . CONF['ht']['user_quota'] . ', + "quota_size": ' . $quotaSize . ', "permissions": { "/": [ "*"