File tree Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Original file line number Diff line number Diff line change
1
+ ## To Record
2
+
3
+ - Step 75 - Configure Spring Security to disable CSRF and enable OPTION Requests
4
+ - https://www.udemy.com/course/spring-boot-and-spring-framework-tutorial-for-beginners/learn/lecture/35017794#overview
5
+ - Add Spring Security Section
6
+
7
+
1
8
## Code Changes
2
9
3
10
### /frontend/todo/src/app/list-todos/list-todos.component.ts
@@ -104,5 +111,3 @@ export class TodoComponent implements OnInit {
104
111
- handleErrorResponse(error) {
105
112
+ handleErrorResponse(error: any) {
106
113
```
107
-
108
-
Original file line number Diff line number Diff line change 24
24
25
25
## Spring Security - Configuration for Basic Auth
26
26
27
+ ### Spring Boot 2
28
+
29
+ ```
30
+ package com.in28minutes.rest.webservices.restfulwebservices.basic.auth;
31
+
32
+ import org.springframework.context.annotation.Configuration;
33
+ import org.springframework.http.HttpMethod;
34
+ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
35
+ import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
36
+ import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
37
+
38
+ @Configuration
39
+ @EnableWebSecurity
40
+ public class SpringSecurityConfigurationBasicAuth extends WebSecurityConfigurerAdapter{
41
+
42
+ @Override
43
+ protected void configure(HttpSecurity http) throws Exception {
44
+ http
45
+ .csrf().disable()
46
+ .authorizeRequests()
47
+ .antMatchers(HttpMethod.OPTIONS,"/**").permitAll()
48
+ .anyRequest().authenticated()
49
+ .and()
50
+ //.formLogin().and()
51
+ .httpBasic();
52
+ }
53
+ }
54
+ ```
55
+
56
+
57
+ ### Spring Boot 3
58
+
27
59
```
28
- package com.in28minutes.rest.basic.auth;
60
+ package com.in28minutes.rest.webservices.restfulwebservices. basic.auth;
29
61
30
62
import org.springframework.context.annotation.Bean;
31
63
import org.springframework.context.annotation.Configuration;
You can’t perform that action at this time.
0 commit comments