You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.6 KiB
48 lines
1.6 KiB
11 months ago
|
package com.teaching.backend.config;
|
||
|
|
||
|
|
||
|
import com.teaching.backend.service.umsAdmin.UmsAdminService;
|
||
|
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.core.userdetails.UserDetailsService;
|
||
|
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import java.util.concurrent.ConcurrentHashMap;
|
||
|
|
||
|
/**
|
||
|
* mall-security模块相关配置
|
||
|
* Created by macro on 2019/11/9.
|
||
|
*/
|
||
|
@Configuration
|
||
|
public class MallSecurityConfig {
|
||
|
|
||
|
@Autowired
|
||
|
private UmsAdminService umsadminService;
|
||
|
// @Autowired
|
||
|
// private UmsResourceService resourceService;
|
||
|
|
||
|
@Bean
|
||
|
public UserDetailsService userDetailsService() {
|
||
|
//获取登录用户信息
|
||
|
return username -> umsadminService.loadUserByUsername(username);
|
||
|
}
|
||
|
|
||
|
// @Bean
|
||
|
// public DynamicSecurityService dynamicSecurityService() {
|
||
|
// return new DynamicSecurityService() {
|
||
|
// @Override
|
||
|
// public Map<String, ConfigAttribute> loadDataSource() {
|
||
|
// Map<String, ConfigAttribute> map = new ConcurrentHashMap<>();
|
||
|
// List<UmsResource> resourceList = resourceService.listAll();
|
||
|
// for (UmsResource resource : resourceList) {
|
||
|
// map.put(resource.getUrl(), new org.springframework.security.access.SecurityConfig(resource.getId() + ":" + resource.getName()));
|
||
|
// }
|
||
|
// return map;
|
||
|
// }
|
||
|
// };
|
||
|
// }
|
||
|
}
|