Skip to content

Commit

Permalink
feature_add_token_persistent
Browse files Browse the repository at this point in the history
  • Loading branch information
zackyoungh committed Nov 9, 2023
1 parent 8dc2431 commit ed039ba
Show file tree
Hide file tree
Showing 13 changed files with 449 additions and 83 deletions.
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
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

0 comments on commit ed039ba

Please sign in to comment.