Java Spring Security+;容器管理的身份验证问题

Java Spring Security+;容器管理的身份验证问题,java,spring,jakarta-ee,spring-security,Java,Spring,Jakarta Ee,Spring Security,我使用+来构建一个安全的web应用程序。我的用户的身份验证必须由我的容器处理。为了实现这一目标,我遵循了这两个步骤: 在我的web.xml文件中保护我的整个应用程序: <login-config> <auth-method>FORM</auth-method> </login-config> <security-constraint> <web-resource-collection> <

我使用+来构建一个安全的web应用程序。我的用户的身份验证必须由我的容器处理。为了实现这一目标,我遵循了这两个步骤:

  • 在我的web.xml文件中保护我的整个应用程序:

    <login-config>
        <auth-method>FORM</auth-method>
    </login-config>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Public</web-resource-name>
            <description>Matches unconstrained pages</description>
            <url-pattern>/resources/*</url-pattern>
        </web-resource-collection>
    </security-constraint>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Secured Areas</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>Everyone</role-name>
        </auth-constraint>
    </security-constraint>
    
    }


  • 这个配置似乎正在运行,因为每当我尝试访问应用程序上下文中的任何URL时,我都必须进行身份验证,静态资源除外(在/resources/文件夹中)。然后在登录后,会显示正确的URL和页面(如预期的那样)。但是,如果我尝试访问另一个链接,我必须再次登录。然后,会显示正确的URL和页面,我可以访问任何链接,而无需再次登录。因此,我的问题是:为什么我必须登录两次才能不被要求再次登录?

    我并不是这方面的专家,但我发现会话可能是由容器和spring安全性共同创建的。我的容器身份验证由WebLogic处理。有一堆google结果显示了如何为preauth编写自定义过滤器,但在我将spring安全性更改为无状态之前,它似乎从未正常工作过

    <http auto-config="false" use-expressions="true" disable-url-rewriting="true"
        create-session="stateless" entry-point-ref="http403EntryPoint">
    
    
    
    <http auto-config="false" use-expressions="true" disable-url-rewriting="true"
        create-session="stateless" entry-point-ref="http403EntryPoint">