Merge branch 'cbx' of https://gitea.qinmian.online/cbx/Medical_Treatment into jpz
commit
cd27ebde9a
|
@ -0,0 +1,13 @@
|
||||||
|
package doctor.auth.controller;
|
||||||
|
|
||||||
|
import doctor.auth.service.HealthService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class HealthController {
|
||||||
|
// @Autowired
|
||||||
|
// private HealthService healthService;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package doctor.auth.service;
|
||||||
|
|
||||||
|
public class HealthService {
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package doctor.common.core.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Token的Key常量
|
* Token的Key常量
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class TokenConstants
|
public class TokenConstants
|
||||||
|
@ -11,6 +11,7 @@ public class TokenConstants
|
||||||
* 令牌自定义标识
|
* 令牌自定义标识
|
||||||
*/
|
*/
|
||||||
public static final String AUTHENTICATION = "Authorization";
|
public static final String AUTHENTICATION = "Authorization";
|
||||||
|
public static final String SESSIONID = "SESSIONID";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 令牌前缀
|
* 令牌前缀
|
||||||
|
|
|
@ -23,7 +23,7 @@ import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网关鉴权
|
* 网关鉴权
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
@ -46,12 +46,14 @@ public class AuthFilter implements GlobalFilter, Ordered
|
||||||
ServerHttpRequest.Builder mutate = request.mutate();
|
ServerHttpRequest.Builder mutate = request.mutate();
|
||||||
|
|
||||||
String url = request.getURI().getPath();
|
String url = request.getURI().getPath();
|
||||||
|
|
||||||
// 跳过不需要验证的路径
|
// 跳过不需要验证的路径
|
||||||
if (StringUtils.matches(url, ignoreWhite.getWhites()))
|
if (StringUtils.matches(url, ignoreWhite.getWhites()))
|
||||||
{
|
{
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
}
|
}
|
||||||
String token = getToken(request);
|
String token = getToken(request);
|
||||||
|
|
||||||
if (StringUtils.isEmpty(token))
|
if (StringUtils.isEmpty(token))
|
||||||
{
|
{
|
||||||
return unauthorizedResponse(exchange, "令牌不能为空");
|
return unauthorizedResponse(exchange, "令牌不能为空");
|
||||||
|
@ -119,6 +121,13 @@ public class AuthFilter implements GlobalFilter, Ordered
|
||||||
private String getToken(ServerHttpRequest request)
|
private String getToken(ServerHttpRequest request)
|
||||||
{
|
{
|
||||||
String token = request.getHeaders().getFirst(TokenConstants.AUTHENTICATION);
|
String token = request.getHeaders().getFirst(TokenConstants.AUTHENTICATION);
|
||||||
|
if (StringUtils.isNotEmpty(token))
|
||||||
|
{
|
||||||
|
token = request.getQueryParams().getFirst(TokenConstants.SESSIONID);
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotEmpty(token)){
|
||||||
|
request.getHeaders().set(TokenConstants.SESSIONID,token);
|
||||||
|
}
|
||||||
// 如果前端设置了令牌前缀,则裁剪掉前缀
|
// 如果前端设置了令牌前缀,则裁剪掉前缀
|
||||||
if (StringUtils.isNotEmpty(token) && token.startsWith(TokenConstants.PREFIX))
|
if (StringUtils.isNotEmpty(token) && token.startsWith(TokenConstants.PREFIX))
|
||||||
{
|
{
|
||||||
|
@ -132,4 +141,4 @@ public class AuthFilter implements GlobalFilter, Ordered
|
||||||
{
|
{
|
||||||
return -200;
|
return -200;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
<artifactId>doctor-common-swagger</artifactId>
|
<artifactId>doctor-common-swagger</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -10,10 +10,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableRyFeignClients
|
@EnableRyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class HealthApplication {
|
public class DoctorHealthApplication {
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
SpringApplication.run(HealthApplication.class, args);
|
SpringApplication.run(DoctorHealthApplication.class, args);
|
||||||
System.out.println("(♥◠‿◠)ノ゙ 健康服务启动成功 ლ(´ڡ`ლ)゙ \n" +
|
System.out.println("(♥◠‿◠)ノ゙ 健康服务启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||||
" .-------. ____ __ \n" +
|
" .-------. ____ __ \n" +
|
||||||
" | _ _ \\ \\ \\ / / \n" +
|
" | _ _ \\ \\ \\ / / \n" +
|
Loading…
Reference in New Issue