parent
							
								
									2ba43e56bc
								
							
						
					
					
						commit
						345ec09be5
					
				
				 20 changed files with 142 additions and 146 deletions
			
			
		| @ -0,0 +1,27 @@ | ||||
| package com.zhengqing.common.auth.config; | ||||
| 
 | ||||
| import cn.dev33.satoken.jwt.StpLogicJwtForSimple; | ||||
| import cn.dev33.satoken.stp.StpLogic; | ||||
| import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.Configuration; | ||||
| 
 | ||||
| /** | ||||
|  * <p> Sa-Token 配置类 </p> | ||||
|  * | ||||
|  * @author zhengqingya | ||||
|  * @description | ||||
|  * @date 2021/11/3 12:06 | ||||
|  */ | ||||
| @Configuration | ||||
| public class SaTokenConfig { | ||||
| 
 | ||||
|     /** | ||||
|      * Sa-Token 整合 jwt (Simple 简单模式) | ||||
|      * 参考 https://sa-token.cc/doc.html#/plugin/jwt-extend
 | ||||
|      */ | ||||
|     @Bean | ||||
|     public StpLogic getStpLogicJwt() { | ||||
|         return new StpLogicJwtForSimple(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -1,30 +0,0 @@ | ||||
| package com.zhengqing.common.auth.config; | ||||
| 
 | ||||
| import cn.dev33.satoken.strategy.SaStrategy; | ||||
| import cn.dev33.satoken.util.SaFoxUtil; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.annotation.Configuration; | ||||
| 
 | ||||
| /** | ||||
|  * <p> 自定义sa-token生成策略 </p> | ||||
|  * | ||||
|  * @author zhengqingya | ||||
|  * @description | ||||
|  * @date 2021/11/3 12:06 | ||||
|  */ | ||||
| @Configuration | ||||
| public class SaTokenCustomConfig { | ||||
| 
 | ||||
|     /** | ||||
|      * 重写 Sa-Token 框架内部算法策略 | ||||
|      */ | ||||
|     @Autowired | ||||
|     public void rewriteSaStrategy() { | ||||
|         // 重写 Token 生成策略
 | ||||
|         SaStrategy.me.createToken = (loginId, loginType) -> { | ||||
|             // 随机60位长度字符串
 | ||||
|             return SaFoxUtil.getRandomString(60); | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -1,48 +0,0 @@ | ||||
| package com.zhengqing.common.base.model.bo; | ||||
| 
 | ||||
| import com.zhengqing.common.base.enums.AuthSourceEnum; | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Data; | ||||
| import lombok.NoArgsConstructor; | ||||
| import lombok.experimental.SuperBuilder; | ||||
| 
 | ||||
| /** | ||||
|  * <p> jwt中自定义的用户信息 </p> | ||||
|  * | ||||
|  * @author zhengqingya | ||||
|  * @description {@link com.zhengqing.auth.security.config.CustomAdditionalInformation} | ||||
|  * @date 2022/6/15 10:34 | ||||
|  */ | ||||
| @Data | ||||
| @SuperBuilder | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class JwtCustomUserBO { | ||||
|     /** | ||||
|      * {@link AuthSourceEnum} | ||||
|      */ | ||||
|     @ApiModelProperty(value = "认证来源") | ||||
|     private String authSource; | ||||
| 
 | ||||
|     @ApiModelProperty(value = "jwt") | ||||
|     private String token; | ||||
| 
 | ||||
|     @ApiModelProperty(value = "jwt的唯一身份标识") | ||||
|     private String jti; | ||||
| 
 | ||||
|     @ApiModelProperty(value = "过期时间(2022-06-01 23:06:53)") | ||||
|     private String expireTime; | ||||
| 
 | ||||
|     @ApiModelProperty(value = "租户ID") | ||||
|     private String tenantId; | ||||
| 
 | ||||
|     @ApiModelProperty(value = "B端系统用户ID") | ||||
|     private String sysUserId; | ||||
| 
 | ||||
|     @ApiModelProperty(value = "C端用户ID") | ||||
|     private String umsUserId; | ||||
| 
 | ||||
|     @ApiModelProperty(value = "用户名") | ||||
|     private String username; | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue
	
	 zhengqingya
						zhengqingya