Class CustomAuthenticationEntryPoint

java.lang.Object
com.raphaelsalles.backend.infra.security.CustomAuthenticationEntryPoint
All Implemented Interfaces:
org.springframework.security.web.AuthenticationEntryPoint

@Component public class CustomAuthenticationEntryPoint extends Object implements org.springframework.security.web.AuthenticationEntryPoint
Ponto de Entrada de Autenticação Customizado.

Propósito: Definir o comportamento quando um usuário não autenticado tenta acessar um recurso protegido. Retorna 401 Unauthorized em vez de redirecionar para página de login (padrão MVC).

  • Constructor Details

    • CustomAuthenticationEntryPoint

      public CustomAuthenticationEntryPoint()
  • Method Details

    • commence

      public void commence(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException) throws IOException
      Trata a tentativa de acesso não autorizado.
      Specified by:
      commence in interface org.springframework.security.web.AuthenticationEntryPoint
      Parameters:
      request - A requisição HTTP.
      response - A resposta HTTP.
      authException - A exceção de autenticação.
      Throws:
      IOException