crater icon indicating copy to clipboard operation
crater copied to clipboard

Error: CSRF Mismatch and Error: Unauthenticated

Open darrylgibbs opened this issue 2 years ago • 10 comments

OS: Ubuntu 20.04.4 (Virtualbox VM) Docker: 20.10.12

My goal here was to migrate my install to a new server.

I have just downloaded and run the git repo as instructed here for a docker install. I used all the default settings, except changing the APP_URL in the .env file to my need. I went to the URL and ran through the setup process (I'm not sure if this is my failing)

What I want to do is restore a previous backup. I've copied to my server (VM) the zip file with the DB and FILES. I successfully uploaded my DB into the DB container, no errors. I changed all 3 "./:/var/www" bind mounts to my backup folder that I imported, and restarted the containers, and reran the "./docker-compose/setup.sh" command from the root CRATER folder.

If I go to the URL (updated for new VM in the .env) I get the login screen. I type in the credentials and the I get 3 notifications in the top right, in this order: LOGIN SUCCESSFUL, Error: Unauthenticated, Error CSRF Mismatch. I then remain on the login screen.

What am I doing wrong here?

Thanks in advance.

Screenshot 2022-03-03 173504

darrylgibbs avatar Mar 03 '22 20:03 darrylgibbs

Hey there,

You need to add 2 more environment variables on the .env file in order to verify your new domain.

Please read the step 4 on the upgrade guide as it clearly explains what values you need to enter there : https://docs.craterapp.com/upgrade-guide.html#using-auto-installer

SANCTUM_STATEFUL_DOMAINS=demo.craterapp.com SESSION_DOMAIN=demo.craterapp.com

mohitpanjwani avatar Mar 04 '22 03:03 mohitpanjwani

This is still necessary for an original v6 install? These were already there and populated with the IP address as below.

APP_URL=http://192.168.56.101 SANCTUM_STATEFUL_DOMAINS=192.168.56.101 SESSION_DOMAIN=192.168.56.101

No difference in reaction, even after rerunning the "./docker-compose/setup.sh" command.

darrylgibbs avatar Mar 04 '22 09:03 darrylgibbs

This is still necessary for an original v6 install? These were already there and populated with the IP address as below.

APP_URL=http://192.168.56.101 SANCTUM_STATEFUL_DOMAINS=192.168.56.101 SESSION_DOMAIN=192.168.56.101

No difference in reaction, even after rerunning the "./docker-compose/setup.sh" command.

Yes it’s still required.

Can you try to reset your application cache or login from incognito mode once after setting the env variables.

mohitpanjwani avatar Mar 04 '22 10:03 mohitpanjwani

@darrylgibbs did you manage to get it working? Let me know if you are stuck.

mohitpanjwani avatar Mar 06 '22 11:03 mohitpanjwani

@mohitpanjwani sadly no. I've been trying and retrying for days with the same outcome. To recap:

  • I installed the latest version of Crater following the Docker installation documentation, and completed the setup procedure and logged into the app (obviously its all blank)
  • I then took the FILES and DB DUMP from my previous backup and copied it over to the new server. I copied the DB into the DB container, and for simplicity, I remapped the /var/www in the docker-compose file to my backup files.
  • I made the changes as requested (although I'm using the IP address of the VM) to the env file.
  • I've cleared caches and even used a different PC but I get the same login errors
  • I reran the setup script multiple times too, and still the same.

Anything else I can try?

darrylgibbs avatar Mar 06 '22 17:03 darrylgibbs

I managed to solve this Problem, it only occours on local environments.

I think the Problem is Crater only accepts a domain like example.com, 127.0.0.1 or any IP Adress wont work.

I solved this problem in Windows 10 like this way:

  1. Go To the Hosts File C:\Windows\System32\drivers\etc\hosts and add this line:

127.0.0.1 mycraterapp.com

  1. Start Your Apache Server on 127.0.0.1 Port 80 -> So mycraterapp.com will forward to your Server.

3 .Go to your .env file and change this :

APP_URL=http://mycraterapp.com SANCTUM_STATEFUL_DOMAINS=mycraterapp.com SESSION_DOMAIN=mycraterapp.com

  1. Maybe clear Cookies in Your Browser and clear php chache.

I hope your problem goes away like i solved this on my machine.

Cheers

PastClear avatar Mar 31 '22 18:03 PastClear

Thanks, I'll give that a go.

What doesn't make sense though, is on a fresh install, it will accept the IP address of the VM, but when trying to migrate the files to a new VM it bombs.

I have relented and done a traditional LAMP install, but I'd far rather do it in docker. I'll report back later!

darrylgibbs avatar Mar 31 '22 18:03 darrylgibbs

There is a Problem with the Install Process on a Local Machine:

https://github.com/crater-invoice/crater/issues/358 https://github.com/crater-invoice/crater/issues/830

Installation Process just work on Management (Hosted) Webservers. So if you copy that to local you will face also Problems.

After you got a successfull Install (Files+ Database), your are able to use these locally with my Fix.

Give it a Try. Cheers

PastClear avatar Mar 31 '22 20:03 PastClear

I managed to solve this Problem, it only occours on local environments.

I think the Problem is Crater only accepts a domain like example.com, 127.0.0.1 or any IP Adress wont work.

I solved this problem in Windows 10 like this way:

  1. Go To the Hosts File C:\Windows\System32\drivers\etc\hosts and add this line:

127.0.0.1 mycraterapp.com

  1. Start Your Apache Server on 127.0.0.1 Port 80 -> So mycraterapp.com will forward to your Server.

3 .Go to your .env file and change this :

APP_URL=http://mycraterapp.com SANCTUM_STATEFUL_DOMAINS=mycraterapp.com SESSION_DOMAIN=mycraterapp.com

  1. Maybe clear Cookies in Your Browser and clear php chache.

I hope your problem goes away like i solved this on my machine.

Cheers

I have followed above but still has same issue of Unauthenticated

muazzamazaz avatar Jul 25 '22 09:07 muazzamazaz

did anyone ever solve this one?

augmentedagent avatar May 11 '23 04:05 augmentedagent