snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

v3 Upgrade No Login

Open elJoeyJojo opened this issue 10 years ago • 17 comments

Expected Behavior (or desired behavior if a feature request)

I upgraded to v3 and everything went well but I can't login with any LDAP account and with my local snipeit (admin) account.


Actual Behavior

I keep getting this error after typing in the credentials:

"Whoops, looks like something went wrong"


Please confirm you have done the following before posting your bug report:


Please provide answers to these questions before posting your bug report:

  • Version of Snipe-IT you're running - v3
  • What OS and web server you're running Snipe-IT on - CentOS 6.8
  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) - Manual Upgrade
  • If you're getting an error in your browser, include that error - "Whooops, looks like something went wrong"
  • What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error - Login Screen
  • If a stacktrace is provided in the error, include that too.
  • Any errors that appear in your browser's error console.
  • Confirm whether the error is reproduceable on the demo.
  • Include any additional information you can find in app/storage/logs and your webserver's logs. -

[2016-07-11 10:48:42] production.DEBUG: LDAP is enabled. [2016-07-11 10:48:42] production.DEBUG: Auth lookup complete [2016-07-11 10:48:42] production.DEBUG: Local user snipeit exists in database. Authenticating existing user against LDAP. [2016-07-11 10:48:42] production.ERROR: exception 'ErrorException' with message 'ldap_set_option(): supplied argument is not a valid ldap link resource' in /opt/snipe-it/app/Http/Controllers/Auth/AuthController.php:94

  • Include what you've done so far in the installation, and if you got any error messages along the way.
  • Indicate whether or not you've manually edited any data directly in the database

elJoeyJojo avatar Jul 11 '16 20:07 elJoeyJojo

I want to disable LDAP from the configuration files but not sure where this is set.

elJoeyJojo avatar Jul 11 '16 20:07 elJoeyJojo

https://snipe-it.readme.io/docs/disabling-ldap

snipe avatar Jul 11 '16 20:07 snipe

thank you!!! :)

elJoeyJojo avatar Jul 11 '16 20:07 elJoeyJojo

you're the best Snipe!!!

elJoeyJojo avatar Jul 11 '16 20:07 elJoeyJojo

seems like the same LDAP Settings from v2 don't work for v3 Am I missing anything?

image

My logs report:

[2016-07-11 13:26:13] production.DEBUG: Authenticating user against database. [2016-07-11 13:54:07] production.DEBUG: LDAP is enabled. [2016-07-11 13:54:07] production.DEBUG: Auth lookup complete [2016-07-11 13:54:07] production.DEBUG: Local user anthony.delarosa does not exist [2016-07-11 13:54:07] production.ERROR: exception 'ErrorException' with message 'ldap_set_option(): supplied argument is not a valid ldap link resource' in /opt/snipe-it/app/Http/Controllers/Auth/AuthController.php:94 Stack trace: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'ldap_set_option...', '/opt/snipe-it/a...', 94, Array)

Line 94 of file /opt/snipe-it/app/Http/Controllers/Auth/AuthController.php is:

ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);

elJoeyJojo avatar Jul 11 '16 23:07 elJoeyJojo

This is an absolute longshot, but can you look at line 92, and tell me if if says:

$connection = ldap_connect($ldaphost) or die("Could not connect to {$ldaphost}");

or

$connection = ldap_connect($ldaphost) || die("Could not connect to {$ldaphost}");

And if it says:

$connection = ldap_connect($ldaphost) || die("Could not connect to {$ldaphost}");

can you change it to:

$connection = ldap_connect($ldaphost) or die("Could not connect to {$ldaphost}");

and try again?

(UPDATE: I reversed it in my original reply - corrected now.)

snipe avatar Jul 11 '16 23:07 snipe

Thanks Snipe! I did change it to "or die" but still no login. Same "Whoops, looks like something went wrong"

Although now I get another error in the logs:

[2016-07-11 14:52:40] production.DEBUG: LDAP is enabled. [2016-07-11 14:52:40] production.DEBUG: Auth lookup complete [2016-07-11 14:52:40] production.DEBUG: Local user anthony.delarosa does not exist [2016-07-11 14:52:45] production.DEBUG: Creating local user from authenticated LDAP user. [2016-07-11 14:52:46] production.ERROR: exception 'ErrorException' with message 'Non-static method Illuminate\Database\Eloquent\Model::save() should not be called statically, assuming $this from incompatible context' in /opt/snipe-it/app/Http/Controllers/Auth/AuthController.php:157

Line 157: User::save($newuser);

elJoeyJojo avatar Jul 12 '16 00:07 elJoeyJojo

Okay, let's try this.

Replace this bit in AuthController:

//create user
        if (!empty($item["username"])) {
            //$pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10);

            $newuser = array(
              'first_name' => $item["firstname"],
              'last_name' => $item["lastname"],
              'username' => $item["username"],
              'email' => $item["email"],
              'employee_num' => $item["employee_number"],
              'password' => bcrypt(Input::get("password")), //$pass,
              'activated' => 1,
              'permissions' => ["user" => 1], //'{"user":1}',
              'notes' => 'Imported from LDAP'
            );
            User::save($newuser);

        } else {

with:

//create user
        if (!empty($item["username"])) {
            $newuser = new User;
            $newuser->first_name => $item["firstname"];
            $newuser->last_name => $item["firstnlastnameame"];
            $newuser->username => $item["username"];
            $newuser->email => $item["email"];
            $newuser->password => bcrypt(Input::get("password"));
            $newuser->activated => 1;
            $newuser->permissions => ["user" => 1];
            $newuser->notes => 'Imported from LDAP';
            $newuser->save();

        } else {

I apologize for the jankiness of this. We previously had a free open LDAP server that we could use for LDAP integration testing, but it hasn't worked in a few weeks. I think they may have shut it down :( We've signed up with a third=party LDAP provider today, so we can test more thoroughly moving forward.

snipe avatar Jul 12 '16 02:07 snipe

hey there,

doesn't seem to like the '=>' arrows

[2016-07-12 07:11:17] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'syntax error, unexpected '=>' (T_DOUBLE_ARROW)' in /opt/snipe-it/app/Http/Controllers/Auth/AuthController.php:145

Now when I go into the login screen I'm not getting a login screen but rather just the error "Whoops.."

elJoeyJojo avatar Jul 12 '16 16:07 elJoeyJojo

Remove the > on each line (except for in the user permissions one), it should just be the following.

            $newuser = new User;
            $newuser->first_name = $item["firstname"];
            $newuser->last_name = $item["lastname"];
            $newuser->username = $item["username"];
            $newuser->email = $item["email"];
            $newuser->password = bcrypt(Input::get("password"));
            $newuser->activated = 1;
            $newuser->permissions = ["user" => 1];
            $newuser->notes = 'Imported from LDAP';
            $newuser->save();

mnemonicly avatar Jul 12 '16 17:07 mnemonicly

Hey thanks for your help. Well at least now I get a login screen but I still can't login:

[2016-07-12 10:31:17] production.ERROR: exception 'ErrorException' with message 'Undefined index: firstnlastnameame' in /opt/snipe-it/app/Http/Controllers/Auth/AuthController.php:146

[2016-07-12 10:33:13] production.DEBUG: LDAP is enabled. [2016-07-12 10:33:13] production.DEBUG: Auth lookup complete [2016-07-12 10:33:13] production.DEBUG: Local user anthony.delarosa does not exist [2016-07-12 10:33:13] production.DEBUG: Creating local user from authenticated LDAP user. [2016-07-12 10:33:13] production.ERROR: exception 'ErrorException' with message 'Undefined index: firstnlastnameame' in /opt/snipe-it/app/Http/Controllers/Auth/AuthController.php:146

Line 146: $newuser->last_name = $item["firstnlastnameame"];

Any idea?

At least now it is authenticating with LDAP, but doesn't seem to be able to create the local user in Snipe It.

elJoeyJojo avatar Jul 12 '16 17:07 elJoeyJojo

Yeah, that should be $newuser->last_name = $item["lastname"];. I corrected it in my thingy above but I didn't point out the difference.

mnemonicly avatar Jul 12 '16 17:07 mnemonicly

Still not able to create account based on LDAP authentication. My logs show this now:

[2016-07-12 10:40:28] production.DEBUG: LDAP is enabled. [2016-07-12 10:40:28] production.DEBUG: Auth lookup complete [2016-07-12 10:40:28] production.DEBUG: Local user anthony.delarosa does not exist [2016-07-12 10:40:28] production.DEBUG: Creating local user from authenticated LDAP user. [2016-07-12 10:40:28] production.DEBUG: Authenticating user against database. [2016-07-12 10:40:28] production.DEBUG: Local authentication failed.

Account info is correct and I even tried DOMAIN\username (could it be because of my dot in the usernames?

elJoeyJojo avatar Jul 12 '16 17:07 elJoeyJojo

I refreshed the logs a few times and I got this:

[2016-07-12 10:50:29] production.ERROR: exception 'ErrorException' with message 'preg_replace(): Parameter mismatch, pattern is a string while replacement is an array' in /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Support/helpers.php:747

Line 746, 747: foreach ($replace as $value) { $subject = preg_replace('/'.$search.'/', $value, $subject, 1);

elJoeyJojo avatar Jul 12 '16 17:07 elJoeyJojo

Are you able to pop into the gitter channel? It might be a little easier to talk in real time (https://gitter.im/snipe/snipe-it). I have a few ideas we can play with, but this might require snipe--I don't know the LDAP code well.

mnemonicly avatar Jul 12 '16 17:07 mnemonicly

@elJoeyJojo Can you grab the latest from the v3 branch and tell me if it resolves your issue? (Be sure to run composer dump after you do do.)

snipe avatar Jul 13 '16 13:07 snipe

hey @snipe i was able to get it to work thanks to @dmeltzer and then i helped out another person who had the same issue as me! i like this vibe guys! keep up the good work and thanks for helping me setup v3 on my environment!

elJoeyJojo avatar Jul 13 '16 16:07 elJoeyJojo