Comments (10)
This is just a note for anyone using simple php with nginx. Ran into some issues around path info, and here is my nginx config and the changes I made to the latest stable simplephp (1.13):
NGINX:
server {
...
location ^~ /simplesaml {
alias /var/simplesamlphp/www;
location ~ ^(?<prefix>/simplesaml)(?<phpfile>.+?\.php)(?<pathinfo>/.*)?$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$phpfile;
fastcgi_param PATH_INFO $pathinfo if_not_empty;
}
}
}
And the above - even after setting baseurl in configs caused some destination in response doesn't match the current url errors.
The first was of the form:
destination http://www.something.com/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp
current (shown wrong the current is actually matched the dest) http://www.something.com/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp/saml/sp/saml2-acs.php/default-sp
To fix the above
www/module.php line ~130
if (preg_match('#\.php$#D', $path)) {
/* PHP file - attempt to run it. */
- $_SERVER['SCRIPT_NAME'] .= '/' . $module . '/' . $url;
+ //$_SERVER['SCRIPT_NAME'] .= '/' . $module . '/' . $url;
require($path);
exit();
}
At this point the error became:
destination: http://www.something.com/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp
current (again wrong) : http://www.something.com/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp/default-sp
to fix this:
lib/SimpleSAML/Utilities.php line ~156
$selfURLhost = self::selfURLhost();
$selfURLhost .= $_SERVER['SCRIPT_NAME'];
if (isset($_SERVER['PATH_INFO'])) {
- $selfURLhost .= $_SERVER['PATH_INFO'];
+ //$selfURLhost .= $_SERVER['PATH_INFO'];
}
return $selfURLhost;
And with the above two changes I am able to log in to the test OpenIdp Account.
I'm sure the fixes could be done in the NGINX config, but the above seems to work.
from simplesamlphp.
Hi Olav, Yep, it's feasible, I already did it with a little raw patch to SSP 1.11 and all works well under nginx.
Check the changes here:
and here:
(In my raw workaround I overrided the $_SERVER['PATH_INFO'] variable to create it if not exists, but obviously this can be done in a cleaner way, i post it just to give you some inspiration)
Best Regards,
Stefano Gargiulo
from simplesamlphp.
Thanks! it solved my issue
(After a loooog internet search and trying to follow different advices that did not help)
btw, I am using latest master (14-8-2015), so I moved the above suggested code fix from
simplesamlphp/lib/SimpleSAML/Utilities.php
To:
simplesamlphp/lib/SimpleSAML/Utils/HTTP.php
As class SimpleSAML_Utilities @deprecated This entire class will be removed in SimpleSAMLphp 2.0.
from simplesamlphp.
Thank you for feedback i'm glad to have helped you a bit, and thanks for the info about deprecated class, I still have to upgrade I'm using 1.12 now.
from simplesamlphp.
Hi!
I might be missing something, but the two links provided by @creativeprogramming are broken.
Could someone provide a PR with the suggested changes on top of master, so that we can take a look into it and evaluate including it as the final solution to this issue?
Thanks!
from simplesamlphp.
Here is what I added to:
simplesamlphp/lib/SimpleSAML/Utils/HTTP.php
public static function __fixPathInfoForNginx() {
$matches = array();
if (preg_match("/^(.+\/module\.php)(\?)?(\/.+)$/", $_SERVER['REQUEST_URI'], $matches)) {
$pathinfo = $matches[3];
$m = array();
if (preg_match("/(.*)\?(.*)/", $pathinfo, $m)) {
$pathinfo = substr($pathinfo, 0, strripos($pathinfo, "?"));
}
$_SERVER['PATH_INFO'] = $pathinfo;
// $scriptname = str_ireplace($pathinfo, "", $matches[0]);
$scriptname = substr($_SERVER['REQUEST_URI'], 0, stripos($_SERVER['REQUEST_URI'], "module.php/")+strlen("module.php"));
$_SERVER['SCRIPT_NAME'] = $scriptname;
}
}
/**
* Retrieve the current URL without the query parameters.
*
* @return string The current URL, not including query parameters.
*
* @author Andreas Solberg, UNINETT AS <[email protected]>
*/
public static function getSelfURLNoQuery()
{
self::__fixPathInfoForNginx(); // fix PATH_INFO for NGINX // nadavkav
$url = self::getSelfURLHost();
$url .= $_SERVER['SCRIPT_NAME'];
if (isset($_SERVER['PATH_INFO'])) {
$url .= $_SERVER['PATH_INFO'];
}
return $url;
}
And called it from:
module.php
try {
SimpleSAML_Utilities::__fixPathInfoForNginx();
if (empty($_SERVER['PATH_INFO'])) {
throw new SimpleSAML_Error_NotFound('No PATH_INFO to module.php');
}
from simplesamlphp.
I ran into the same Issue on lighttpd with Rewrite-Rules on.
I centralized $_SERVER['PATH_INFO'] as HTTP::getPathInfo(). At the moment I am running some Tests for rewriting $_SERVER['REQUEST_URI'] to $_SERVER['PATH_INFO'] in a more general way as @nadavkav did.
When I am ready, I will provide a PR.
from simplesamlphp.
That sounds promising @gfaust-qb, thanks a lot!
Please remember to add some unit tests too so that we can make sure that your new method continues to work over time as expected.
from simplesamlphp.
Hello!
Running v1.14.3 with php-fpm behind apache 2.4 in proxy pass mode is also affected by this issue. The patch linked by @didoda (when updated to use the new functions in Utils/HTTP.php) works.
It seems like $_SERVER['SCRIPT_NAME']
is populated differently when running with FastCGI, or php-fpm (common with nginx), as opposed to whatever the environment is where the code is written.
It is behaving as if $_SERVER['SCRIPT_NAME']
is already populated with the appropriate URL path in the former case, so the code is currently needlessly appending more to it.
Perhaps a better fix will be to test $_SERVER['SCRIPT_NAME']
before appending to it. I'll try and get a pull request set up today.
from simplesamlphp.
This issue should be fixed now thanks to @travishegner contribution. Thanks also to all who shared their feedback!
from simplesamlphp.
Related Issues (20)
- session.state.timeout never work as described in the comment.
- SP->authenicate() broken in master branch HOT 1
- Release 2.1.4: Expected return value from redirectTrustedURL() not provided HOT 1
- The default config.php still uses the core:StatisticsWithAttribute authproc-filter HOT 5
- Fix for bin/initMDSPdo.php wasn't ported to v2.2 HOT 2
- Unhandled exception HOT 4
- Subject-ID - Hashing & Salt identifyingAttribute value HOT 8
- Support Laravel 11 (with Symfony 7.0) HOT 4
- Translations in v2.2 seem broken HOT 11
- Perhaps respect the gettext domain for modules HOT 7
- After update to 2.1.5 and going to startpage, only a Welcome screen appears HOT 5
- 2.1+: Translations are off HOT 8
- Adding Microsoft or Google MFA application support. HOT 2
- Updates to bin/translations translations:update:translatable
- console command does not respect module parameter HOT 1
- AuthData is an empty array in the database but user still can login. HOT 7
- (minor) XML metadata opening tags difference between IdP and SP metadata HOT 1
- SimpleSAML 1.18.7 - ERR_EMPTY_RESPONSE HOT 3
- SCIM Support HOT 2
- Adding NameFormat to IdP-hosted config changes Attribute Name value HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simplesamlphp.