fix: 日志入库
This commit is contained in:
parent
37596bb702
commit
a1f4b2ad31
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user