Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Cookie Pfad setzen #3334

Closed
tristanlins opened this issue Nov 29, 2011 · 9 comments
Closed

Cookie Pfad setzen #3334

tristanlins opened this issue Nov 29, 2011 · 9 comments
Labels
Milestone

Comments

@tristanlins
Copy link
Contributor

Den Cookie Pfad standardmäßig auf $GLOBALS['TL_CONFIG']['websitePath'] anstatt "/" setzen um so die Sicherheit zu erhöhen, wenn Contao nicht auf der Wurzel installiert ist. Eventuell über separate Systemeinstellung konfigurierbar machen?!

Related issues: #3248, #3335

--- Originally created on August 8th, 2011, at 10:30am (ID 3334)

@ghost
Copy link

ghost commented Nov 29, 2011

Siehe dazu bitte mein Ticket #3248 bzgl. Cookie-Path beim SSL-Proxy setzen.

Der Cookie-Pfad wird doch momentan gar nicht gesetzt, oder sehe ich das falsch? Er sollte auf den Installationsordner (gegebenenfalls unter Berücksichtigung eines SSL-Proxies) verweisen.

--- Originally created by Borrible on August 8th, 2011, at 11:45pm

@tristanlins
Copy link
Contributor Author

Der Cookie-Pfad wird aktuell auf "/" gesetzt, wenn er bei setCookie nicht übergeben wird und das wird er bei der Anmeldung nicht.
$GLOBALS['TL_CONFIG']['websitePath'] ist der Installationsordner und die Konfigurationsmöglichkeit über eine separate Systemeinstellung war genau für solche Sachen wie SSL-Proxies gedacht ;)

--- Originally created on August 9th, 2011, at 09:55am

@ghost
Copy link

ghost commented Nov 29, 2011

Ziel:

  • http[s]://domain.de/ --> Cookie für domain.de mit Cookie-Path /, kein Installationsordner angegeben
  • http[s]://domain.de/contao-install/ --> Cookie für domain.de mit Cookie-Path contao-install/, Installationsordner ist "contao-install"
  • https://ssl-proxy/domain.de --> Cookie für ssl-proxy mit Cookie-Path domain.de/, kein Installationsordner angegeben
  • https://ssl-proxy/domain.de/contao-install/ --> Cookie für ssl-proxy mit Cookie-Path domain.de/contao-install/, Installationsordner ist "contao-install"

Es sind aber zwei unterschiedliche Konfigurationspunkte:

  • Installationsordner wird über Systemeinstellungen festgelegt
  • SSL-Proxy wird (gegebenenfalls) direkt in der Config-Datei system/config/localconf.php hiermit unterstützt:
if ($_SERVER['HTTP_X_FORWARDED_HOST'] == "ssl-proxy")
{
$_SERVER['HTTPS'] = 1;
}

--- Originally created by Borrible on August 9th, 2011, at 12:02pm

@tristanlins
Copy link
Contributor Author

Ähh, Systemeinstellungen und localconfig.php sind ein und dasselbe! ;-)

Du kannst ja in deine localconfig.php auch schreiben:
für https://ssl-proxy/domain.de:

if ($_SERVER['HTTP_X_FORWARDED_HOST'] == "ssl-proxy")
{
  $_SERVER['HTTPS'] = 1;
  $GLOBALS['TL_CONFIG']['websitePath'] = '/domain.de/';
}

bzw. für https://ssl-proxy/domain.de/contao-install/:

if ($_SERVER['HTTP_X_FORWARDED_HOST'] == "ssl-proxy")
{
  $_SERVER['HTTPS'] = 1;
  $GLOBALS['TL_CONFIG']['websitePath'] = '/domain.de/contao-install/';
}

sollte es dann eventuell eine eigene Einstellung für den Cookie Pfad geben, z.B. $GLOBALS['TL_CONFIG']['cookiePath'], könnte das dann so aussehen:

if ($_SERVER['HTTP_X_FORWARDED_HOST'] == "ssl-proxy")
{
  $_SERVER['HTTPS'] = 1;
  $GLOBALS['TL_CONFIG']['cookiePath'] = '/domain.de/contao-install/';
}

Und wenn du den cookiePath über die Systemeinstellungen direkt festlegen kannst, wo ist dann das Problem?

Dann gilt es lediglich das Cookie-Domain Problem zu lösen, dafür gibt es aber afaik ein anderes Ticket.

--- Originally created on August 9th, 2011, at 12:32pm

@ghost
Copy link

ghost commented Nov 29, 2011

if ($_SERVER['HTTP_X_FORWARDED_HOST'] == "ssl-proxy")
{
  $_SERVER['HTTPS'] = 1;
  $GLOBALS['TL_CONFIG']['websitePath'] = '/domain.de/';
}

^^^ auf die Idee bin ich noch gar nicht gekommen! :-)

Kleine Frage:

if ($_SERVER['HTTP_X_FORWARDED_HOST'] == "ssl-proxy")
{
  $_SERVER['HTTPS'] = 1;
  $GLOBALS['TL_CONFIG']['websitePath'] = '/domain.de/'.$GLOBALS['TL_CONFIG']['websitePath'];
}

Würde sowas auch gehen, wenn es am Ende der Config-Datei steht?

--- Originally created by Borrible on August 9th, 2011, at 01:18pm

@tristanlins
Copy link
Contributor Author

Würde sowas auch gehen, wenn es am Ende der Config-Datei steht?
Vergiss was ich zuerst geschrieben habe, ja das geht ^^

PS: Ich haue solche Scripte IMMER an das Ende der localconfig.php damit ich die Einstellungen auch garantiert überschreibe ;)

--- Originally created on August 9th, 2011, at 01:30pm

@ghost
Copy link

ghost commented Nov 29, 2011

Ok, ich bin jetzt mal dazugekommen es auszuprobieren: Es funktioniert SO NICHT (und wird wohl für einen SSL-Proxy völliger Blödsinn sein)!
Folgendes und dergleichen in der localconfig.php bitte wieder ganz schnell vergessen:

if ($_SERVER['HTTP_X_FORWARDED_HOST'] == "ssl-proxy")
{
  $_SERVER['HTTPS'] = 1;
  $GLOBALS['TL_CONFIG']['websitePath'] = '/domain.de/';
}

--- Originally created by Borrible on August 16th, 2011, at 09:12pm

@ghost
Copy link

ghost commented Nov 29, 2011

Kannst du den Patch aus #3335 mal ausprobieren? Gibt es da Problem, wenn man SSL benutzt?

--- Originally created by SunBlack on August 16th, 2011, at 09:27pm

@leofeyer
Copy link
Member

Geändert in dafef25.

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

No branches or pull requests

2 participants