Merge pull request 'develop' (#6) from develop into master

Reviewed-on: #6
This commit is contained in:
Petr 2025-02-20 12:22:50 +00:00
commit a68deda0c0
4 changed files with 4 additions and 18 deletions

View File

@ -5,7 +5,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
@ -33,21 +32,13 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http.csrf().disable() http.csrf().disable()
.authorizeRequests() .authorizeRequests()
.antMatchers("/h2-console/**").permitAll() .antMatchers("/h2-console/**").permitAll()
.antMatchers("/api/v1/images/**").permitAll() .antMatchers("/api/v1/**").hasAnyAuthority("ROLE_USER", "ROLE_ADMIN")
.antMatchers("/api/v1/volunteers/login").permitAll() .antMatchers("/api/v1/authorization/login").permitAll()
.antMatchers("/api/v1/volunteers/register").permitAll() .antMatchers("/api/v1/authorization/register").permitAll()
.antMatchers("/api/v1/**").permitAll()
//.antMatchers("/api/v1/**").hasAnyAuthority("ROLE_USER", "ROLE_ADMIN")
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()
.httpBasic() .httpBasic()
.and() .and()
.headers().frameOptions().disable(); .headers().frameOptions().disable();
} }
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers("/api/v1/volunteers/images");
}
} }

View File

@ -17,6 +17,7 @@ public class AuthorizationController {
@GetMapping("/login") @GetMapping("/login")
public ResponseEntity<EmployeeDTO> login(Authentication authentication) { public ResponseEntity<EmployeeDTO> login(Authentication authentication) {
return ResponseEntity.ok(employeeService.getByEmail(authentication.getName())); return ResponseEntity.ok(employeeService.getByEmail(authentication.getName()));
} }

View File

@ -65,5 +65,4 @@ public class EmployeeController {
employeeService.patchBlockEmployee(employeeId, blockStatus); employeeService.patchBlockEmployee(employeeId, blockStatus);
return ResponseEntity.noContent().build(); return ResponseEntity.noContent().build();
} }
} }

View File

@ -94,11 +94,6 @@ public class Employee implements UserDetails {
return List.of(this.role); return List.of(this.role);
} }
@Override
public String getPassword() {
return this.password;
}
@Override @Override
public String getUsername() { public String getUsername() {
return this.email; return this.email;