Invalid CSRF token on sulu CMF (production) - symfony

I've managed setting up a development environment running Symfony and sulu cmf. For production I have done the same, but then both Symfony and sulu with production-environment setting.
Everything is running fine except one small issue. When I want to log in, Chrome console shows me 'Invalid CSRF token'
I have cleared the cache of both browser and server, but it does not make any difference.
Any suggestions/experience with this issue?

Related

How to diagnose why one-tap popup not showing in production

I added google one-tap to our web app, tested it well working at localhost (see pic).
After deploying to production (react optimized code), the one-tap dialog doesn't show up, checking network traffic, seems some of the requests are missing compared to localhost, but not sure how to diagnose what the root cause is, any help?
(note: I have tried production URL in incognito mode and restarted my browser)
Localhost: (http://localhost:3000)
Production (https://columns.ai)
I’m not sure if it's related to the OAuth scope, but I added the opened and profile scopes, and it's now working in production. However, I can't verify if this is what fixed it.

SilverStripe 4.1 - SS_DEFAULT_ADMIN_USERNAME and PASSWORD not respected

I have a SilverStripe 4.1 site (upgraded from 3.4) running on an Ubuntu Vagrant VM. I have the following .env file:
# Default Admin
SS_DEFAULT_ADMIN_USERNAME="admin"
SS_DEFAULT_ADMIN_PASSWORD="password"
# DB credentials
SS_DATABASE_CLASS="MySQLPDODatabase"
SS_DATABASE_SERVER="127.0.0.1"
SS_DATABASE_USERNAME="user"
SS_DATABASE_PASSWORD="pass"
SS_DATABASE_NAME="silverstripe"
# environment
SS_ENVIRONMENT_TYPE="dev"
The site otherwise works, and complains when .env is deleted, so it's being read by the site.
However, when I go to /admin to log in with the above admin username and password the login page just refreshes with this message:
You must be logged in to access the administration area; please enter your credentials below.
I've tried moving the .env file to different locations. Multiple dev/build?flush=all, a flush=all on the login page itself and manually deleting the silverstripe cache in /tmp. There are no errors on screen or in the logs.
Has anyone had this issue before, or can guess what may be causing this, or how I might trap any errors in a log?
The issue was the client side cookies on the site. Something in the cookies must have been incorrect after the update, causing the log in to never go to the correct admin URL.
Using an incognito browser tab (or another browser) worked correctly, showing that the cookies needed to be cleared. I cleared my domain cookies and then the log in worked correctly again.

Xdebug with PhpStorm stops working when assigning an URL for Symfony debug server

I'm developing a Symfony PHP Application which uses Azure Active Directory authentication. I'm using PhpStorm on Windows 10 as my IDE.
Azure Active Directory requires me to register a redirect URL but doesn't allow it to be http://127.0.0.1:8000 so I had to register http://localhost:8000
For that reason, in PhpStorm, I had to change my Run/Debug Configuration in order to change bin\console arguments from server:run to server:run localhost:8000.
But since I did that, PhpStorm no longer stops at my assigned breakpoints, as if it weren't listening to Xdebug's connections, although it is set to do so. I'm sure the problem is the new URL, because when I rolled back my change, it came back to normal.
I know the question is rather specific.

ZF3 - ZfcUser cant take identity from session

I have very strange problem. I use ZfcUser as authentication module. I made a lot of projects on lot of different environments using ZF3 and ZfcUser module. I have nevere experienced such kind of problem which I will explain bellow. In my current project I cant login into system on production server. I succesfuly log from local env, or other test environments.
I try to investigate whats going on. I went to login page on production, entered my credentials and system redirects me to home page. No errors, no warnings... notihnig. But I was not logged in. I check the identity from the framework (identity()) - it was null. I thought that may be it is server issue with the php sessions. I checked the sessions on server. It appears that the problem was not there.
The framework succesfully stored the data it needs in sessions. I found the Zend_Auth key, the identity key and the value for logged user. It seems that with php sessions everything is OK.
I am powerless and cant even think about what is going on here and where is the problem. No errors are thrown. I trace the execution of code on local and production environment. Everything is same. The frameworks seems to work properly. But the IDENTITY is allways null
Found the problem.
So, the site was runing under a subdomain. Let say sub.domain.tld. This site is different from main domain which is domain.tld. In the programm code, the favicon of application was requested form the domain.tld not from the sub.domain.tld.
As a result when you hit the http://sub.domain.tld the browser stores two PHPSESSID cookies. One under sub.domain and another under domain.tld which couses Chrome to messed up
Interesting is that, Firefox and IE didnt messed with the sessions and the site was working porperly. I dont say that Crhome is guilty. Obviously the programm code was cousing the problem. But Chrome recognize that one domain is sub domain of the other
Thats why, when I was trying to run project on different environments as local setup or different domain e.g. test.different-domain.tld, ther were again two PHPSESSID cookies set, but in this time Chrome didnt messed up with the sessions becouse test.different-domain.tld is not recognized as subdomain of domain.tld
Very small and silly mistake, but cousing big problems

Symfony2: access same route in production as development

I'm developing a little application using Symfony2. I can access all routes with no problems in my dev environment:
http://symfony/app_dev.php/cp ("symfony" is in my hosts file to resolve to localhost)
However, as soon as I try and access it in the production environment, I just get a 404 error page:
http://symfony/app.php/cp
Oops! An Error Occurred
The server returned a "404 Not Found".
Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
Is there something I need to change/do before I can view my application in production? I've not messed with any of the core files (kernel/bootstrap/app files, etc). I'm using Release Candidate 3.
As Crozin already mentioned in his comment, you have to rebuild cache to be able to see your changes. You need to rebuild production cache every time you change something in config, routing or templates. The safest way to do so is using php app/console cache:clear --env=prod --no-debug (as CLI runs in dev mode with debugging enabled by default).

Resources