Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Boa noite como faço para acessar o mapeamento /relatorio-produtos sem exigir autenticação do usuário

estou fazendo o projeto final casa do código java, preciso gerar um jason com todos produtos porem não deve ter restrição ao acessar a url. porem só consigo acessar logado.

@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    private UsuarioDAO usuarioDao;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
            .antMatchers("/produtos/detalhes/**").permitAll()
            .antMatchers("/produtos/**").hasRole("ADMIN")
            .antMatchers("/carrinho/**").permitAll()    
            .antMatchers("/pagamento/**").permitAll()    
            .antMatchers("/").permitAll()
            .antMatchers("/url-magica-maluca-oajksfbvad6584i57j54f9684nvi658efnoewfmnvowefnoeijn").permitAll()
            .anyRequest().authenticated()
            .and()
                .formLogin().loginPage("/login").defaultSuccessUrl("/").permitAll()
            .and()
                .logout()
                .logoutRequestMatcher(new AntPathRequestMatcher("/logout")).permitAll() 
                .logoutSuccessUrl("/login");
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(usuarioDao)
                .passwordEncoder(new BCryptPasswordEncoder());
    }

    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/resources/**");
    }
}
1 resposta
solução!

Já consegui solucionar estava faltando na SecurityConfiguration

.antMatchers("/relatorio-produtos/**").permitAll()

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software