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

Trouble getting Cachet to work on custom apache/php setup -- help appreciated! #2064

Closed
jsdavis opened this issue Aug 16, 2016 · 12 comments
Closed

Comments

@jsdavis
Copy link

jsdavis commented Aug 16, 2016

Background Info

Okay, so I understand my situation is not at all supported; really, I could just use a hint from somebody with more intimate knowledge of this software to help me figure out what's going on here.

I'm interning at a company that would like to use Cachet internally; however, this company has strict security rules and heavily customizes much of their software. As a result, I am required to use an internal version of apache and php to integrate Cachet into the corporate environment. I've already gotten it set up using php56 and httpd as a proof of concept, but I'm having difficulties getting it to work on our stack.

Environment

php version --> 5.6
apache version --> 2.4

rm -rf /bootstrap/cache/* --> Didn't help :(

The Problem

After a few tweaks, I've been mostly successful in my efforts; however, I have two problems whose solutions I can't seem to begin to figure out:

  1. CSRF token validation fails for every form
  2. When I disable CSRF token validation (by removing the CSRF Middleware from Laravel), I cannot log in. The page displays a 404, with the URL of /auth/dashboard.

Tweaks Made

  1. We use an inhouse filtering solution for PHP, so we wrote a polyfill for filter_vars() that calls our inhouse solution.
  2. In order to install composer, I simply removed the check for the filter extension in the composer installer
  3. Our version of apache requires a "DirectoryIndex index.php" directive in the VirtualHost block

There may be other differences present, but the gist of it is that I have NO IDEA where to be looking; 2 weeks ago I'd never seen a line of PHP or apache configuration in my life, so I'm a little overwhelmed.

Expected behaviour

Expecting to be taken to the admin dashboard on login

Actual behaviour

Browser attempts to redirect to /auth/dashboard and hits a 404. Laravel logs say it gets stuck at authentication, at a line where it throws a 403 error, I believe due to invalid credentials. However, I've gotten this on 3 separate installations and I am 100% certain the credentials are valid.

Again, I get that this situation is totally unsupported since there's no way you guys can know what's different in my setup, but if I could even know where I should be looking to fix this it would be a great help.

@jsdavis
Copy link
Author

jsdavis commented Aug 16, 2016

Laravel log on the aformentioned 404

[2016-08-16 21:09:33] production.WARNING: exception 'Symfony\Component\HttpKernel\Exception\HttpException' in /home/y/share/html/Cachet/app/Http/Middleware/Authenticate.php:51
Stack trace:
#0 [internal function]: CachetHQ\Cachet\Http\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))
#1 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#2 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#3 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#4 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#5 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#6 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#7 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#8 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#9 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#10 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#11 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#12 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#13 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#14 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#15 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#16 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#17 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#18 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#19 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#20 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#21 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#22 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#23 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#24 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#25 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#26 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#27 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(699): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#28 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(675): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#29 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(246): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#30 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}(Object(Illuminate\Http\Request))
#31 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#32 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#33 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#35 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#36 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#37 /home/y/share/html/Cachet/vendor/fideloper/proxy/src/TrustProxies.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#38 [internal function]: Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#39 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#40 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#41 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#42 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#43 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#44 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#45 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(99): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#46 /home/y/share/html/Cachet/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#47 {main} {"identification":{"id":"299dad5f-fe91-46ff-a350-b7abd4ed3f37"}}

@jsdavis
Copy link
Author

jsdavis commented Aug 17, 2016

Laravel log for error submitting form when CSRF validation is turned on

[2016-08-15 22:41:11] production.NOTICE: exception 'Illuminate\Session\TokenMismatchException' in /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:67
Stack trace:
#0 [internal function]: Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#1 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#2 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#3 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#4 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#5 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#6 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#7 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#8 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#9 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#10 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#11 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#12 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#13 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#14 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#15 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#16 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#17 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#18 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#19 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#20 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#21 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#22 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#23 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#24 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#25 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#26 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#27 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(699): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#28 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(675): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#29 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(246): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#30 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}(Object(Illuminate\Http\Request))
#31 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#32 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#33 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#35 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#36 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#37 /home/y/share/html/Cachet/vendor/fideloper/proxy/src/TrustProxies.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#38 [internal function]: Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#39 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#40 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#41 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#42 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#43 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#44 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#45 /home/y/share/html/Cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(99): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#46 /home/y/share/html/Cachet/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#47 {main} {"identification":{"id":"e0ee90e4-3081-46b6-8ab7-36c52b66ca86"}}

@jbrooksuk
Copy link
Member

As you said before, this kind of installation is completely unsupported and without intimate or "on-site" access, we'd be shooting in the dark.

We do offer an installation service if that's of any use?

@GrahamCampbell
Copy link
Contributor

What session driver are you using please?

@jsdavis
Copy link
Author

jsdavis commented Aug 17, 2016

@jbrooksuk I don't think we'll be going for the installation service, unfortunately.

@GrahamCampbell I'm using the file driver for sessions and cache

@GrahamCampbell
Copy link
Contributor

Try using redis or apc.

@jsdavis
Copy link
Author

jsdavis commented Aug 17, 2016

After trying it with redis (our internal version of PHP has deprecated apc), I've had no luck. On login attempts with CSRF token validation enabled, I get the TokenMismatchException. When I remove the CSRF Middleware from app/Http/Kernel.php, I get a 404 at /auth/dashboard.

Oddly enough, the non-company-compliant installation I set up seems to redirect at /dashboard after a login, not /auth/dashboard -- although that path may just be an intermediate that it glosses over quickly.

Anyway, I installed Redis, configured it in .env, 'require'ed predis/predis, and then ran
php artisan config:cache
php artisan cache:clear
rm -rf bootstrap/cache/*

And restart apache, but to no avail...

@jsdavis
Copy link
Author

jsdavis commented Aug 17, 2016

Digging really deep into some really old documentation, I have found that $_COOKIE and $_ENV are disabled in our version of PHP.

Even further digging shows that $_COOKIE and $_ENV are only referenced in composer, symfony, guzzlehttp, psr, and vlucas. Also none of the files that are reported in the Laravel stack traces

@GrahamCampbell
Copy link
Contributor

Laravel does use them. It loads them into the symfony request object right at the start.

@GrahamCampbell
Copy link
Contributor

Closing since this isn't a bug in cachet. Feel free to keep the discussion going if you want though. :)

@GrahamCampbell
Copy link
Contributor

Even further digging shows that $_COOKIE and $_ENV are only referenced in composer, symfony, guzzlehttp, psr, and vlucas. Also none of the files that are reported in the Laravel stack traces

Laravel uses all those deps, or cachet does in some way. We didn't just install them for the lols. :P

@jsdavis
Copy link
Author

jsdavis commented Aug 17, 2016

I know Laravel uses those, but what I wonder why none of them show up in the stack trace for the errors? Essentially, if I'm committing to patching those out for our installation, I need to know they're actually causing the issues I'm having

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants