Browse Source

Disable basic auth prompt on failed login #9

master
Rohan Sircar 4 years ago
parent
commit
cfbd841ad0
  1. 14
      src/main/java/org/ros/chatto/RESTAuthenticationEntryPoint.java

14
src/main/java/org/ros/chatto/RESTAuthenticationEntryPoint.java

@ -12,23 +12,11 @@ import org.springframework.security.web.authentication.www.BasicAuthenticationEn
import org.springframework.stereotype.Component;
@Component
public final class RESTAuthenticationEntryPoint
extends BasicAuthenticationEntryPoint {
// @Override
// public void commence(
// HttpServletRequest request,
// HttpServletResponse response,
// AuthenticationException authException) throws IOException {
//
// response.sendError(HttpServletResponse.SC_UNAUTHORIZED,
// "Unauthorized");
// }
public final class RESTAuthenticationEntryPoint extends BasicAuthenticationEntryPoint {
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authEx)
throws IOException, ServletException {
response.addHeader("WWW-Authenticate", "Basic realm=" +getRealmName());
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
PrintWriter writer = response.getWriter();
writer.println("HTTP ApplicationStatus 401 - " + authEx.getMessage());

Loading…
Cancel
Save