首页 文章

Java Web应用程序仅角色安全性

提问于
浏览
0

美好的一天!

我尝试通过web.xml中的角色安全来保护我的Web应用程序:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>RESTRICTED</web-resource-name>
        <description>Resources to be placed under security control</description>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>manager</role-name>
    </auth-constraint>
</security-constraint>

<security-role>
    <description>ACCESS ROLE</description>
    <role-name>manager</role-name>
</security-role>

并且就我使用Weblogic而言,有一个weblogic-application.xml,其中包含以下行:

<security>
    <security-role-assignment>
        <role-name>manager</role-name>
        <principal-name>manager</principal-name>
    </security-role-assignment>
</security>

The idea 如果用户已经过身份验证(Web SSO),则他具有角色,并且应用程序必须为此类用户提供访问权限 .

The problem 即使用户具有所需角色,应用程序也会提供基本登录表单 .

我试过添加这样一行:

<login-config/>

在web.xml中,依赖于article中的事实,据说此行使所有页面都公开(我认为它会删除登录表单,但保留角色安全性),但这没有用 .

有人知道如何删除登录表单,留下角色安全性吗?

UPDATE :在我的WebLogic中,有一个手写的身份断言器,用于检查用户的令牌 . 如果令牌出现,则断言器创建一个主体并让用户进入系统 .

一个有趣的事实:如果我使用Firefox浏览器没有任何登录表单,但在Chrome中,基本登录表单总是在这里......

1 回答

  • 0

    好的,最后我找到了'Using Identity Assertion for Web Application Authentication'中this article中实际描述的解决方案:我已将这些行添加到web.xml中:

    <login-config>
            <auth-method>CLIENT-CERT</auth-method>
        </login-config>
    

    那很有效 .

相关问题