Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDAP login failing on 3.10.X #1174

Closed
areis422 opened this issue Aug 5, 2021 · 10 comments
Closed

LDAP login failing on 3.10.X #1174

areis422 opened this issue Aug 5, 2021 · 10 comments
Milestone

Comments

@areis422
Copy link

areis422 commented Aug 5, 2021

Version(s) affected: 3.10.x (specifically 3.10.5 and 3.10.6)
PHP Version: 7.4.22 (didn't change between 3.9.2 and 3.10.6)

Description
With LDAP enabled and working in 3.9.2, upgrading to 3.10.X results in the following message after submitting the login:
Sorry, there was an error logging you in: Call to a member function get() on null

How to reproduce

  1. have instance running on 3.9.2 with LDAP via Active Directory enabled.
  2. Upgrade to 3.10.6
  3. Fail on login

Additional context
Log messages:

[2021-08-05 01:16:33] auth.INFO: Login attempt by 'user' was successful. {"user":"user","type":"success","extra":null} {"file":"/var/www/eventum-3.10.6/lib/eventum/class.auth.php","line":85,"class":"Auth","function":"saveLoginAttempt","memory_peak_usage":"4 MB","memory_usage":"4 MB","url":"/login.php/login.php","ip":"x.x.x.x","http_method":"POST","server":"staging.eventum.domain.tld","referrer":"https://staging.eventum.domain.tld/login.php"}
[2021-08-05 01:16:33] app.CRITICAL: Unable to instantiate auth adapter {"exception":"[object] (Error(code: 0): Call to a member function get() on null at /var/www/eventum-3.10.6/src/ServiceContainer.php:89)"} {"file":"/var/www/eventum-3.10.6/lib/eventum/class.auth.php","line":476,"class":"Auth","function":"getAuthBackend","memory_peak_usage":"2 MB","memory_usage":"2 MB","url":"/list.php","ip":"x.x.x.x","http_method":"GET","server":"staging.eventum.domain.tld","referrer":"https://staging.eventum.domain.tld/login.php"}

Auth config (from setup.php):

    'auth' => [
        'adapter' => 'Eventum\\Auth\\Adapter\\ChainAdapter',
        'options' => [
            'Eventum\\Auth\\Adapter\\MysqlAdapter' => null,
            'Eventum\\Auth\\Adapter\\ChainAdapter' => [
                [
                    'Eventum\\Auth\\Adapter\\MysqlAdapter',
                    'Eventum\\Auth\\Adapter\\LdapAdapter',
                ],
            ],
            'Eventum\\Auth\\Adapter\\LdapAdapter' => null,
        ],
        'login_backoff' => [
            'count' => null,
            'minutes' => 15,
        ],
    ],

LDAP Configuration (redacted):

    'ldap' => [
        'active_dn' => 'dc=domain,dc=tld',
        'inactive_dn' => 'ou=Disabled Users,OU=Users,OU=office,dc=domain,dc=tld',
        'default_role' => [
            1 => '6',
        ],
        'binddn' => 'user@domain.tld',
        'bindpw' => 'somepassword',
        'host' => 'domaincontroller.domain.tld',
        'port' => '636',
        'encryption' => 'ssl',
        'basedn' => 'dc=domain,dc=tld',
        'user_id_attribute' => 'sAMAccountName',
        'userdn' => 'DOMAIN\\%UID%',
        'user_filter' => '(&(sAMAccountName={username})(memberOf=CN=somegroup,OU=Roles,OU=Groups,OU=office,DC=domain,DC=tld))',
        'customer_id_attribute' => '',
        'contact_id_attribute' => '',
        'create_users' => '1',
    ],
@glensc
Copy link
Member

glensc commented Aug 5, 2021

The error comes from here:

Need fuller trace of why this is happening.

Add such debug code to get it:

            $container = static::getKernel()->getContainer();
            if (!$container) {
                $e = new \Exception();
                error_log($e->getTraceAsString());
            }

@areis422
Copy link
Author

areis422 commented Sep 8, 2021

Here's the error:

[Wed Sep 08 08:28:51.247700 2021] [proxy_fcgi:error] [pid 879497:tid 139643479652096] [client SOMEIP:15734] AH01071: Got error 'PHP message: 
#0 /var/www/eventum-3.10.6/src/Auth/Adapter/LdapAdapter.php(68): Eventum\\ServiceContainer::getLogger()
#1 [internal function]: Eventum\\Auth\\Adapter\\LdapAdapter->__construct()
#2 /var/www/eventum-3.10.6/src/Auth/Adapter/Factory.php(34): ReflectionClass->newInstanceArgs()
#3 /var/www/eventum-3.10.6/src/Auth/Adapter/ChainAdapter.php(29): Eventum\\Auth\\Adapter\\Factory::create()
#4 [internal function]: Eventum\\Auth\\Adapter\\ChainAdapter->__construct()
#5 /var/www/eventum-3.10.6/src/Auth/Adapter/Factory.php(34): ReflectionClass->newInstanceArgs()
#6 /var/www/eventum-3.10.6/lib/eventum/class.auth.php(473): Eventum\\Auth\\Adapter\\Factory::create()
#7 /var/www/eventum-3.10.6/lib/eventum/class.auth.php(99): Auth::getAuthBackend()
#8 /var/www/eventum-3.10.6/src/Controller/ListController.php(81): Auth::checkAuthentication()
#9 /var/www/eventum-3.10.6/src/Controller/BaseController.php(80): Eventum\\Controller\\ListController->canAccess()
#10 /var/www/eventum-3.10.6/htdocs/list.php(17): Eventum\\Controlle...PHP message: [2021-09-08 08:28:50] app.CRITICAL: Unable to instantiate auth adapter {"exception":"[object] (Error(code: 0): Call to a member function get() on null at /var/www/eventum-3.10.6/src/ServiceContainer.php:93)"} {"file":"/var/www/eventum-3.10.6/lib/eventum/class.auth.php","line":476,"class":"Auth","function":"getAuthBackend","memory_peak_usage":"4 MB","memory_usage":"4 MB","url":"/list.php","ip":"SOMEIP","http_method":"GET","server":"URL","referrer":"https://URL/login.php"}', referer: https://URL/login.php

@vladsf
Copy link
Contributor

vladsf commented Sep 15, 2021

I guess src/Auth/Adapter/LdapAdapter.php is borken since 3.10.2 #898

@areis422

This comment has been minimized.

@vladsf
Copy link
Contributor

vladsf commented Sep 29, 2021

@areis422 I tried to fix myself but failed so I changed to $this->logger = ServiceContainer::getLogger(); and continued.

@areis422

This comment has been minimized.

@shiyamk
Copy link

shiyamk commented Nov 12, 2021

Thank you. it worked

@areis422

This comment has been minimized.

@areis422

This comment was marked as spam.

@areis422
Copy link
Author

areis422 commented Mar 20, 2023

Still currently exists in v3.10.12. Will this be released as part of v3.10.13?

I manually added the fix from #1482 to src/ServiceContainer.php and can confirm it seems to work. Thank you @glensc for all the work you guys do!

@glensc glensc closed this as completed Mar 21, 2023
@glensc glensc added this to the 3.10.13 milestone Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants