Przeglądaj źródła

Add no authorization endpoint for plants

Blazej 3 lat temu
rodzic
commit
07825ffe30

+ 4 - 0
src/main/java/com/example/plantsforyou/plant/PlantController.java

@@ -22,4 +22,8 @@ public class PlantController {
         return plantService.getAllPlants();
     }
 
+    @GetMapping(path = "no-auth") //ONLY FOR TESTING
+    public List<Plant> getPlantsNoAuth(){
+        return plantService.getAllPlants();
+    }
 }

+ 1 - 1
src/main/java/com/example/plantsforyou/security/config/WebSecurityConfig.java

@@ -35,7 +35,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
     protected void configure(HttpSecurity http) throws Exception {
         http.csrf().disable().csrf();
         http.sessionManagement().sessionCreationPolicy(STATELESS);
-        http.authorizeRequests().antMatchers("/api/v*/registration/**", "/api/v*/users/token/refresh/**").permitAll();
+        http.authorizeRequests().antMatchers("/api/v*/registration/**", "/api/v*/users/token/refresh/**", "/api/v*/plants/no-auth").permitAll();
         http.authorizeRequests().antMatchers("/api/v*/**").hasAnyAuthority("USER");
         http.addFilter(new CustomAuthenticationFilter(authenticationManagerBean()));
         http.addFilterBefore(new CustomAuthorizationFilter(), UsernamePasswordAuthenticationFilter.class);