| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.domain.SysClientDetails;
|
| | | import com.ruoyi.system.service.ISysClientDetailsService;
|
| | |
|
| | |
| | | {
|
| | | return AjaxResult.error("新增终端'" + clientId + "'失败,编号已存在");
|
| | | }
|
| | | sysClientDetails.setClientSecret(SecurityUtils.encryptPassword(sysClientDetails.getClientSecret()));
|
| | | return toAjax(sysClientDetailsService.insertSysClientDetails(sysClientDetails));
|
| | | }
|
| | |
|
| | |
| | | @PutMapping
|
| | | public AjaxResult edit(@RequestBody SysClientDetails sysClientDetails)
|
| | | {
|
| | | sysClientDetails.setClientSecret(SecurityUtils.encryptPassword(sysClientDetails.getClientSecret()));
|
| | | return toAjax(sysClientDetailsService.updateSysClientDetails(sysClientDetails));
|
| | | }
|
| | |
|
| | |
| | | */
|
| | | private String autoapprove;
|
| | |
|
| | | /**
|
| | | * 终端明文安全码
|
| | | */
|
| | | private String originSecret;
|
| | |
|
| | | public String getClientId()
|
| | | {
|
| | | return clientId;
|
| | |
| | | this.autoapprove = autoapprove;
|
| | | }
|
| | |
|
| | | public String getOriginSecret()
|
| | | {
|
| | | return originSecret;
|
| | | }
|
| | |
|
| | | public void setOriginSecret(String originSecret)
|
| | | {
|
| | | this.originSecret = originSecret;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
| | |
| | | .append("refreshTokenValidity", getRefreshTokenValidity())
|
| | | .append("additionalInformation", getAdditionalInformation())
|
| | | .append("autoapprove", getAutoapprove())
|
| | | .append("originSecret", getOriginSecret())
|
| | | .toString();
|
| | | }
|
| | | }
|
| | |
| | | import org.springframework.cache.annotation.CacheEvict;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.core.constant.CacheConstants;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.domain.SysClientDetails;
|
| | | import com.ruoyi.system.mapper.SysClientDetailsMapper;
|
| | | import com.ruoyi.system.service.ISysClientDetailsService;
|
| | |
| | | @Override
|
| | | public int insertSysClientDetails(SysClientDetails sysClientDetails)
|
| | | {
|
| | | sysClientDetails.setClientSecret(SecurityUtils.encryptPassword(sysClientDetails.getOriginSecret()));
|
| | | return sysClientDetailsMapper.insertSysClientDetails(sysClientDetails);
|
| | | }
|
| | |
|
| | |
| | | @CacheEvict(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#sysClientDetails.clientId")
|
| | | public int updateSysClientDetails(SysClientDetails sysClientDetails)
|
| | | {
|
| | | sysClientDetails.setClientSecret(SecurityUtils.encryptPassword(sysClientDetails.getOriginSecret()));
|
| | | return sysClientDetailsMapper.updateSysClientDetails(sysClientDetails);
|
| | | }
|
| | |
|
| | |
| | | <result property="refreshTokenValidity" column="refresh_token_validity" />
|
| | | <result property="additionalInformation" column="additional_information" />
|
| | | <result property="autoapprove" column="autoapprove" />
|
| | | <result property="originSecret" column="origin_secret" />
|
| | | </resultMap>
|
| | |
|
| | | <sql id="selectSysClientDetailsVo">
|
| | | select client_id, resource_ids, client_secret, scope, authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, refresh_token_validity, additional_information, autoapprove from sys_oauth_client_details
|
| | | select client_id, resource_ids, client_secret, scope, authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, refresh_token_validity, additional_information, autoapprove, origin_secret from sys_oauth_client_details
|
| | | </sql>
|
| | |
|
| | | <select id="selectSysClientDetailsList" parameterType="SysClientDetails" resultMap="SysClientDetailsResult">
|
| | |
| | | <if test="refreshTokenValidity != null">refresh_token_validity,</if>
|
| | | <if test="additionalInformation != null">additional_information,</if>
|
| | | <if test="autoapprove != null">autoapprove,</if>
|
| | | <if test="originSecret != null">origin_secret,</if>
|
| | | </trim>
|
| | | <trim prefix="values (" suffix=")" suffixOverrides=",">
|
| | | <if test="clientId != null">#{clientId},</if>
|
| | |
| | | <if test="refreshTokenValidity != null">#{refreshTokenValidity},</if>
|
| | | <if test="additionalInformation != null">#{additionalInformation},</if>
|
| | | <if test="autoapprove != null ">#{autoapprove},</if>
|
| | | <if test="originSecret != null ">#{originSecret},</if>
|
| | | </trim>
|
| | | </insert>
|
| | |
|
| | |
| | | <if test="refreshTokenValidity != null">refresh_token_validity = #{refreshTokenValidity},</if>
|
| | | <if test="additionalInformation != null">additional_information = #{additionalInformation},</if>
|
| | | <if test="autoapprove != null">autoapprove = #{autoapprove},</if>
|
| | | <if test="originSecret != null">origin_secret = #{originSecret},</if>
|
| | | </trim>
|
| | | where client_id = #{clientId}
|
| | | </update>
|
| | |
| | | <el-table v-loading="loading" :data="clientList" @selection-change="handleSelectionChange">
|
| | | <el-table-column type="selection" width="55" align="center" />
|
| | | <el-table-column label="编号" align="center" prop="clientId" />
|
| | | <el-table-column label="安全码" align="center" prop="clientSecret" :show-overflow-tooltip="true" />
|
| | | <el-table-column label="安全码" align="center" prop="originSecret" :show-overflow-tooltip="true" />
|
| | | <el-table-column label="授权范围" align="center" prop="scope" />
|
| | | <el-table-column label="授权类型" align="center" prop="authorizedGrantTypes" :show-overflow-tooltip="true" />
|
| | | <el-table-column label="令牌时效" align="center" prop="accessTokenValidity" />
|
| | |
| | | <el-form-item label="编号" prop="clientId">
|
| | | <el-input v-model="form.clientId" placeholder="请输入编号" :disabled="!isAdd" />
|
| | | </el-form-item>
|
| | | <el-form-item label="安全码" prop="clientSecret">
|
| | | <el-input v-model="form.clientSecret" placeholder="请输入安全码" />
|
| | | <el-form-item label="安全码" prop="originSecret">
|
| | | <el-input v-model="form.originSecret" placeholder="请输入安全码" />
|
| | | </el-form-item>
|
| | | <el-form-item label="授权范围" prop="scope">
|
| | | <el-input v-model="form.scope" placeholder="请输入授权范围" />
|
| | |
| | | clientId: [
|
| | | { required: true, message: "编号不能为空", trigger: "blur" }
|
| | | ],
|
| | | clientSecret: [
|
| | | originSecret: [
|
| | | { required: true, message: "安全码不能为空", trigger: "blur" }
|
| | | ],
|
| | | scope: [
|
| | |
| | | refresh_token_validity int(11) default null comment '设定终端的refresh_token的有效时间值(秒)',
|
| | | additional_information varchar(4096) default null comment '附加信息',
|
| | | autoapprove tinyint(4) default null comment '是否登录时跳过授权',
|
| | | origin_secret varchar(255) not null comment '终端明文安全码',
|
| | | primary key (client_id)
|
| | | ) engine=innodb auto_increment=1 comment = '终端配置表';
|
| | |
|
| | | -- ----------------------------
|
| | | -- 初始化-终端配置表数据
|
| | | -- ----------------------------
|
| | | insert into sys_oauth_client_details values ('web', '', '$2a$10$y2hKeELx.z3Sbz.kjQ4wmuiIsv5ZSbUQ1ov4BwFH6ccirP8Knp1uq', 'server', 'password,refresh_token', '', NULL, 3600, 7200, NULL, NULL);
|
| | | insert into sys_oauth_client_details values ('ruoyi', '', '$2a$10$y2hKeELx.z3Sbz.kjQ4wmuiIsv5ZSbUQ1ov4BwFH6ccirP8Knp1uq', 'server', 'password,client_credentials,refresh_token', '', NULL, 3600, 7200, NULL, NULL); |
| | | insert into sys_oauth_client_details values ('web', '', '$2a$10$y2hKeELx.z3Sbz.kjQ4wmuiIsv5ZSbUQ1ov4BwFH6ccirP8Knp1uq', 'server', 'password,refresh_token', '', NULL, 3600, 7200, NULL, NULL, '123456');
|
| | | insert into sys_oauth_client_details values ('ruoyi', '', '$2a$10$y2hKeELx.z3Sbz.kjQ4wmuiIsv5ZSbUQ1ov4BwFH6ccirP8Knp1uq', 'server', 'password,client_credentials,refresh_token', '', NULL, 3600, 7200, NULL, NULL, '123456'); |