Skip to content

Commit

Permalink
[Dovecot] move sogo sso to mailcowauth.php
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddleSpl0it committed Feb 26, 2024
1 parent 010d898 commit 6928eb6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
7 changes: 0 additions & 7 deletions data/Dockerfiles/dovecot/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,6 @@ EOF
# Create random master Password for SOGo SSO
RAND_PASS=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1)
echo -n ${RAND_PASS} > /etc/phpfpm/sogo-sso.pass
cat <<EOF > /etc/dovecot/sogo-sso.conf
# Autogenerated by mailcow
passdb {
driver = static
args = allow_real_nets=${IPV4_NETWORK}.248/32 password={plain}${RAND_PASS}
}
EOF

if [[ "${MASTER}" =~ ^([nN][oO]|[nN])+$ ]]; then
# Toggling MASTER will result in a rebuild of containers, so the quota script will be recreated
Expand Down
20 changes: 15 additions & 5 deletions data/conf/dovecot/auth/mailcowauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,30 @@
require_once 'sessions.inc.php';
require_once 'functions.mailbox.inc.php';

// Init provider
$iam_provider = identity_provider('init');


$isSOGoRequest = $post['real_rip'] == getenv('IPV4_NETWORK') . '.248';
$result = false;
$protocol = $post['protocol'];
if ($post['real_rip'] == getenv('IPV4_NETWORK') . '.248') {
if ($isSOGoRequest) {
$protocol = null;
// This is a SOGo Auth request. First check for SSO password.
$sogo_sso_pass = file_get_contents("/etc/sogo-sso/sogo-sso.pass");
if ($sogo_sso_pass === $post['password']){
error_log('MAILCOWAUTH: SOGo SSO auth for user ' . $post['username']);
$result = true;
}

}
$result = user_login($post['username'], $post['password'], $protocol, array('is_internal' => true));
if ($result === false){
$result = apppass_login($post['username'], $post['password'], $protocol, array(
'is_internal' => true,
'remote_addr' => $post['real_rip']
));
if ($result) error_log('MAILCOWAUTH: App auth for user ' . $post['username']);
}
if ($result === false){
$result = user_login($post['username'], $post['password'], $protocol, array('is_internal' => true));
if ($result) error_log('MAILCOWAUTH: User auth for user ' . $post['username']);
}

if ($result) {
Expand Down
1 change: 0 additions & 1 deletion data/conf/dovecot/dovecot.conf
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ replication_dsync_parameters = -d -l 30 -U -n INBOX
!include_try /etc/dovecot/sni.conf
!include_try /etc/dovecot/sogo_trusted_ip.conf
!include_try /etc/dovecot/extra.conf
!include_try /etc/dovecot/sogo-sso.conf
!include_try /etc/dovecot/shared_namespace.conf
# </Includes>
default_client_limit = 10400
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ services:
- sogo

dovecot-mailcow:
image: mailcow/dovecot:nightly-20240208
image: mailcow/dovecot:nightly-20240226
depends_on:
- mysql-mailcow
- netfilter-mailcow
Expand Down

0 comments on commit 6928eb6

Please sign in to comment.