Skip to content

Commit

Permalink
temp rollback of spring security features to allow testing
Browse files Browse the repository at this point in the history
  • Loading branch information
eschremp committed Apr 22, 2024
1 parent ac9ec2a commit 3503576
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
8 changes: 4 additions & 4 deletions ReactFrontEnd/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ReactFrontEnd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"match-sorter": "^6.3.4",
"react": "^18.2.0",
"react-cookie": "^7.1.4",
"react-datepicker": "^6.6.0",
"react-datepicker": "^6.9.0",
"react-dom": "^18.2.0",
"react-icons": "^5.0.1",
"react-leaflet": "^4.2.1",
Expand Down
5 changes: 5 additions & 0 deletions ReactFrontEnd/src/Components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ function Header() {
icon:HiUser,
path:'/profile'
},
{
name: 'LOGIN',
icon: HiUser,
path: '/login'
}

]
return (
Expand Down
2 changes: 1 addition & 1 deletion ReactFrontEnd/src/Services/LoginService.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LoginService {
instance.interceptors.request.use((config) => {
const hash = window.btoa(user.username+":"+user.password);
if (hash) {
let authHeader = "Basic "+hash;
let authHeader = "Basic "+ hash;
instance.defaults.headers["Authorization"] = authHeader;
window.localStorage.setItem("Auth", authHeader);
}
Expand Down
1 change: 0 additions & 1 deletion ReactFrontEnd/src/Services/ReviewServices.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const axiosInstance = axios.create({

class ReviewService {
createReview(review) {
console.log(window.localStorage.getItem("Auth"));
return axiosInstance.post(REVIEW_API_BASE_URL, review)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
return config;
}

})).csrf((csrf) -> csrf.csrfTokenRequestHandler(requestHandler).ignoringRequestMatchers( "/register","/user")
})).csrf((csrf) -> csrf.csrfTokenRequestHandler(requestHandler).ignoringRequestMatchers( "/register","/user","/api/v1/**")
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()))
.addFilterAfter(new CsrfCookieFilter(), BasicAuthenticationFilter.class)
.authorizeHttpRequests((requests)->requests

.requestMatchers("/api/v1/**").authenticated()
.requestMatchers("/register","/user").permitAll())
//.requestMatchers("/createreview").authenticated()
.requestMatchers("/register","/user","/api/v1/**").permitAll())

.formLogin(Customizer.withDefaults())
.httpBasic(Customizer.withDefaults());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ResponseEntity<Favorites> getFavoritesById(@PathVariable Long id) {
return ResponseEntity.ok(favorites);
}

@PostMapping("/favorites")
@PostMapping("/addFavorites")
public Favorites addToFavorites(@RequestBody Favorites favorites) {
return favoritesService.addToFavorites(favorites);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ public ResponseEntity<String> registerUser(@RequestBody User user) {
}

@RequestMapping("/user")
public ResponseEntity<String> loginUser (@RequestBody User user) {
return ResponseEntity
.status(HttpStatus.CREATED)
.body("Given user details are successfully registered");
}
public User loginUser (@RequestBody User user) {
return userRepository.findByUsername(user.getUsername());
}

}

0 comments on commit 3503576

Please sign in to comment.