[d3cf3a1] | 1 | package project.educatum;
|
---|
| 2 |
|
---|
| 3 | import org.springframework.boot.SpringApplication;
|
---|
| 4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
|
---|
| 5 | import org.springframework.boot.web.servlet.ServletComponentScan;
|
---|
| 6 | import org.springframework.context.annotation.Bean;
|
---|
| 7 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
---|
| 8 | import org.springframework.security.crypto.password.PasswordEncoder;
|
---|
| 9 | import org.springframework.security.web.firewall.HttpFirewall;
|
---|
| 10 | import org.springframework.security.web.firewall.HttpStatusRequestRejectedHandler;
|
---|
| 11 | import org.springframework.security.web.firewall.RequestRejectedHandler;
|
---|
| 12 | import org.springframework.security.web.firewall.StrictHttpFirewall;
|
---|
| 13 |
|
---|
| 14 | @SpringBootApplication
|
---|
| 15 | @ServletComponentScan
|
---|
| 16 | public class EducatumApplication {
|
---|
| 17 |
|
---|
| 18 | public static void main(String[] args) {
|
---|
| 19 | SpringApplication.run(EducatumApplication.class, args);
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | @Bean
|
---|
| 23 | PasswordEncoder passwordEncoder() {
|
---|
| 24 | return new BCryptPasswordEncoder();
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | @Bean
|
---|
| 28 | public HttpFirewall allowUrlSemicolonHttpFirewall() {
|
---|
| 29 | StrictHttpFirewall firewall = new StrictHttpFirewall();
|
---|
| 30 | firewall.setAllowSemicolon(true);
|
---|
| 31 | return firewall;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | @Bean
|
---|
| 35 | RequestRejectedHandler requestRejectedHandler() {
|
---|
| 36 | // sends an error response with a configurable status code (default is 400 BAD_REQUEST)
|
---|
| 37 | // we can pass a different value in the constructor
|
---|
| 38 | return new HttpStatusRequestRejectedHandler();
|
---|
| 39 | }
|
---|
| 40 | }
|
---|