mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-09-19 10:08:07 +08:00
整合 jwt 临时令牌鉴权
This commit is contained in:
@@ -15,6 +15,7 @@ import cn.dev33.satoken.context.SaTokenContextForThreadLocal;
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.dev33.satoken.listener.SaTokenListener;
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import cn.dev33.satoken.temp.SaTempInterface;
|
||||
|
||||
/**
|
||||
* 利用spring的自动装配来加载开发者重写的Bean
|
||||
@@ -113,6 +114,16 @@ public class SaTokenSpringAutowired {
|
||||
public void setSaTokenListener(SaTokenListener saTokenListener) {
|
||||
SaManager.setSaTokenListener(saTokenListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注入临时令牌验证模块 Bean
|
||||
*
|
||||
* @param saTemp saTemp对象
|
||||
*/
|
||||
@Autowired(required = false)
|
||||
public void setSaTemp(SaTempInterface saTemp) {
|
||||
SaManager.setSaTemp(saTemp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 利用自动注入特性,获取Spring框架内部使用的路由匹配器
|
||||
|
@@ -16,6 +16,7 @@ import cn.dev33.satoken.listener.SaTokenListener;
|
||||
import cn.dev33.satoken.solon.integration.SaContextForSolon;
|
||||
import cn.dev33.satoken.solon.integration.SaTokenMethodInterceptor;
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import cn.dev33.satoken.temp.SaTempInterface;
|
||||
|
||||
/**
|
||||
* @author noear
|
||||
@@ -39,25 +40,30 @@ public class XPluginImp implements Plugin {
|
||||
//注入容器交互Bean
|
||||
SaManager.setSaTokenContext(new SaContextForSolon());
|
||||
|
||||
//注入侦听器Bean
|
||||
// 注入侦听器 Bean
|
||||
Aop.getAsyn(SaTokenListener.class, bw->{
|
||||
SaManager.setSaTokenListener(bw.raw());
|
||||
});
|
||||
|
||||
//注入框架行为Bean
|
||||
// 注入框架行为 Bean
|
||||
Aop.getAsyn(SaTokenAction.class, bw->{
|
||||
SaManager.setSaTokenAction(bw.raw());
|
||||
});
|
||||
|
||||
//注入权限认证Bean
|
||||
// 注入权限认证 Bean
|
||||
Aop.getAsyn(StpInterface.class, bw->{
|
||||
SaManager.setStpInterface(bw.raw());
|
||||
});
|
||||
|
||||
//注入持久化Bean
|
||||
// 注入持久化 Bean
|
||||
Aop.getAsyn(SaTokenDao.class, bw->{
|
||||
SaManager.setSaTokenDao(bw.raw());
|
||||
});
|
||||
|
||||
// 临时令牌验证模块 Bean
|
||||
Aop.getAsyn(SaTempInterface.class, bw->{
|
||||
SaManager.setSaTemp(bw.raw());
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ import cn.dev33.satoken.context.SaTokenContext;
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.dev33.satoken.listener.SaTokenListener;
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import cn.dev33.satoken.temp.SaTempInterface;
|
||||
|
||||
/**
|
||||
* 利用spring的自动装配来加载开发者重写的Bean
|
||||
@@ -105,6 +106,16 @@ public class SaTokenSpringAutowired {
|
||||
SaManager.setSaTokenListener(saTokenListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注入临时令牌验证模块 Bean
|
||||
*
|
||||
* @param saTemp saTemp对象
|
||||
*/
|
||||
@Autowired(required = false)
|
||||
public void setSaTemp(SaTempInterface saTemp) {
|
||||
SaManager.setSaTemp(saTemp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 利用自动注入特性,获取Spring框架内部使用的路由匹配器
|
||||
*
|
||||
|
@@ -177,7 +177,6 @@ public class SaTokenSpringBootStarterTest {
|
||||
|
||||
// 解析token
|
||||
String value = SaTempUtil.parseToken(token, String.class);
|
||||
System.out.println(value);
|
||||
Assert.assertEquals(value, "group-1014");
|
||||
|
||||
// 过期时间
|
||||
|
Reference in New Issue
Block a user