| | |
| | | package com.ycl.config; |
| | | |
| | | import com.ycl.component.DynamicSecurityService; |
| | | import com.ycl.entity.user.UmsMenu; |
| | | import com.ycl.entity.user.UmsResource; |
| | | import com.ycl.service.user.UmsAdminService; |
| | | import com.ycl.service.user.UmsMenuService; |
| | | import com.ycl.service.user.UmsResourceService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.access.ConfigAttribute; |
| | | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; |
| | | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
| | | import org.springframework.security.core.userdetails.UserDetailsService; |
| | | |
| | | import java.util.List; |
| | |
| | | @Autowired |
| | | private UmsAdminService adminService; |
| | | @Autowired |
| | | private UmsResourceService resourceService; |
| | | private UmsMenuService umsMenuService; |
| | | |
| | | @Bean |
| | | public UserDetailsService userDetailsService() { |
| | |
| | | @Override |
| | | public Map<String, ConfigAttribute> loadDataSource() { |
| | | Map<String, ConfigAttribute> map = new ConcurrentHashMap<>(); |
| | | List<UmsResource> resourceList = resourceService.list(); |
| | | for (UmsResource resource : resourceList) { |
| | | map.put(resource.getUrl(), new org.springframework.security.access.SecurityConfig(resource.getId() + ":" + resource.getName())); |
| | | List<UmsMenu> resourceList = umsMenuService.list(); |
| | | for (UmsMenu resource : resourceList) { |
| | | map.put(resource.getTitle(), new org.springframework.security.access.SecurityConfig(resource.getId() + ":" + resource.getTitle())); |
| | | } |
| | | return map; |
| | | } |