Apache配置 - 从身份验证中排除位置



我有一个由Shibboleth身份验证模块保护的Web应用程序。我当前的配置如下

<Location /MyApp>
 AuthType shibboleth
 ShibUseHeaders On
 ShibRequestSetting requireSession 1
 require shibboleth
</Location>

shibboleth 是一个身份验证模块,可提供SSO功能,而当前流则将用户引导到 Identity Provider 以使用户输入登录凭据。我希望能够打开特定的URL,以便通过身份验证模块绕过URL。我尝试了以下操作,但似乎不起作用,并且在加载URL

时得到了空白页面

方法1

<Location /MyApp/Login.html>
  Satisfy Any
  Allow from all
  AuthType None
  Require all granted
</Location>

方法2

<Location /MyApp/Login.html>
  AuthType shibboleth
  ShibRequestSetting requireSession 0
  require shibboleth
</Location>

我进行了一些其他调试,看来问题是其他文件 login.html 加载 - 例如CSS,JS等可以从身份验证

中绕过login.html

谢谢

我对排除 login.html 加载的其他文件的评论最终是正确的。我使用以下格式排除了由HTML文件加载的文件

<Location ~ "/MyApp/(Login.html|SessionTimeout.html|accessDenied.html|/badRequest.html|status|css/*|login/*|images/*|style/*|js/*|javascript/*|)">   
  Satisfy Any   
  Allow from all   
  AuthType None   
  Require all granted   
</Location>

使用apache 2.4而不是2.2时,为了排除"/server-status&quot",以下是足够的:

<LocationMatch "^(?!/server-status)">
    AuthType Basic
    AuthUserFile /etc/apache2/.htpasswd
    <RequireAll>
        Require ssl
        Require user valid_user_name
    </RequireAll>
</LocationMatch>

分析:

  • <LocationMatch "regex">等于<Location ~ "regex">
  • 所用的正则是pcre(Perl兼容正则表达式)。
  • ^(?!/server-status)表示:
    • ^:'从
    • 开始
    • (?!):"负面看(而不是正面(?=))"

最新更新