Update HttpSecurityConfig.java

This commit is contained in:
Rufina Uche 2023-10-14 21:49:30 +01:00 committed by GitHub
parent 9fcdc43c5c
commit 4fb3cb2577
1 changed files with 7 additions and 8 deletions

View File

@ -13,18 +13,17 @@ public class HttpSecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
// Given: HttpSecurity configured // Given: HttpSecurity configured
http http.authorizeRequests()
.authorizeRequests() .antMatchers("/public/**").permitAll()
.antMatchers("/public/**").permitAll() .antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/admin/**").hasRole("ADMIN") .anyRequest().authenticated()
.anyRequest().authenticated()
.and() .and()
.formLogin() .formLogin()
.loginPage("/login") .loginPage("/login")
.permitAll() .permitAll()
.and() .and()
.logout() .logout()
.permitAll(); .permitAll();
// When: Accessing specific URLs // When: Accessing specific URLs
// Then: Access is granted based on defined rules // Then: Access is granted based on defined rules