HTTP_X_FORWARDED_PREFIX for cookie path (#2201)

Forgotten. Follow-up of https://github.com/FreshRSS/FreshRSS/pull/2191
pull/2204/head
Alexandre Alapetite 6 years ago committed by GitHub
parent 06ea2626e8
commit e9d50f48eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/install.php
  2. 6
      lib/Minz/Session.php

@ -7,7 +7,8 @@ header("Content-Security-Policy: default-src 'self'");
require(LIB_PATH . '/lib_install.php'); require(LIB_PATH . '/lib_install.php');
session_name('FreshRSS'); session_name('FreshRSS');
session_set_cookie_params(0, dirname(empty($_SERVER['REQUEST_URI']) ? '/' : dirname($_SERVER['REQUEST_URI'])), null, false, true); $forwardedPrefix = empty($_SERVER['HTTP_X_FORWARDED_PREFIX']) ? '' : rtrim($_SERVER['HTTP_X_FORWARDED_PREFIX'], '/ ');
session_set_cookie_params(0, $forwardedPrefix . dirname(empty($_SERVER['REQUEST_URI']) ? '/' : dirname($_SERVER['REQUEST_URI'])), null, false, true);
session_start(); session_start();
if (isset($_GET['step'])) { if (isset($_GET['step'])) {

@ -61,7 +61,11 @@ class Minz_Session {
public static function getCookieDir() { public static function getCookieDir() {
// Get the script_name (e.g. /p/i/index.php) and keep only the path. // Get the script_name (e.g. /p/i/index.php) and keep only the path.
$cookie_dir = empty($_SERVER['REQUEST_URI']) ? '/' : $_SERVER['REQUEST_URI']; $cookie_dir = '';
if (!empty($_SERVER['HTTP_X_FORWARDED_PREFIX'])) {
$cookie_dir .= rtrim($_SERVER['HTTP_X_FORWARDED_PREFIX'], '/ ');
}
$cookie_dir .= empty($_SERVER['REQUEST_URI']) ? '/' : $_SERVER['REQUEST_URI'];
if (substr($cookie_dir, -1) !== '/') { if (substr($cookie_dir, -1) !== '/') {
$cookie_dir = dirname($cookie_dir) . '/'; $cookie_dir = dirname($cookie_dir) . '/';
} }

Loading…
Cancel
Save