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 {
|
||||
}
|
|
@ -11,6 +11,7 @@ public class TokenConstants
|
|||
* 令牌自定义标识
|
||||
*/
|
||||
public static final String AUTHENTICATION = "Authorization";
|
||||
public static final String SESSIONID = "SESSIONID";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
|
|
|
@ -46,12 +46,14 @@ public class AuthFilter implements GlobalFilter, Ordered
|
|||
ServerHttpRequest.Builder mutate = request.mutate();
|
||||
|
||||
String url = request.getURI().getPath();
|
||||
|
||||
// 跳过不需要验证的路径
|
||||
if (StringUtils.matches(url, ignoreWhite.getWhites()))
|
||||
{
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
String token = getToken(request);
|
||||
|
||||
if (StringUtils.isEmpty(token))
|
||||
{
|
||||
return unauthorizedResponse(exchange, "令牌不能为空");
|
||||
|
@ -119,6 +121,13 @@ public class AuthFilter implements GlobalFilter, Ordered
|
|||
private String getToken(ServerHttpRequest request)
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
<artifactId>doctor-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -10,10 +10,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
public class HealthApplication {
|
||||
public class DoctorHealthApplication {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SpringApplication.run(HealthApplication.class, args);
|
||||
SpringApplication.run(DoctorHealthApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 健康服务启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
Loading…
Reference in New Issue