custom authentication provider

This commit is contained in:
Umesh Awasthi
2021-08-14 19:12:40 -07:00
parent 38c90e92ca
commit cfca39a34b
4 changed files with 3 additions and 4 deletions

View File

@@ -45,7 +45,7 @@ public class AppSecurityConfig extends WebSecurityConfigurerAdapter {
http.authorizeRequests()
.antMatchers("/login", "/register","/home")
.permitAll()
.antMatchers("/account/**").hasAuthority("CUSTOMER")
.antMatchers("/account/**").hasAnyAuthority("CUSTOMER", "ADMIN")
.and()
.exceptionHandling().accessDeniedHandler(accessDeniedHandler())
.and()

View File

@@ -50,5 +50,4 @@ public class CustomUserDetailService implements UserDetailsService{
return authorities;
}
}

View File

@@ -6,7 +6,7 @@
spring.jpa.generate-ddl=true
spring.datasource.url=jdbc:mysql://localhost:3306/spring-security-series?useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.password=12345678
#disabling cache for the development purpose
spring.template.cache=false

View File

@@ -18,7 +18,7 @@
</ul>
<ul class="navbar-nav ml-auto">
<li class="dropdown user user-menu" sec:authorize="hasAuthority('CUSTOMER')">
<li class="dropdown user user-menu" sec:authorize="hasAnyAuthority('CUSTOMER', 'ADMIN')">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="hidden-xs" sec:authentication="name"></span>
</a>