Facebook Login Error: CSRF detected

Hi!

My users cannot log in with Facebook anymore. This is the error log:

(facebook) Authentication failure! csrf_detected: OmniAuth::Strategies::OAuth2::CallbackError, csrf_detected | CSRF detected

I’m using Cloudflare in front of nginx. I’m using Cloudflare automatic SSL (flexible). I didn’t install any certificate on my server (i.e. I’m not using Letsencrypt).

Is this related to Cloudflare? Can this be solved without installing Letsencrypt?

Thanks!

This error is similar both for Google and Facebook. In my configuration there was a line in nginx:

# proxy_set_header X-Forwarded-Proto $https;

After I changed it to

proxy_set_header X-Forwarded-Proto $scheme;

the error has gone.

Solution was found after reading this topic: Redirect URI mismatch in Google Auth

2 Me gusta

Tengo que mejorar mi respuesta.

Después de jugar con la autenticación de FB y Google, me quedo en el inicio de sesión de Office365 debido a la política de la empresa.

Cuando moví mi servidor de Discourse detrás de un proxy (ver la imagen a continuación), la autenticación de O365 dejó de estar disponible. Necesita que force https esté habilitado y esta opción está rota detrás del proxy. Afortunadamente, Daniel lo resolvió: Moved site behind proxy, favicon and header not using https anymore - #11 by rossierd.

La línea en la configuración interna de Nginx

proxy_set_header X-Forwarded-Proto $scheme;

debe ser reemplazada por

proxy_set_header X-Forwarded-Proto "https";

El Nginx externo no necesita tal modificación. Tiene:

proxy_set_header X-Forwarded-Proto $scheme;

Probablemente lo mismo sea correcto para FB, Google y otros tipos de autenticación.

P.D.

Obviamente, esa cadena contenía un error tipográfico $ y era inútil.

1 me gusta