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

Server Error : Unauthorized

Open bakfiets2 opened this issue 6 years ago • 146 comments

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

Describe the bug Fresh install of Snipe-It on a server Running Plesk Onyx. PHP Composer installs fine. Tried installing 4.8.0 and 4.8.5. Tried all PHP versions from 7 and up.

The thing is. If i want to add a Category. Lets say. In Licenses. The drop down menu tells me that the Results could not be loaded. If i try to add the category the window says: Server Error : Unauthorized

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Licenses -> Category drop down -> Then New -> Add'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Server (please complete the following information):

  • Snipe-IT Version : 4.6.4
  • OS: Ubuntu 18.04.5 LTS. Plesk Obsidian Version 18.0.30
  • Web Server: Apache
  • PHP Version :

Desktop (please complete the following information):

  • OS: [e.g. iOS] Mac Os Catalina. Windows 10 Pro
  • Browser Safar, Firefox, Microsoft Edge
  • Version [e.g. 22]

Error Messages Version v4.9.4 - build 4437 (master) Snipe-IT is open source software, made with love by @snipeitapp. 7.4.10358ms4MB5.5.50productionnlGET api/v1/categories/{item_type}/selectlist

Unauthenticated./var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php#66Illuminate\Auth\AuthenticationException

            }
        }

        throw new AuthenticationException('Unauthenticated.', $guards);
    }
}

#0 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(41): Illuminate\Auth\Middleware\Authenticate->authenticate()
#1 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Auth\Middleware\Authenticate->handle()
#2 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#3 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#4 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\Pipeline\Pipeline->then()
#5 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\Router->runRouteWithinStack()
#6 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(601): Illuminate\Routing\Router->runRoute()
#7 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(590): Illuminate\Routing\Router->dispatchToRoute()
#8 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch()
#9 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
#10 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#11 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle()
#12 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#13 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/app/Http/Middleware/SecurityHeaders.php(26): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#14 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\SecurityHeaders->handle()
#15 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#16 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#17 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#18 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#19 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/app/Http/Middleware/CheckForDebug.php(25): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#20 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\CheckForDebug->handle()
#21 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#22 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/app/Http/Middleware/CheckForSetup.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#23 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\CheckForSetup->handle()
#24 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#25 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#26 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Fideloper\Proxy\TrustProxies->handle()
#27 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#28 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#29 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\View\Middleware\ShareErrorsFromSession->handle()
#30 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#31 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#32 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Session\Middleware\StartSession->handle()
#33 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#34 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#35 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()
#36 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#37 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/barryvdh/laravel-cors/src/HandlePreflight.php(29): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#38 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Barryvdh\Cors\HandlePreflight->handle()
#39 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#40 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#41 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then()
#42 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#43 /var/www/vhosts/ict.jellevansetten.nl/httpdocs/public/index.php(58): Illuminate\Foundation\Http\Kernel->handle()
#44 {main}

bakfiets2 avatar Sep 20 '20 15:09 bakfiets2

Same exact error for me as well

snipeit version: v4.9.5 - build 4482 (master)

OS: Windows Server 2019 Windows IIS Server: 10.0.17763.1

LDAP enabled and working. AD user able to login Non AD Admin user created on setup works

All are unable to see anything in snipeit with the above error.

yosiasz avatar Sep 22 '20 17:09 yosiasz

spun up snipe-it 4.8.0, identical issue. This means the issue is most probably environmental.

yosiasz avatar Sep 22 '20 19:09 yosiasz

After 4 days of searching. No results yet. Checked a lot of right things. Tried 2 different servers. Not much to find about this error btw

bakfiets2 avatar Sep 22 '20 19:09 bakfiets2

for now, just to get out of the error (do not do this in production system) and to see what is going on, I commented out the following line 41 of C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Auth\Middleware\Authenticate.php

// $this->authenticate($guards);

restart web server and things are looking good. So I can troubleshoot further.

yosiasz avatar Sep 22 '20 20:09 yosiasz

Cool. Going to try that tomorrow!

bakfiets22 avatar Sep 22 '20 20:09 bakfiets22

So, we're starting to see a little bit of this with some of our customers (not-hosted). I don't have any definitive answers yet, but it's at least reproducible across multiple systems, which is a good start.

If you can tell me what happens if you run the following:

php artisan passport:install
php artisan migrate
php artisan passport:client --personal

log out, log back in, try to reproduce again, and tail the logs as you do.

We'll figure this out. Something changed, and it wasn't the version of Laravel, so I'm confident we can find the common thread here.

snipe avatar Sep 22 '20 22:09 snipe

Never met forge :)

SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: YES)

yosiasz avatar Sep 22 '20 22:09 yosiasz

If you see that, it means one of two things...

Either you didn't set your MySQL info in the .env, OR, you have a parse error higher up in the .env (weird characters that are not enclosed in quotes, for example) so that the .env cannot be read.

snipe avatar Sep 22 '20 22:09 snipe

apologies, I was in another snipe 4.8 folder when I did this. went back to latest v4.9.5 - build 4482 (master) folder and those commands did not fix the original issue.

yosiasz avatar Sep 22 '20 22:09 yosiasz

@yosiasz roger that - can you successfully create an API key through the web UI? (Go to your name in the top left, and then API keys)

snipe avatar Sep 22 '20 22:09 snipe

yes I am able to create an API key (from top right)

yosiasz avatar Sep 22 '20 22:09 yosiasz

So this is the same thing we're seeing on only self-hosted folks. Nothing big has changed in the last few versions of Snipe-IT, so I have to wonder if it's an environmental change? Do you know if you're running SELinux?

snipe avatar Sep 22 '20 22:09 snipe

We are using IIS on Windows Server 2019. Not sure if that answers the question.

yosiasz avatar Sep 22 '20 22:09 yosiasz

    public function handle($request, Closure $next, ...$guards)
    {
        //echo implode("X",$guards);
		$this->authenticate($guards); -->Commenting this out, makes it "work"

        return $next($request);
    }

yosiasz avatar Sep 22 '20 22:09 yosiasz

It does :D

Can you show me the perms on your storage directory and subdirectories?

Sometimes we see highly conflated log errors because the log itself (or temp directories) are writable by the current user, but not the web server.

You can't realistically comment that out tho - It's literally what controls all permissions within the system.

snipe avatar Sep 22 '20 22:09 snipe

Can all of you on the the thread let me know what specific version of PHP you're using? Wondering if maybe it's an esoteric artifact of a minor version change in PHP

snipe avatar Sep 22 '20 22:09 snipe

PHP 7.4 nts.

I purposely gave IUSR full control on storage

image

yosiasz avatar Sep 22 '20 22:09 yosiasz

I suspect, it is environmental php modules that were update such as ldap.

yosiasz avatar Sep 22 '20 23:09 yosiasz

@yosiasz TYSM for your patience here. I know we run PHP 7.3 for all of our hosted customers.

I'd love to hear from others who are having this issue with respect to what version they're using. If we can figure out what's happening here, it would be a huge win for many of the folks who use this software.

snipe avatar Sep 22 '20 23:09 snipe

@uberbrady can you reproduce this on your linux PHP 7.4 install?

snipe avatar Sep 22 '20 23:09 snipe