Navigation

    Kopano
    • Register
    • Login
    • Search
    • Categories
    • Get Official Kopano Support
    • Recent
    Statement regarding the closure of the Kopano community forum and the end of the community edition

    Logging of login attemts

    Kopano WebApp
    4
    10
    782
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • klausf
      klausf last edited by

      How can I log the login attemts of users in nginx/apache logs? I like to see the usernames who are logging in like in the z-push logins.

      Thanks!
      Klaus

      1 Reply Last reply Reply Quote 0
      • marty
        marty Kopano (Inactive) last edited by

        @klausf Failed attempt can be seen in the apache error log

        Kopano WebApp user: klausf: authentication failure at MAPI, referer: https://someurl/?logon
        

        https://documentation.kopano.io/deskapp_admin_manual
        http://documentation.kopano.io/webapp_smime_manual
        https://documentation.kopano.io/webapp_admin_manual

        1 Reply Last reply Reply Quote 0
        • klausf
          klausf last edited by

          @marty Thank you for your quick reply. Yes, fine, thanks for the hint! Is it possible to configure webapp to log successful logins with the username?

          1 Reply Last reply Reply Quote 0
          • marty
            marty Kopano (Inactive) last edited by

            You cannot configure it, but you can add a line to the php code.
            For example here:
            https://stash.kopano.io/projects/KW/repos/kopano-webapp/browse/server/includes/core/class.webappauthentication.php#173

            https://documentation.kopano.io/deskapp_admin_manual
            http://documentation.kopano.io/webapp_smime_manual
            https://documentation.kopano.io/webapp_admin_manual

            klausf 1 Reply Last reply Reply Quote 0
            • klausf
              klausf @marty last edited by

              @marty Great, works fine! Thank you for finding the line number for me!
              It would be nice to have a config.php variable to enable success logging for future versions.

                    if (WebAppAuthentication::$_errorCode === NOERROR ) {
                      WebAppAuthentication::$_authenticated = true;
                      // Print success message to error_log of webserver
                      error_log('Kopano WebApp user: ' . $username . ': authentication success at MAPI');
                      WebAppAuthentication::_storeMAPISession(WebAppAuthentication::$_mapiSession->getSession());
                    } elseif ( WebAppAuthentication::$_errorCode == MAPI_E_LOGON_FAILED || WebAppAuthentication::$_errorCode == MAPI_E_UNCONFIGURED ) {
                      // Print error message to error_log of webserver
                      error_log('Kopano WebApp user: ' . $username . ': authentication failure at MAPI');
              
              
              1 Reply Last reply Reply Quote 0
              • micro
                micro last edited by

                Hi all,

                I cam from this thread here and I am also interested in getting the succeeded logins. Can anyone explain to me please, how I can implement this in the class.webappauthentication.php and how to compile and make the change effective?

                thank you in advance.

                1 Reply Last reply Reply Quote 0
                • micro
                  micro last edited by

                  anyone can explain to a non-developer how to implement this “patch” so I can get have logged the succeeded logins, too?

                  BTW: I’m also interested in a solution to see successful “mailbox attaches” in the log file. Is that possible, too? For example: when Alice attaches successfully the mailbox of Bob into her account.

                  thanks in advance.

                  1 Reply Last reply Reply Quote 0
                  • klausade
                    klausade last edited by

                    Several ways, one way would be to open the file /usr/share/kopano-webapp/server/includes/core/class.webappauthentication.php with vi/vim, and around line 172, the one that says “WebAppAuthentication::$_authenticated = true;”, just add this line right after that one:
                    error_log('Kopano WebApp user: ’ . $username . ‘: authentication success at MAPI’);

                    You should then in your /var/log/apache2/error.log see something like this:
                    [:error] [pid XXX] [client XXXXXXXXX:XXXX] Kopano WebApp user: username: authentication success at MAPI

                    Note that this file will be replaced whenever there is a new version of kopano-webapp being installed, so another way would be to use dpkg-divert, if you are on debian, or just remember to do it manually every time a new version of kopano-webapp

                    micro 1 Reply Last reply Reply Quote 0
                    • marty
                      marty Kopano (Inactive) last edited by

                      I’ve made a ticket: https://jira.kopano.io/browse/KW-3375
                      and added a small fix, hidden behind a new config option, because not everyone wants this enabled by default.

                      https://documentation.kopano.io/deskapp_admin_manual
                      http://documentation.kopano.io/webapp_smime_manual
                      https://documentation.kopano.io/webapp_admin_manual

                      1 Reply Last reply Reply Quote 0
                      • micro
                        micro @klausade last edited by micro

                        @klausade
                        Thanks for that helpful information. Your line showed backticks instead the apostrophe, I had to correct the line:

                         error_log('Kopano WebApp user: ' . $username . ': authentication success at MAPI');
                        

                        Now my “/usr/share/kopano-webapp/server/includes/core/class.webappauthentication.php” looks like that:

                         if (WebAppAuthentication::$_errorCode === NOERROR ) {
                           WebAppAuthentication::$_authenticated = true;
                           error_log('Kopano WebApp user: ' . $username . ': authentication success at MAPI');
                        

                        and I get successfully the message logged as you explained. Great!

                        @marty said in Logging of login attemts:

                        I’ve made a ticket: https://jira.kopano.io/browse/KW-3375
                        and added a small fix, hidden behind a new config option, because not everyone wants this enabled by default.

                        thank you Marty. It would be nice to have the option to specify a separate logfile for succeeded or failed logins which one could use for post-analyzing procedures (security measurements).

                        Now I still wonder if it’s possible to get succeeded attaches of a shared mailbox. Will that work somehow similar ?

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post