轻量级权限认证SpringBoot实现,使用Redis、雪花ID、Base62等技术
- 主线版本
- 兼容模式 支持
SpringBoot 2.7.0
以下版本 - 精简版 去除
id
字段、拓展内容
字段、新增用户名密码校验
- 兼容模式 精简版
- 基本认证版 仅提供
Basic Authentication
认证 - SpringBoot 3.x版 支持
SpringBoot 3.0.0
及以上版本 - SpringBoot 3.x 精简版
- SpringBoot 3.x 基本认证版
<dependency>
<groupId>cn.404z</groupId>
<artifactId>tiny-token-spring-boot-starter</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.18</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.7.18</version>
</dependency>
<dependency>
<groupId>cn.404z</groupId>
<artifactId>id-spring-boot-autoconfigure</artifactId>
<version>3.1.2</version>
</dependency>
// 注入
private final T4s t4s;
// 设置token(token使用32位随机字符串 过期时间使用默认值)
t4s.setToken(id);
// 获取token(当前Context 不判断是否有效)
t4s.getToken();
// 获取token(当前Context 判断是否有效)
t4s.getTokenValid();
// 获取id(当前Context)
t4s.getId();
// 删除(当前Context)
t4s.deleteByToken();
// 设置过期时间(当前Context 过期时间使用默认值)
t4s.expire();
// 设置永不过期(当前Context)
t4s.persist();
// 获取信息(当前Context)
t4s.getInfoByToken();
// 获取拓展信息(当前Context)
t4s.getInfoExtraByToken();
更多请见测试