snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
10.86k stars 3.14k forks source link

LDAP Authentication #10260

Open DPNADM opened 2 years ago

DPNADM commented 2 years ago

Debug mode

Describe the bug

I have been having some issues with LDAP authentication. Those that were previously logged in and selected "remember me" still access the page post upgrade fine. Those that are trying to log in with their AD username and password are no longer able to.

I have verified that the LDAP module is still on the server. No changes in our settings for LDAP have been made; however, now if I select Test LDAP synchronization I receive "LDAP is not enabled, cannot test." It was enabled prior to the upgrade and the setting page still has it selected. I am unsure where on the backend to look to ensure it is enabled as well.

The LDAP sync itself still appears to function even though the admin page behavior is acting this way and authentication is not working.

I am running PHP 7.4 and have seen some articles stating LDAP and PHP 7.4 appear to have issues. I am unsure how to downgrade to PHP 7.3 and have Snipe-IT utilize that version instead.

Reproduction steps

  1. Attempt to login, cannot do so using methods that worked prior to upgrade.
  2. Logging in local and going to the LDAP settings page, I cannot get a successful test for LDAP synchronization, states "LDAP is not enabled"
  3. Unchecking/rechecking the enabled box just leads to a 500 error page.
  4. Ran LDAP sync and that works, but authentication via LDAP does not.

Expected behavior

Authenticate with LDAP credentials

Screenshots

No response

Snipe-IT Version

5.3.0

Operating System

Ubuntu 20.04.3 LTS

Web Server

Apache

PHP Version

7.4.3

Operating System

Windows

Browser

Chrome and Edge

Version

Edge Version: 95.0.1020.40

Device

NA

Operating System

NA

Browser

NA

Version

NA

Error messages

[stacktrace]
#0 /var/www/snipeit/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(371): Swift_Transport_Esmtp_AuthHandler->afterEhlo()
#1 /var/www/snipeit/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(148): Swift_Transport_EsmtpTransport->doHeloCommand()
#2 /var/www/snipeit/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(65): Swift_Transport_AbstractSmtpTransport->start()
#3 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(488): Swift_Mailer->send()
#4 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(261): Illuminate\\Mail\\Mailer->sendSwiftMessage()
#5 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php(65): Illuminate\\Mail\\Mailer->send()
#6 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(148): Illuminate\\Notifications\\Channels\\MailChannel->send()
#7 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(106): Illuminate\\Notifications\\NotificationSender->sendToNotifiable()
#8 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(29): Illuminate\\Notifications\\NotificationSender->Illuminate\\Notifications\\{closure}()
#9 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(109): Illuminate\\Notifications\\NotificationSender->withLocale()
#10 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(79): Illuminate\\Notifications\\NotificationSender->sendNow()
#11 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(39): Illuminate\\Notifications\\NotificationSender->send()
#12 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Notifications/RoutesNotifications.php(18): Illuminate\\Notifications\\ChannelManager->send()
#13 /var/www/snipeit/app/Console/Commands/SendExpectedCheckinAlerts.php(53): App\\Models\\User->notify()
#14 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\\Console\\Commands\\SendExpectedCheckinAlerts->handle()
#15 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#16 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()
#17 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod()
#18 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/Container.php(590): Illuminate\\Container\\BoundMethod::call()
#19 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\\Container\\Container->call()
#20 /var/www/snipeit/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute()
#21 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run()
#22 /var/www/snipeit/vendor/symfony/console/Application.php(1009): Illuminate\\Console\\Command->run()
#23 /var/www/snipeit/vendor/symfony/console/Application.php(273): Symfony\\Component\\Console\\Application->doRunCommand()
#24 /var/www/snipeit/vendor/symfony/console/Application.php(149): Symfony\\Component\\Console\\Application->doRun()
#25 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\\Component\\Console\\Application->run()
#26 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\\Console\\Application->run()
#27 /var/www/snipeit/artisan(35): Illuminate\\Foundation\\Console\\Kernel->handle()
#28 {main}

[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Additional context

This was upgraded using the install.sh

welcome[bot] commented 2 years ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

DPNADM commented 2 years ago

I thought I would try to upgrade since v. 5.3.1 is out. Unsure if the upgrade output is helpful or not, but here it is. The problem persists.


WELCOME TO THE SNIPE-IT UPGRADER!

This script will attempt to:


STEP 1: Checking PHP requirements:

Current PHP version: (7.4.3) is at least 7.2.5 - continuing... FYI: The php.ini used by this PHP is: /etc/php/7.4/cli/php.ini

Checking Required PHP extensions...

√ bcmath is installed! √ curl is installed! √ fileinfo is installed! √ gd is installed! √ json is installed! √ ldap is installed! √ mbstring is installed! √ mysqli is installed! √ openssl is installed! √ PDO is installed! √ tokenizer is installed! √ xml is installed! √ zip is installed!


STEP 2: Backing up database:

-- Starting backup... Backup failed because: mkdir(): Permission denied.


STEP 3: Putting application into maintenance mode:

-- Application is now in maintenance mode.


STEP 4: Pulling latest from Git (master branch):

Git is installed. remote: Enumerating objects: 145, done. remote: Counting objects: 100% (142/142), done. remote: Compressing objects: 100% (24/24), done. remote: Total 69 (delta 50), reused 58 (delta 45), pack-reused 0 Unpacking objects: 100% (69/69), 79.35 KiB | 262.00 KiB/s, done. From https://github.com/snipe/snipe-it 76cc46c41..9ed1442bd master -> origin/master eae9bf574..98de8526d develop -> origin/develop


Step 5: Cleaning up old cached files:

√ No bootstrap/cache/compiled.php, so nothing to delete. √ No bootsrap/cache/services.php, so nothing to delete. √ No bootstrap/cache/config.php, so nothing to delete.

-- Configuration cache cleared! -- Failed to clear cache. Make sure you have the appropriate permissions. -- Route cache cleared! -- Compiled views cleared!


Step 6: Updating composer dependencies: (This may take a moment.)

-- We couldn't find a local composer.phar. No worries, trying globally.

Generating optimized autoload files> Illuminate\Foundation\ComposerScripts::postAutoloadDump Generated optimized autoload files containing 6032 classes Loading composer repositories with package information Installing dependencies from lock file Nothing to install or update Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead. Package patchwork/utf8 is abandoned, you should avoid using it. Use symfony/polyfill-mbstring or symfony/string instead. Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump


Step 7: Migrating database:

Migrating: 2019_04_06_060145_add_user_skin_setting

UnexpectedValueException : The stream or file "/var/www/snipeit/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

at /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:111 107| restore_error_handler(); 108| if (!is_resource($this->stream)) { 109| $this->stream = null; 110|

111| throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in append mode: '.$this->errorMessage, $this->url)); 112| } 113| } 114| 115| if ($this->useLocking) {

Exception trace:

1 Monolog\Handler\StreamHandler::write() /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php:42

2 Monolog\Handler\AbstractProcessingHandler::handle() /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Logger.php:317

Please use the argument -v to see more details.


Step 8: Checking for OAuth keys:

√ OAuth keys detected. Skipping passport install.


Step 9: Taking application out of maintenance mode:

-- Application is now live.

---------------------- FINISHED! ----------------------- All done! Clear your browser cookies and re-login to use your upgraded Snipe-IT!

Also...here is a screenshot from the admin page showing the behavior. For the past two years I have not had issues with LDAP, just with the recent upgrades. I suspect maybe PHP 7.4 is to blame based on my reading but I'm unsure the steps to take to install 7.3 and point Snipe-IT to it?

image

GitHub
GitHub - snipe/snipe-it: A free open source IT asset/license management system
A free open source IT asset/license management system - GitHub - snipe/snipe-it: A free open source IT asset/license management system
Kreidos commented 2 years ago

It's possible since this server has been running a while, you might have upgraded from PHP 7.3 to 7.4 without actually disabling the PHP7.3 module in Apache... Maybe check if you installed libapache2-mod-php7.4 and have it enabled?