2

I created the configuration class telling all requests must be authorized and setting httpBasic():

@Configuration
@EnableWebSecurity
public class WebConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests().anyRequest().authenticated().and()
            .httpBasic();
    }
}

But despite that, the password generated when restarting the server seems to be always wrong and not authorizing. If I comment it out it will naturally allow access to an endpoint I have. What could be wrong?

enter image description here

enter image description here

  • You need to tell use how are you storing the user/authorities information? –  Nov 01 '20 at 16:30
  • @macedonboy I am following a tutorial, and it is the generated `user` username and password that Spring created. No storage yet. This is what has been shown in the video but for me is not working. –  Nov 01 '20 at 16:35
  • The user information needs to be stored somewhere like InMemoryUserDetailsManager or some other Authentication manager –  Nov 01 '20 at 16:37
  • @macedonboy weird, it hasn't been done in the tutorial. If you'd like to see: https://youtu.be/her_7pa0vrg?t=1903 –  Nov 01 '20 at 16:39
  • I am doing exactly the same thing he is but this @#$ is failing for me. –  Nov 01 '20 at 16:52
  • Seems like there's something missing from that video. Does [this](https://www.yawintutor.com/using-generated-security-password-spring-boot/) help? –  Nov 01 '20 at 16:58
  • No, it did not. I will recreate the project. –  Nov 01 '20 at 17:03
  • Ok, so it was something with the previous attempt. It was a user microservice connected with Zuul and etc. Probably something I haven't done to make it possible. –  Nov 01 '20 at 17:10
  • in the future i suggest you read up on how to debug in spring boot. https://stackoverflow.com/a/47729991/1840146 will activate debuglogs that will tell you exactly what you are doing wrong. – Toerktumlare Nov 01 '20 at 18:51
  • Please attach to question also the controller and it's class, method level annotations. – mrkurtan Nov 07 '20 at 14:08

0 Answers0