-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Web] move /process/login to internal endpoint
- Loading branch information
1 parent
f0689e0
commit dca5f1b
Showing
10 changed files
with
123 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,3 +69,4 @@ rebuild-images.sh | |
refresh_images.sh | ||
update_diffs/ | ||
create_cold_standby.sh | ||
!data/conf/nginx/mailcow_auth.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
header('Content-Type: application/json'); | ||
|
||
$post = trim(file_get_contents('php://input')); | ||
if ($post) { | ||
$post = json_decode($post, true); | ||
} | ||
|
||
$return = array("success" => false, "role" => false); | ||
if(!isset($post['username']) || !isset($post['password'])){ | ||
echo json_encode($return); | ||
exit(); | ||
} | ||
|
||
require_once('../../../web/inc/vars.inc.php'); | ||
if (file_exists('../../../web/inc/vars.local.inc.php')) { | ||
include_once('../../../web/inc/vars.local.inc.php'); | ||
} | ||
require_once '../../../web/inc/lib/vendor/autoload.php'; | ||
|
||
// Do not show errors, we log to using error_log | ||
ini_set('error_reporting', 0); | ||
// Init database | ||
//$dsn = $database_type . ':host=' . $database_host . ';dbname=' . $database_name; | ||
$dsn = $database_type . ":unix_socket=" . $database_sock . ";dbname=" . $database_name; | ||
$opt = [ | ||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, | ||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, | ||
PDO::ATTR_EMULATE_PREPARES => false, | ||
]; | ||
try { | ||
$pdo = new PDO($dsn, $database_user, $database_pass, $opt); | ||
} | ||
catch (PDOException $e) { | ||
error_log("MAILCOWAUTH: " . $e . PHP_EOL); | ||
http_response_code(501); | ||
exit; | ||
} | ||
|
||
// Load core functions first | ||
require_once 'functions.inc.php'; | ||
require_once 'functions.auth.inc.php'; | ||
require_once 'sessions.inc.php'; | ||
|
||
// Init Keycloak Provider | ||
$iam_provider = identity_provider('init'); | ||
|
||
$result = check_login($post['username'], $post['password'], $post['protocol'], true); | ||
if ($result) { | ||
$return = array("success" => true, "role" => $result); | ||
} | ||
|
||
echo json_encode($return); | ||
exit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
server { | ||
listen 9082 ssl http2; | ||
|
||
ssl_certificate /etc/ssl/mail/cert.pem; | ||
ssl_certificate_key /etc/ssl/mail/key.pem; | ||
|
||
index mailcowauth.php; | ||
server_name _; | ||
error_log /var/log/nginx/error.log; | ||
access_log /var/log/nginx/access.log; | ||
root /mailcowauth; | ||
client_max_body_size 10M; | ||
|
||
location ~ \.php$ { | ||
client_max_body_size 10M; | ||
try_files $uri =404; | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
fastcgi_pass phpfpm:9001; | ||
include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters