如果通过java代码访问URL,则Spring身份验证失败
目前,我通过Spring过滤器和Servlet使用Spring安全认证如果通过java代码访问URL,则Spring身份验证失败,java,spring,jakarta-ee,servlets,spring-security,Java,Spring,Jakarta Ee,Servlets,Spring Security,目前,我通过Spring过滤器和Servlet使用Spring安全认证 远程处理 /远程处理/* 远程处理 /管理员 springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain /* 在我的spring-security.xml中 <authentication-manager alias="authenticationManager"&
远程处理
/远程处理/*
远程处理
/管理员
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*
在我的spring-security.xml中
<authentication-manager alias="authenticationManager">
<authentication-provider ref="myAppAuthenticationProvider"/>
</authentication-manager>
<beans:bean id="myAppAuthenticationProvider"
class="com.filter.MyAppAuthenticationProvider">
<beans:property name="repository" value="#{deployment['globalregistry.repository']}"/>
</beans:bean>
现在,当我点击Eg:http://localhost:8080/context/admin?action=authenticate
j_用户名:用户j_密码:密码 我得到一个输入用户和密码的屏幕,该屏幕由spring security验证 现在,当我试图通过HttpPostAPI通过Java程序访问上述URL时,我得到一个重定向错误响应,即302。现在,我如何绕过登录屏幕进行验证和直接身份验证,而无需重定向到网页。并使用我的java程序提供j_用户名和j_密码 请注意,当我点击URL时,页面被重定向到如下
http://localhost:8080/context/spring_security_login
你们的帮助会让我们非常感激的 您应该在用于身份验证的URL中传递
j_用户名
和j_密码
例如:
http://localhost:8080/yourAppContext/j_spring_security_check?j_username=user&j_password=pass
或者通过POST发送,这是默认情况下唯一允许的方法。