package com.ho.flow.config;

import com.ho.common.tools.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author fancl
 * @desc: 给流程框架自定义用户体系
 * @date 2023/2/5
 */
@Component
public class MyUserDetailServiceImpl implements UserDetailsService {
    @Autowired
    RedisService redisService;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        //只是为了不报错,因为用户和权限已经有框架来控制
        List<GrantedAuthority> authorities= AuthorityUtils.commaSeparatedStringToAuthorityList("admin");
        User user = new User(username,"", authorities);
        return user;
    }
}
