Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Routing: breaks Apache Aliases (module #1023

Open
dbollaer opened this issue Dec 19, 2018 · 11 comments

Comments

@dbollaer
Copy link
Contributor

commented Dec 19, 2018

I use apache aliases in Simplesamlphp to allow easier access to my custom module.

Steps to reproduce the behavior:

  1. Create an alias in your apache config:
    Alias /login.php "/var/www/simplesamlphp/www/module.php/core/www/authenticate.php"
  2. Restart apache
  3. Go to the page

Expected behavior
You will receive a page not found exception, with the following message:

SimpleSAML\Error\NotFound: The requested page 'http://localhost/login.php' could not be found. The URL must at least contain a module name followed by a slash.

In the past this used to just show the authenticate page.

A clear and concise description of what you expected to happen.

When you look in the logs, you see that login.php page is in the front, normally it should not be part of the path and it replaced module.php.

Screenshots or logs

Dec 19 19:12:21 localhost simplesamlphp[8138]: 2 [a9caccd0cf] /login.php/core/www/authenticate.php - Localization directory missing/broken for langcode 'nl' and domain 'themes'
Dec 19 19:12:21 localhost simplesamlphp[8138]: 3 [a9caccd0cf] /login.php/core/www/authenticate.php - Something went wrong when trying to get path to language file, cannot load domain 'themes'.
Dec 19 19:12:21 localhost simplesamlphp[8138]: 3 [a9caccd0cf] SimpleSAML\Error\NotFound: The requested page 'https://localhost/login.php' could not be found. The URL must at least contain a module name followed by a slash.
Dec 19 19:12:21 localhost simplesamlphp[8138]: 3 [a9caccd0cf] Error report with id 9709a3dd generated.

Additional context
I rewrote some parameters, (privacy)

I use php7.1-fpm

If it is possible to use the routing directly, the aliases would no longer be necessary.

@tvdijen

This comment has been minimized.

Copy link
Member

commented Dec 20, 2018

As a workaround/fix you could use:
Redirect "/login.php" "/module.php/core/authenticate.php"

We should probably mention this in the upgrade notes, but other than that I don't think there's a solution for this if we want to move forward with routing.

@dbollaer

This comment has been minimized.

Copy link
Contributor Author

commented Dec 21, 2018

I understand you want to move forward and I will use your redirect in the meantime, but I will probably end up fixing it in the coming months. Could you please provide me some hint where I can start looking.

Also I was wondering why you did not go for full routing or is this something you plan for in the future.
I think having nice custom urls is one of the major benefits of using routing.

@tvdijen

This comment has been minimized.

Copy link
Member

commented Dec 21, 2018

You should probably start with #966 and go from there. Maybe @jaimeperez can comment on this as well, as it was his idea.

Right now the functionality is limited to routing for modules and a showcase was added in the new admin module. It will be implemented for all modules in 1.18 (or 2.0, not sure what we agreed upon)

@tvdijen tvdijen added the needsinfo label Jan 13, 2019

@dbollaer

This comment has been minimized.

Copy link
Contributor Author

commented Jan 16, 2019

Just to let you know, I patched it in my own version to use PATH_INFO instead of request.

diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php
index 4cbd4165..69702d21 100644
--- a/lib/SimpleSAML/Module.php
+++ b/lib/SimpleSAML/Module.php
@@ -130,7 +130,8 @@ class Module
             throw new Error\NotFound('No PATH_INFO to module.php');
         }
 
-        $url = $request->getPathInfo();
+        $url = $_SERVER['PATH_INFO'];
+
         assert(substr($url, 0, 1) === '/');
 
         /* clear the PATH_INFO option, so that a script can detect whether it is called with anything following the

I don't think this is a good solution, but it seems to work.

@tvdijen

This comment has been minimized.

Copy link
Member

commented Jan 16, 2019

Thanks @dbollaer !
I wonder though.. How are the values different? I would expect them to be equal

@dbollaer

This comment has been minimized.

Copy link
Contributor Author

commented Jan 16, 2019

The difference is the lack of the module name:

$request->getPathInfo() => /url.php
$_SERVER['PATH_INFO'] => /module/url.php
@klausdk

This comment has been minimized.

Copy link

commented Mar 28, 2019

We just upgraded to simplesaml v1.17.1 and had the same issue.

Before we could use

Alias /cas /var/www/simplesamlphp/www/module.php/casserver/cas.php

Now we use

RewriteRule ^/cas/(.*) /saml/module.php/casserver/cas.php/$1 [P]

We had to use the [P] option because we have a service provider which for some reason failed when redirecting.

Hope it helps

/Klaus

@dbollaer

This comment has been minimized.

Copy link
Contributor Author

commented Mar 29, 2019

@klausdk thank you for feedback.

I tried to implement it, but I am afraid it does not work in my use case.

We are using proxy:fcgi

Log

[Fri Mar 29 12:03:57.573250 2019] [proxy:warn] [pid 24642:tid 139907737540352] [client 157.193.49.84:60686] AH01144: No protocol handler was valid for the URL /login.php. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

config

<FilesMatch ".+(\.php)$">
        SetHandler proxy:fcgi://127.0.0.1:9003
 </FilesMatch>

Note: Modules are loaded.

@klausdk

This comment has been minimized.

Copy link

commented Mar 29, 2019

The difference is the lack of the module name:

$request->getPathInfo() => /url.php
$_SERVER['PATH_INFO'] => /module/url.php

I wonder if the problem can be solved in the cas.php file instead.

It excepts PATH_INFO to contain url.php and not /url.php

Maybe it will help to do this change :

$function = substr($_SERVER['PATH_INFO'], 1);
+// remove slashes
+$function = preg_replace('#/#','',$function);
@dbollaer

This comment has been minimized.

Copy link
Contributor Author

commented Mar 29, 2019

First: with fix, I no longer enter the module.php, so it just doesn't work.
Sorry I should have more explicit.

Second: This is not really an option I prefer. I am using this also for other custom modules.
So one location is better for me.

@klausdk

This comment has been minimized.

Copy link

commented Mar 29, 2019

The main reason might be they switched to use symfony/httpfoundation for URL-handling. ( Checkout simplesamlphp/simplesamlphp-module-casserver#18 )

So you might have to investigate in that area. But then it might break other things :-/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.