修改消息服务 忽略过滤名单
parent
e5a5c047fa
commit
57884a9527
@ -0,0 +1,23 @@
|
||||
package com.baiye.exception;
|
||||
|
||||
/**
|
||||
* @author Enzo
|
||||
* @date: 2022/1/6
|
||||
* @Description
|
||||
*/
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Enzo
|
||||
* @date : 2022/1/9
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public class CallException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 9022008349767066965L;
|
||||
|
||||
public CallException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.baiye.feign;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 鉴权配置
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class FeignProvider {
|
||||
|
||||
private static final List<String> DEFAULT_SKIP_URL = new ArrayList<>();
|
||||
|
||||
static {
|
||||
DEFAULT_SKIP_URL.add("/swagger/**");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认无需鉴权的API
|
||||
*/
|
||||
public static List<String> getDefaultSkipUrl() {
|
||||
return DEFAULT_SKIP_URL;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.baiye.model.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Enzo
|
||||
* @date : 2022/1/9
|
||||
*/
|
||||
@Data
|
||||
public class ChangeMessageDTO {
|
||||
private Boolean flag;
|
||||
|
||||
private Long messageId;
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.baiye.filter;
|
||||
|
||||
import com.baiye.constant.SecurityConstants;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Enzo
|
||||
* @date : 2022/1/9
|
||||
*/
|
||||
@Order(1)
|
||||
@Component
|
||||
@WebFilter(filterName = "WebsocketFilter",urlPatterns = "/task/prosperous")
|
||||
public class WebsocketFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
String token = ((HttpServletRequest) request).getHeader("Sec-WebSocket-Protocol");
|
||||
response.setHeader("Sec-WebSocket-Protocol",token);
|
||||
if (token != null) {
|
||||
request.setAttribute(SecurityConstants.AUTHORIZATION,token);
|
||||
}
|
||||
chain.doFilter(request, servletResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue