servnest/sftpgo-auth.php

27 lines
736 B
PHP
Raw Normal View History

2022-05-19 16:59:32 +02:00
<?php
require 'router.php';
2022-05-19 16:59:32 +02:00
2022-11-26 21:45:48 +01:00
$auth_data = json_decode(file_get_contents('php://input'), true);
2022-05-19 16:59:32 +02:00
2022-11-26 21:45:48 +01:00
$internal_username = hash('sha256', $auth_data['username']);
if (userExist($internal_username) === true AND checkPassword($internal_username, $auth_data['password']) === true) {
2022-06-28 22:08:34 +02:00
echo '
{
"status": 1,
2022-11-26 21:45:48 +01:00
"username": ' . json_encode($auth_data['username']) . ',
"home_dir": "' . CONF['ht']['ht_path'] . '/' . $internal_username . '",
"quota_size": ' . ((query('select', 'users', ['username' => $internal_username], 'type')[0] === 'trusted') ? CONF['ht']['user_quota_trusted'] : CONF['ht']['user_quota_testing']) . ',
2022-06-28 22:08:34 +02:00
"permissions": {
"/": [
"*"
]
}
}
';
2022-05-19 16:59:32 +02:00
http_response_code(200);
} else {
http_response_code(403);
}