fix: 日志入库

This commit is contained in:
wangyu 2021-01-16 01:28:35 +08:00
parent 37596bb702
commit a1f4b2ad31

View File

@ -3,9 +3,16 @@ package com.flyfish.framework.controller;
import com.flyfish.framework.bean.Result;
import com.flyfish.framework.config.RSAKeys;
import com.flyfish.framework.config.properties.SecurityProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.flyfish.framework.configuration.annotations.CurrentUser;
import com.flyfish.framework.configuration.jwt.TokenProvider;
import com.flyfish.framework.domain.po.User;
import com.flyfish.framework.utils.UserUtils;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import javax.annotation.Resource;
@ -20,6 +27,8 @@ public class LoginController {
@Resource
private SecurityProperties securityProperties;
@Resource
private TokenProvider tokenProvider;
/**
* 获取公钥如果有的话
@ -33,4 +42,19 @@ public class LoginController {
}
return Result.error("尚未配置加密密钥!");
}
/**
* 刷新token返回新token
* 这里不销毁原来的token等他自动过期
* @return 结果
*/
@GetMapping("refresh")
public Mono<Void> refreshToken(ServerWebExchange exchange) {
return ReactiveSecurityContextHolder.getContext()
.doOnNext(securityContext -> {
Authentication authentication = securityContext.getAuthentication();
tokenProvider.addToken(exchange, authentication);
})
.then();
}
}