【问题标题】:JDBC Security Popup on Glassfish 3.1.2.2Glassfish 3.1.2.2 上的 JDBC 安全弹出窗口
【发布时间】:2013-04-23 16:07:24
【问题描述】:

我在 Glassfish 3.1.2.2 上使用 JDBC 领域身份验证运行 JSF 应用程序。

我想知道是否有任何方法可以禁用每当有人尝试访问受限页面但未登录时出现的登录弹出窗口,而是引发错误 401(自动重定向到我页面的登录页面)以保持一致性用户体验。

【问题讨论】:

    标签: glassfish glassfish-3 jdbcrealm


    【解决方案1】:

    您必须将 web.xml 安全约束 login-config auth-method 设置为 FORM 登录:

     <login-config>
            <auth-method>FORM</auth-method>
            <realm-name>You can but you are not forced to supply a realm here</realm-name>
            <form-login-config>
                <form-login-page>/login.xhtml</form-login-page>
                <form-error-page>/access-forbidden.xhtml</form-error-page>
            </form-login-config>
        </login-config>  
    

    这样保护您的网页:

    <security-constraint>
        <web-resource-collection>
            <url-pattern>/index.xhtml</url-pattern>       
        </web-resource-collection>
        <auth-constraint>
            <role-name>Manager</role-name>
        </auth-constraint>
    </security-constraint>
    
    <security-role>
        <role-name>Manager</role-name>
    </security-role>
    

    【讨论】:

      猜你喜欢
      • 2013-01-04
      • 1970-01-01
      • 1970-01-01
      • 2013-05-16
      • 2015-02-09
      • 2020-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多