vaadin / flow-crm-tutorial

Demo app for the Java Web App tutorial series
The Unlicense
172 stars 185 forks source link

cant login locally #156

Closed bgard68 closed 1 year ago

bgard68 commented 1 year ago

This is the code in the github repository v24 branch and I have tried many combos and nothing seems to work. What am I missing to be able to login locally ?

@Bean public UserDetailsService users() { UserDetails user = User.builder() .username("user") // password = password with this hash, don't tell anybody :-) .password("{bcrypt}$2a$10$GRLdNijSQMUvl/au9ofL.eDwmoohzzS7.rmNSJZ.0FxO/BTk76klW") .roles("USER") .build(); UserDetails admin = User.builder() .username("admin") .password("{bcrypt}$2a$10$GRLdNijSQMUvl/au9ofL.eDwmoohzzS7.rmNSJZ.0FxO/BTk76klW") .roles("USER", "ADMIN") .build(); return new InMemoryUserDetailsManager(user, admin); // <5>

jankod commented 1 year ago

I added this code and then it works for me. Otherwise, I did not find anywhere what the password is for the defined user and admin.


 @Bean
    public UserDetailsService users() {

        String pass = encoder().encode("ja");
        UserDetails user = User.builder()
              .username("user")
              // password = password with this hash, don't tell anybody :-)
              //.password("{bcrypt}$2a$10$GRLdNijSQMUvl/au9ofL.eDwmoohzzS7.rmNSJZ.0FxO/BTk76klW")
              .password(pass)
              .roles("USER")
              .build();
        UserDetails admin = User.builder()
              .username("admin")
              //.password("{bcrypt}$2a$10$GRLdNijSQMUvl/au9ofL.eDwmoohzzS7.rmNSJZ.0FxO/BTk76klW")
              .password(pass)
              .roles("USER", "ADMIN")
              .build();
        return new InMemoryUserDetailsManager(user, admin); // <5>
    }

    @Bean
    public PasswordEncoder encoder() {
        return new BCryptPasswordEncoder();
    }
bgard68 commented 1 year ago

Thank you for responding so quickly, @jankod . I've added the above code and tried logging in as admin, ja and still login error, as if, the SecurityConfig isn't recognized.

mcollovati commented 1 year ago

I just cloned the repo, started the application and was able to login without any change

bgard68 commented 1 year ago

idk what im doing wrong but not able to login as is. moving on. Thanks again for the quick responses.