id = user.getUserId(); | id = user.getUserId(); | ||||
username = user.getUserName(); | username = user.getUserName(); | ||||
password = user.getPassword(); | password = user.getPassword(); | ||||
authorities = Collections.singleton(new SimpleGrantedAuthority(user.getAuthority())); | |||||
authorities = Collections.singleton(new SimpleGrantedAuthority(user.getAuthorityList().toString())); | |||||
} | } | ||||
@Override | @Override |
import lombok.Data; | import lombok.Data; | ||||
import java.util.List; | |||||
/** | /** | ||||
* @author chenjiandong | * @author chenjiandong | ||||
* @description: TODO | * @description: TODO | ||||
private String password; | private String password; | ||||
private String authority; | |||||
private List<String> authorityList; | |||||
} | } |
if (scopes.contains(OidcScopes.PROFILE)) { | if (scopes.contains(OidcScopes.PROFILE)) { | ||||
builder.claim("userId", userBaseInfoDto.getUserId()) | builder.claim("userId", userBaseInfoDto.getUserId()) | ||||
.claim("userName", userBaseInfoDto.getUserName()) | .claim("userName", userBaseInfoDto.getUserName()) | ||||
.claim("authority", userBaseInfoDto.getAuthority()); | |||||
.claim("authority", userBaseInfoDto.getAuthorityList()); | |||||
} | } | ||||
/*if (scopes.contains(OidcScopes.EMAIL)) { | /*if (scopes.contains(OidcScopes.EMAIL)) { | ||||
builder.email(name + "@163.com").emailVerified(true); | builder.email(name + "@163.com").emailVerified(true); |
type: com.alibaba.druid.pool.DruidDataSource | type: com.alibaba.druid.pool.DruidDataSource | ||||
driver-class-name: com.mysql.cj.jdbc.Driver | driver-class-name: com.mysql.cj.jdbc.Driver | ||||
# 填写你数据库的url、登录名、密码和数据库名 | # 填写你数据库的url、登录名、密码和数据库名 | ||||
url: jdbc:mysql://192.168.11.242:3306/tuoheng_dsp?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false | |||||
url: jdbc:mysql://192.168.11.242:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false | |||||
username: root | username: root | ||||
password: idontcare | password: idontcare | ||||
druid: | druid: |
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
<mapper namespace="com.tuoheng.mapper.UserMapper"> | <mapper namespace="com.tuoheng.mapper.UserMapper"> | ||||
<resultMap type="com.tuoheng.model.dto.UserBaseInfoDto" id="UserBaseInfoMap"> | |||||
<id column="userId" jdbcType="INTEGER" property="userId" /> | |||||
<result column="userName" jdbcType="VARCHAR" property="userName" /> | |||||
<result column="password" jdbcType="VARCHAR" property="password" /> | |||||
<collection property="authorityList" ofType="java.lang.String" javaType="java.util.List"> | |||||
<result column="authority" jdbcType="VARCHAR"/> | |||||
</collection> | |||||
</resultMap> | |||||
<insert id="insertUser" parameterType="com.tuoheng.model.po.UserPo" keyProperty="id" useGeneratedKeys="true"> | <insert id="insertUser" parameterType="com.tuoheng.model.po.UserPo" keyProperty="id" useGeneratedKeys="true"> | ||||
insert into users (username, password) | insert into users (username, password) | ||||
values (#{username}, #{password}) | values (#{username}, #{password}) | ||||
</insert> | </insert> | ||||
<select id="getUserBaseInfo" resultType="com.tuoheng.model.dto.UserBaseInfoDto"> | |||||
<select id="getUserBaseInfo" resultMap="UserBaseInfoMap"> | |||||
select a.id as userId, a.username as userName, a.password , b.authority | select a.id as userId, a.username as userName, a.password , b.authority | ||||
from users a | from users a | ||||
inner join authorities b on a.id = b.user_id | inner join authorities b on a.id = b.user_id |