refactor: 添加未认证和未授权自定义异常处理,printWriter无需手动关闭

This commit is contained in:
haoxr
2022-11-15 00:24:41 +08:00
parent 8c988de05a
commit dee6fa5cc4
7 changed files with 31 additions and 27 deletions

View File

@@ -4,6 +4,7 @@ import com.youlai.system.common.result.ResultCode;
import com.youlai.system.util.ResponseUtils;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -16,6 +17,7 @@ import java.io.IOException;
* @author haoxr
* @date 2022/10/18
*/
@Component
public class MyAuthenticationEntryPoint implements AuthenticationEntryPoint {
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {