前言
SpringSecurity默认使用表单登录,不支持Json方式登录,接下来设置既可以支持表单登录,也可以支持Json方式登录。
实现
public class SignInFilter extends UsernamePasswordAuthenticationFilter {
@Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws
AuthenticationException {
if (MediaType.APPLICATION_JSON_VALUE.equals(request.getContentType()) && request.getMethod().equals("POST")) {
Map<String, String> requestBody = null;
try {
requestBody = new ObjectMapper().readValue(request.getInputStream(), Map</

这篇博客介绍了如何在SpringBoot应用中结合SpringSecurity,既保持原有的表单登录功能,又添加对JSON登录的支持。内容包括前言和具体实现步骤,其中在实现部分提到了在SignInFilter中处理了验证码验证的细节。
最低0.47元/天 解锁文章
2352

被折叠的 条评论
为什么被折叠?



