Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][token]Add token persistent #2512

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions dinky-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- sa-token 持久化 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.dinky</groupId>
<artifactId>dinky-core</artifactId>
Expand Down
63 changes: 0 additions & 63 deletions dinky-admin/src/main/java/org/dinky/configure/CacheConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
import cn.dev33.satoken.stp.StpLogic;
import cn.dev33.satoken.util.SaTokenConsts;

@Configuration
public class SaTokenConfigure {
// Sa-Token 整合 jwt (Simple 简单模式)
@Bean
public StpLogic getStpLogicJwt() {
return new StpLogicJwtForSimple();
// return new StpLogicJwtForSimple();
return new StpLogic(SaTokenConsts.TOKEN_STYLE_RANDOM_32);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import cn.hutool.core.lang.UUID;
import cn.dev33.satoken.stp.StpLogic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/** TokenController */
/**
* TokenController
*/
@Slf4j
@Api(tags = "Token Controller")
@RestController
Expand All @@ -58,6 +60,7 @@
public class TokenController {

private final TokenService tokenService;
private final StpLogic stpLogic;

/**
* get udf template list
Expand Down Expand Up @@ -113,12 +116,13 @@ public Result<Void> deleteToken(@RequestParam Integer id) {

/**
* delete Token by id
*
* @return {@link Result} <{@link Void}>
*/
@PostMapping("/buildToken")
@Log(title = "Build Token", businessType = BusinessType.OTHER)
@ApiOperation("Build Token")
public Result<String> buildToken() {
return Result.succeed(UUID.fastUUID().toString(true), Status.SUCCESS);
return Result.succeed(stpLogic.createTokenValue(null, null, 1, null), Status.SUCCESS);
}
}
14 changes: 14 additions & 0 deletions dinky-admin/src/main/java/org/dinky/data/model/SysToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
Expand All @@ -39,6 +40,7 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Data
Expand Down Expand Up @@ -154,4 +156,16 @@ public class SysToken implements Serializable {
dataType = "List<LocalDateTime>",
notes = "List of timestamps indicating the time range for token expiration")
private List<LocalDateTime> expireTimeRange;

private Source source;

@Getter
@AllArgsConstructor
public enum Source {
LOGIN(1),
CUSTOM(2);

@EnumValue
private final int type;
}
}
Loading
Loading