Springboot Part:10

Published: 10 November 2020
on channel: GIRISH KUMAR MISHRA
124
2

Way to generate bcrypt password:
public static void main(String[] args) {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
encoded = encoder.encode("Best@123");//Girish's password
System.out.println("Girish :"+encoded);
SpringApplication.run(Demo1Application.class, args);
}
OR
https://bcrypt-generator.com/
Table creation:
---------------------------------------------------------------------------------------------------------
DROP TABLE authorities;
DROP TABLE users;

create table users (
username varchar(50) not null primary key,
password varchar(120) not null,
enabled tinyint(1) not null
);

create table authorities (
username varchar(50) not null,
authority varchar(50) not null,
foreign key (username) references users (username)
);

insert into users(username, password, enabled)values('girish','$2y$10$sBiPavfQWXNBy9MICuO6Xuf.fasWvpKBOdjXUgMZ8ro8hEhvQTYaq',1);
insert into authorities(username,authority)values('girish','ROLE_ADMIN');

insert into users(username, password, enabled)values('rajeev','$2y$10$URffSmEyBZpQ2HqECC32KeKIBDGQn2e7VgSINa2STRhW2nrHvGzMu',1);
insert into authorities(username,authority)values('rajeev','ROLE_USER');
-----------------------------------------------------------------------------------------------------------------
Java Security configuration details:
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}

@Bean
public JdbcUserDetailsManager jdbcUserDetailsManager() {
return new JdbcUserDetailsManager(dataSource);
}
@Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception{
auth.jdbcAuthentication().dataSource(dataSource).passwordEncoder(passwordEncoder());
}
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception{
httpSecurity.authorizeRequests()
.antMatchers("/rest/getEmploees").hasRole("USER")
.anyRequest()
.authenticated()
.and()
.formLogin();
}
---------------------------------------------------------------------------------------------------


On this page of the site you can watch the video online Springboot Part:10 with a duration of hours minute second in good quality, which was uploaded by the user GIRISH KUMAR MISHRA 10 November 2020, share the link with friends and acquaintances, this video has already been watched 124 times on youtube and it was liked by 2 viewers. Enjoy your viewing!