fix: route regular users through SOGo SSO authentication#7085
Open
x-vibe wants to merge 2 commits intomailcow:masterfrom
Open
fix: route regular users through SOGo SSO authentication#7085x-vibe wants to merge 2 commits intomailcow:masterfrom
x-vibe wants to merge 2 commits intomailcow:masterfrom
Conversation
Regular (non-dual-login) users clicking "Open webmail" are sent to /SOGo/so directly, which fails with 403 because SOGoTrustProxyAuthentication=YES disables SOGo's built-in login form and the _sogo_static_view table has dummy password hashes. Route all users through /sogo-auth.php?login= (the same SSO flow already used for admin-as-user logins) so that proper proxy auth headers are passed to SOGo. Fixes mailcow#6442
Collaborator
The login handler in triggers.user.inc.php has two locations (after TFA verification and after password login) that redirect regular users directly to /SOGo/so/ when sogo_access is enabled. This bypasses the SSO flow entirely, causing 403 errors. Route both redirects through /sogo-auth.php?login= so that the SSO session is properly established before reaching SOGo. Fixes mailcow#6442
Collaborator
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Regular (non-dual-login) users get a 403 / Unauthorized error from SOGo. This happens in two scenarios:
On login: The login handler in
triggers.user.inc.phpredirects regular users directly to/SOGo/so/(lines 83 and 149), bypassing the SSO authentication flow entirely.Clicking "Open webmail": The template
tab-user-auth.twigroutes regular users to/SOGo/sodirectly instead of through/sogo-auth.php?login=.Both paths fail because:
SOGoTrustProxyAuthentication=YESdisables SOGo's built-in login form_sogo_static_viewtable has dummy password hashes (not real user passwords)Fix
data/web/inc/triggers.user.inc.php(2 locations):data/web/templates/user/tab-user-auth.twig(1 location):All three changes route through
/sogo-auth.php?login=— the same SSO flow already used successfully for admin-as-user (dual_login) access. This properly sets$_SESSION['sogo-sso-user-allowed']and passes proxy auth headers to SOGo.Affected configurations
Any Mailcow instance where regular users access webmail. The bug is most visible when
ALLOW_ADMIN_EMAIL_LOGIN=n(the recommended setting), but affects all regular user logins regardless of that setting.Testing
Verified end-to-end on a production Mailcow instance (SOGo 5.12.4-1):
Before fix:
/SOGo/so/→ 403 Unauthorized/SOGo/so→ 403 UnauthorizedAfter fix:
/sogo-auth.php?login=user@domain→ SSO session created → 302 →/SOGo/so/user@domain/Mail/view→ 200 OK (SOGo loads)Note: After applying the template change, the Twig cache and PHP OPcache must be cleared:
Fixes #6442