View Issue Details

IDProjectCategoryView StatusLast Update
0006123SOGoBackend Generalpublic2025-05-16 12:12
ReporterCLSMCSMII Assigned Toqhivert  
PrioritynormalSeverityminorReproducibilityalways
Status feedbackResolutionopen 
PlatformLinuxOSUbuntuOS Version24.04.2 LTS
Product Version5.12.1 
Summary0006123: SOGo + OpenID authentication with MS Entra ID problem
Description

Hello everyone,

I have SOGo setup with LDAP usersource, it works fine.
My AD servers synced to MS Entra ID, we have some apps that already using
OpenID connect (Moodle) and it works fine.

I'm trying to make SOGo authenticate with Entra ID as well.
Here is my sogo.conf (OpenID portion)

/ OpenID /
OCSOpenIdURL = "mysql://sogo:===mysql sogo password===@127.0.0.1:3306/
sogo/sogo_openid";
SOGoAuthenticationType = openid;
SOGoXSRFValidationEnabled = NO;
SOGoOpenIdConfigUrl = "https://login.microsoftonline.com/==Long string
that pointed to my APP ID==/v2.0/.well-known/openid-configuration";
SOGoOpenIdClient = "===oidc client id ===";
SOGoOpenIdClientSecret = "===oidc secret===";
SOGoOpenIdScope = "profile email openid";
SOGoOpenIdEmailParam = "mail";
SOGoOpenIdEnableRefreshToken = NO;
SOGoOpenIdTokenCheckInterval = 200;

On Entra ID I put "https://myactualsite.domain/SOGo/"; as the redirect URI.

After I restart sogo service on Ubuntu 24.04, sogo_openid table is created in
sogo database.

But when I tried to login, authentication process on Microsoft authentication
portal is successful until it got redirected, it shows blank page for minutes
and it end up with NGINX error.

Here is my sogo.log

May 14 15:16:15 sogod [301625]: |SOGo| starting method 'GET' on uri '/SOGo/'
May 14 15:16:15 sogod [301625]: <0x0x58b6a36f21a0[SOGoCache]> Cache cleanup
interval set every 300.000000 seconds
May 14 15:16:15 sogod [301625]: <0x0x58b6a36f21a0[SOGoCache]> Using host(s)
'127.0.0.1' as server(s)
May 14 15:16:15 sogod [301625]: [WARN] <0x0x78181bad01e0[WOxElemBuilder]>
could not locate builders: WOxExtElemBuilder,WOxExtElemBuilder
May 14 15:16:15 sogod [301625]: |SOGo| request took 0.556267 seconds to
execute
May 14 15:16:15 sogod [301625]: 172.16.14.19 "GET /SOGo/ HTTP/1.0" 302 0/0
0.559 - - 5M - 11
May 14 15:16:18 sogod [301625]: |SOGo| starting method 'GET' on uri '/SOGo/?
code=1.AVQA6i==VERY LONG STRINGS==&session_state=2a2cdd81-8446-4284-af1d-
b6dc12e886b1'
May 14 15:17:18 sogod [301613]: [WARN] <0x0x58b6a39b13f0[WOWatchDogChild]> pid
301625 has been hanging in the same request for 1 minutes
May 14 15:18:18 sogod [301613]: [WARN] <0x0x58b6a39b13f0[WOWatchDogChild]> pid
301625 has been hanging in the same request for 2 minutes
2025-05-14 15:18:28.431 sogod[301625:301625] caught SIGPIPE - ignoring!
May 14 15:18:28 sogod [301625]: [ERROR] <0x0x58b6a3f7fcd0[GSCBufferString]>
json parser: Expected value while parsing array, attempting once more after
unescaping...
May 14 15:18:28 sogod [301625]: [ERROR] <0x0x58b6a3f7fcd0[GSCBufferString]>
total failure. Original string is: E5
{"sub":"AgbeINzGF6Oao3N_mW4RzY6EQmbZM1dF1bbiz-CUrTo","name":"==My name on
AD==","family_name":"==My family name on AD==","given_name":"==My given name
on
AD==","picture":"https://graph.microsoft.com/v1.0/me/photo/$value&quot;,&quot;email&quot;:&quot;==My
email on AD=="}
0

May 14 15:18:28 sogod [301625]: [ERROR] <0x0x78181c11f160[SOGoSession]> Value
to be secured is too big (2601 > 1575) -- secured value will be corrupted
May 14 15:18:28 sogod [301625]: |SOGo| request took 130.323775 seconds to
execute
May 14 15:18:28 sogod [301625]: [ERROR] <0x0x58b6a3e91750[WOHttpTransaction]>
client disconnected during delivery of response for
<WORequest[0x0x58b6a39c5500]: method=GET uri=/SOGo/?code=1.AVQA6i==VERY LONG
STRINGS==&session_state=2a2cdd81-8446-4284-af1d-b6dc12e886b1 app=SOGo rqKey=
rqPath=(null)> (len=0): the socket was shutdown
May 14 15:18:28 sogod [301625]: 172.16.14.19 "GET /SOGo/?code=1.AVQA6i==VERY
LONG STRINGS==&session_state=2a2cdd81-8446-4284-af1d-b6dc12e886b1 HTTP/1.0"
302 0/0 130.327 - - 2M - 13

I see a lot of errors from this authentication attemp, and I have no idea what
this is --> [ERROR] <0x0x78181c11f160[SOGoSession]> Value to be secured is too
big (2601 > 1575) -- secured value will be corrupted
Maybe it's the cause why it fail to redirect, right?

Please help me figure out what's wrong with my setup.

Steps To Reproduce

If you already have a working SOGo with LDAP user source (Can authenticate with LDAP account)

Create Entra ID app for SOGo, add redirect URI at this app by going to Azure portal --> Entra ID --> App Registration --> Choose your app --> Authentication --> + Add platform --> Choose Web --> Add Redirect URI as "https://your.domain/SOGo/&quot;

Then add this portion of OIDC configuration to /etc/sogo/sogo.conf and restart sogo service.
SOGo will create another DB table named "sogo_openid" (Check with sql command)

/ OpenID /
OCSOpenIdURL = "mysql://sogo:===mysql sogo password===@127.0.0.1:3306/
sogo/sogo_openid";
SOGoAuthenticationType = openid;
SOGoXSRFValidationEnabled = NO;
SOGoOpenIdConfigUrl = "https://login.microsoftonline.com/==Long string
that pointed to my APP ID==/v2.0/.well-known/openid-configuration";
SOGoOpenIdClient = "===oidc client id ===";
SOGoOpenIdClientSecret = "===oidc secret===";
SOGoOpenIdScope = "profile email openid";
SOGoOpenIdEmailParam = "mail";
SOGoOpenIdEnableRefreshToken = NO;
SOGoOpenIdTokenCheckInterval = 200;

After all done, try to access your SOGo app, it will redirected to MS authentication portal.
After login successfully, it will redirect to the URI you've setup which return blank page for minutes then it will shows NGINX error.

Check /var/log/sogo/sogo.log for errors.

Additional Information

LDAP user source portion

// Authentication using LDAP
SOGoUserSources = (
    {
        // Used for user authentication
        type = ldap;
        id = users;
        canAuthenticate = YES;
        isAddressBook = NO;
        displayName = &quot;LDAP Authentication&quot;;

        hostname = &quot;ldap://my.domain:389&quot;;   // &lt;- Set to ldaps://ad.example.com:636 for LDAPS.
        baseDN = &quot;dc=my,dc=domain&quot;;
        bindDN = &quot;CN=ldapadmin,OU=Service Accounts,OU=Groups,dc=my,dc=domain&quot;;
        bindPassword = &quot;secret&quot;;
        filter = &quot;objectClass=person AND userPrincipalName='*' AND (NOT userAccountControl:1.2.840.113556.1.4.803:=2)&quot;;
        scope = SUB;

        // always keep binding to the LDAP server using the DN of the
        // currently authenticated user. bindDN and bindPassword are still
        // required to find DN of the user.
        // Note: with default LDAP acl configured by iRedMail, user doesn't
        //       have privilege to query o=domains,dc=delmsgs,dc=freeddns,dc=org.
        //       so this doesn't work.
        bindAsCurrentUser = YES;

        // The algorithm used for password encryption when changing
        // passwords without Password Policies enabled.
        // Possible values are: plain, crypt, md5-crypt, ssha, ssha512.
        userPasswordAlgorithm = ssha512;

        CNFieldName = cn;
        IDFieldName = userPrincipalName;
        // value of UIDFieldName must be unique on entire server
        UIDFieldName = userPrincipalName;
        IMAPLoginFieldName = userPrincipalName;
        MailFieldNames = (userPrincipalName);
        bindFields = (userPrincipalName);
    },
    {
        // Used for global address book
        type = ldap;
        id = global_addressbook;
        canAuthenticate = NO;
        isAddressBook = YES;
        displayName = &quot;Global Address Book&quot;;
        bindAsCurrentUser = YES;

        // Listing of this LDAP source is only possible when performing a
        // search (respecting the SOGoSearchMinimumWordLength parameter)
        // or when explicitely typing a single dot.
        // Defaults to YES when unset.
        //
        // WARNING: if you have many accounts in this address book, it may
        //          reach server-side query size limit, or cause
        //          performance issue.
        listRequiresDot = NO;

       // Set to ldaps://ad.example.com:636 for LDAPS.
        hostname = &quot;ldap://my.domain:389&quot;;
        baseDN = &quot;dc=my,dc=domain&quot;;
        bindDN = &quot;CN=ldapadmin,OU=Service Accounts,OU=Groups,dc=my,dc=domain&quot;;
        bindPassword = &quot;secret&quot;;
        filter = &quot;(objectClass=person OR (objectClass=group AND mail='*')) AND (NOT userAccountControl:1.2.840.113556.1.4.803:=2)&quot;;
        scope = SUB;

        IDFieldName = userPrincipalName;
        bindFields = (userPrincipalName);
        // value of UID field must be unique on whole server.
        UIDFieldName = userPrincipalName;
        IMAPLoginFieldName = userPrincipalName;

        CNFieldName = cn;
        SearchFieldNames = (mail, cn, sAMAccountName, displayName, sn, givenName);

        mapping = {
          ou = (&quot;department&quot;, &quot;ou&quot;);
          street = (&quot;streetAddress&quot;, &quot;street&quot;);
          mozillaworkurl = (&quot;wWWHomePage&quot;, &quot;mozillaworkurl&quot;);
          description = (&quot;info&quot;, &quot;description&quot;);
        };
    },
    {
        // Used for distribution lists
        type = ldap;
        id = distribution_lists;
        canAuthenticate = NO;
        isAddressBook = NO;
        displayName = &quot;Distribution Lists&quot;;
        bindAsCurrentUser = YES;
        // Set to ldaps://ad.example.com:636 for LDAPS.
        hostname = &quot;ldap://my.domain:389&quot;;
        baseDN = &quot;dc=my,dc=domain&quot;;
        bindDN = &quot;CN=ldapadmin,OU=Service Accounts,OU=Groups,dc=my,dc=domain&quot;;
        bindPassword = &quot;secret&quot;;
        filter = &quot;(objectClass=group) AND (mail=*)&quot;;
        scope = SUB;

        IDFieldName = cn;
        bindFields = (cn);
        // value of UID field must be unique on whole server.
        UIDFieldName = cn;
        IMAPLoginFieldName = mail;
        CNFieldName = cn;
        SearchFieldNames = (mail, cn, displayName);
        mapping = {
          description = (&quot;description&quot;);
        };
    },
    {
        // Used for resource accounts
        type = ldap;
        id = resources;
        canAuthenticate = NO;
        isAddressBook = NO;
        displayName = &quot;Resources&quot;;
        bindAsCurrentUser = YES;

        hostname = &quot;ldap://my.domain:389&quot;;
        baseDN = &quot;OU=Exchange Resources,OU=Service Accounts,OU=Groups,dc=my,dc=domain&quot;;
        bindDN = &quot;CN=ldapadmin,OU=Service Accounts,OU=Groups,dc=my,dc=domain&quot;;
        bindPassword = &quot;secret&quot;;
        filter = &quot;(employeeType=Resource)&quot;;
        // scope = SUB;

        IDFieldName = cn;
        bindFields = (cn);
        UIDFieldName = cn;
        IMAPLoginFieldName = mail;

        CNFieldName = cn;
        SearchFieldNames = (mail, cn, displayName);
        // MultipleBookingsFieldName = customMultipleBookings;
        KindFieldName = physicalDeliveryOfficeName;
        mapping = {
          description = (&quot;description&quot;);
        };
    }
);
TagsNo tags attached.

Activities

CLSMCSMII

CLSMCSMII

2025-05-15 02:41

reporter   ~0018212

Fix, Add Redirect URI as

https://your.domain/SOGo/

CLSMCSMII

CLSMCSMII

2025-05-15 03:26

reporter   ~0018213

Try to change redirect URI on ENtra ID as https://your.domain/
Still doesn't work.

qhivert

qhivert

2025-05-16 12:12

administrator   ~0018214

Hello,
My guess is after your login, sogo is stuck when doing the requets to get the token or to get the userinfo. I've already made a fix for that before.

I will try to set up MS entra in my side.

Meanwhile, you can add this to your sogo.conf to have more logs
NGLogDefaultLogLevel = "ALL";
SOGoDebugRequests = YES;
SOGoOpenIDDebugEnabled = YES;
WODebugHTTPConnection = YES;
WODebugHTTPConnectionLogStream = YES;

It will help to see where sogo is stuck but don't put here all the log as all the http data will be in there (including your cleint id and secret)
Just tell me the last request or action you see before the process is stuck.

Issue History

Date Modified Username Field Change
2025-05-15 02:38 CLSMCSMII New Issue
2025-05-15 02:41 CLSMCSMII Note Added: 0018212
2025-05-15 03:26 CLSMCSMII Note Added: 0018213
2025-05-15 11:23 qhivert Assigned To => qhivert
2025-05-15 11:23 qhivert Status new => assigned
2025-05-16 12:12 qhivert Note Added: 0018214
2025-05-16 12:12 qhivert Status assigned => feedback