Long story short, I migrated from Spring Security 3 to version 4.0.3.RELEASE. When I changed the version in pom file I faced with 405 error. In my login.jsp I had something like that:
*(I changed the character "<" to "!" to display the code)
!form style="margin-bottom: 0px;" action="../../j_spring_security_check" method="post">
Username:!input type="text" name="j_username" />!br/>
Password:!input type="password" name="j_password" />!br/>
Digging through Stackoverflow and other articles I found this useful link (note for the future: try to search in official documentation first :-) ):
https://docs.spring.io/spring-security/site/migrate/current/3-to-4/html5/migrate-3-to-4-xml.html#m3to4-xmlnamespace-form-login
So now I have login.jsp with the following text:
!form style="margin-bottom: 0px;" action="!c:url value='/login' />" method="POST">
Username:!input type="text" name="username" />!br/>
Password:!input type="password" name="password" />!br/>
!input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> !br/>
!input type="submit" value="Login" />
Update: For now I do not need CSRF filter in my project, so I removed one line from the code above (crossed out text) and added the following string in my spring-security.xml:
<security:csrf disabled="true" />
*(I changed the character "<" to "!" to display the code)
!form style="margin-bottom: 0px;" action="../../j_spring_security_check" method="post">
Username:!input type="text" name="j_username" />!br/>
Password:!input type="password" name="j_password" />!br/>
Digging through Stackoverflow and other articles I found this useful link (note for the future: try to search in official documentation first :-) ):
https://docs.spring.io/spring-security/site/migrate/current/3-to-4/html5/migrate-3-to-4-xml.html#m3to4-xmlnamespace-form-login
So now I have login.jsp with the following text:
!form style="margin-bottom: 0px;" action="!c:url value='/login' />" method="POST">
Username:!input type="text" name="username" />!br/>
Password:!input type="password" name="password" />!br/>
!input type="submit" value="Login" />
Update: For now I do not need CSRF filter in my project, so I removed one line from the code above (crossed out text) and added the following string in my spring-security.xml:
<security:csrf disabled="true" />
Немає коментарів:
Дописати коментар