在 Apache mod_rewrite内的一个 URL 路由上禁用 Shibboleth 登录


Disable Shibboleth login on one URL route within Apache's mod_rewrite

我有一个在PHP Codeigniter框架上运行的Web应用程序,它使用重写规则重写路由到前端控制器索引.php。我想做的是从 shibboleth 身份验证中排除一条路线。

例:
我们有2条路线 https://example.com/view/1457 和 https://example.com/public/view/1457。第一个链接应该要求用户通过Shibbo登录,第二个链接不需要。两条路由都重写为 https://example.com/index.php?/view/1457 和 https://example.com/index.php?/public/view/1457。我在 apache conf 中有一个重定向规则,可以将视图/公共/12345 重定向到公共/视图/12345。另一个非 shibbo 路由是包含静态文件(css、js、...(的/assets。

我的问题是公共路由和重定向到公共的路由(view/public/12345(被shibbo登录捕获。但资产路线并非如此。

对我来说,看起来 https://example.com/public/view/1457 的请求被重写为 https://example.com/index.php?/public/view/1457 并且此路由未列入白名单。但是登录后,我被重定向到此网址 https://example.com/public/view/1457

.htaccess

Options -Indexes 
DirectoryIndex index.php index.html index.htm
RewriteEngine On
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

Apache vhost conf

<VirtualHost *:443>
        ServerName example.com
        #legacy redirection
        Redirect /view/public/12345 https://example.com/public/view/12345
        DocumentRoot /var/www/html
        <Directory />
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        <Location /public>
                AuthType shibboleth
                ShibRequireSession Off
                require shibboleth
        </Location>
        <Location /assets>
                AuthType shibboleth
                ShibRequireSession Off
                require shibboleth
        </Location>
        <Location />
                AuthType shibboleth
                ShibRequireSession On
                ShibUseHeaders On
                require valid-user
                require shibboleth
        </Location>
</VirtualHost>

我认为你应该使用

ShibRequestSetting requireSession false

而不是

ShibRequireSession Off

但这可能只是一个版本问题——我不熟悉 Shibboleth。

此外,了解您正在使用的 Apache 版本可能会有所帮助。我问的原因是因为您正在使用Order/Allow/DenyRequire的组合。后者适用于 Apache 2.4,前者适用于 2.2。

过去了,恐怕我不知道还能帮上什么忙。