gpt4 book ai didi

Spring 安全 : Authentication method not supported: GET

转载 作者:行者123 更新时间:2023-12-01 01:11:58 26 4
gpt4 key购买 nike

我不知道我在哪里遗漏了一些东西,非常感谢您的帮助!
登录尝试后,我收到“不支持身份验证方法:GET”消息。

这是我的 security-Context.xml:

 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">

<!-- <security:http auto-config="true" access-decision-manager-ref="accessDecisionManager"> -->
<security:http auto-config="true">
<security:intercept-url pattern="/login/login.do" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/login/doLogin.do" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/lib/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/css/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/images/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/resources/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/**" access="IS_AUTHENTICATED_REMEMBERED" />
<security:form-login login-page="/login/login.do" authentication-failure-url="/login/login.do?login_error=true" default-target-url="/test/showTest.do"/>
<security:logout logout-success-url="/login/login.do" invalidate-session="true" />
<security:remember-me key="rememberMe"/>
</security:http>


<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service data-source-ref="dataSource"
users-by-username-query="select EMAIL as email, PASSWORD as password, from ams.user where EMAIL=?"
authorities-by-username-query="
select distinct user.EMAIL as email, permission.NAME as authority
from ams.user, ams.user_role, ams.role, ams.role_permission, ams.permission
where user.ID=user_role.USER_ID AND user_role.ROLE_ID=role_permission.ROLE_ID AND role_permission.PERMISSION_ID=permission.ID AND user.EMAIL=?"/>
<security:password-encoder ref="passwordEncoder" />
</security:authentication-provider>
</security:authentication-manager>

<bean id="passwordEncoder"
class="org.springframework.security.authentication.encoding.ShaPasswordEncoder">
<constructor-arg value="256" />
</bean>
</beans>

还有我的 LoginController:
@Controller
public class LoginController {

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showLogin() {
ModelAndView mav = new ModelAndView("login/login");

return mav;
}

@RequestMapping(method = RequestMethod.POST)
public ModelAndView doLogin(@RequestParam("email") String email,
@RequestParam("password") String password,
@RequestParam("remember_me") boolean rememberMe,
HttpServletRequest request, HttpServletResponse response) {

ModelAndView mav = new ModelAndView();

mav.setViewName("redirect:/j_spring_security_check?j_email=" + email + "&j_password=" + password + "&_spring_security_remember_me=" + rememberMe);

return mav;
}
}

如果您需要更多信息,请告诉我

最佳答案

我猜您尝试使用用户名和密码作为查询参数向登录 URL 发送 HTTP GET 请求。由于这本质上是不安全的(例如可以添加书签),因此是不允许的。您应该改为发送 HTTP POST。

关于 Spring 安全 : Authentication method not supported: GET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14966309/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com