Skip to content

Commit

Permalink
Merge pull request #164 from FederatedAI/develop-1.11.1
Browse files Browse the repository at this point in the history
Develop 1.11.1
  • Loading branch information
idwenwen authored May 31, 2023
2 parents e778f31 + 4d5e848 commit 09ff73f
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 4 deletions.
8 changes: 8 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Release 1.11.1

#### Major Features and Improvements
**Major Features**

* Optimize authentication mechanism for websocket.
* Optimize page rendering

# Release 1.11.0

#### Major Features and Improvements
Expand Down
4 changes: 2 additions & 2 deletions bin/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ status() {
if [[ -n ${pid} ]]; then
echo "status:
$(ps aux | grep ${pid} | grep -v grep)"
return 1
return 0
else
echo "service not running"
return 0
return 1
fi
}

Expand Down
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fateboard</groupId>
<artifactId>fateboard</artifactId>
<version>1.11.0</version>
<version>1.11.1</version>

<parent>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -37,6 +37,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.26</version>
<scope>compile</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -58,7 +65,7 @@
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
<version>1.5</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.session.SessionAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
Expand All @@ -29,11 +30,13 @@


@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, SessionAutoConfiguration.class})
@ServletComponentScan(basePackages = {"com.webank.ai.fate.board.conf"})
@ComponentScan(basePackages = {"com.webank.ai.fate.*"})
@PropertySource(value = "classpath:application.properties", ignoreResourceNotFound = true)
@Configuration
@EnableScheduling
@EnableFeignClients(basePackages = "com.webank.ai.fate.*")

public class Bootstrap {
public static void main(String[] args) {
try {
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/com/webank/ai/fate/board/conf/WebsocketFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.webank.ai.fate.board.conf;

import com.alibaba.fastjson.JSON;
import com.webank.ai.fate.board.global.ErrorCode;
import com.webank.ai.fate.board.global.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.annotation.Order;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.websocket.server.HandshakeRequest;
import java.io.IOException;

@Slf4j
@Order(1)
@WebFilter(filterName = "websocketFilter", urlPatterns = {"/websocket/progress/*","/log/new/*"})
public class WebsocketFilter implements Filter {

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletResponse resp = (HttpServletResponse) response;
HttpServletRequest req = (HttpServletRequest) request;

HttpSession session = req.getSession(false);
if (session == null) {
resp.getWriter().write(JSON.toJSONString(new ResponseResult<>(ErrorCode.LOGIN_ERROR)));
return ;
}
Object user = session.getAttribute("USER");
if (user == null) {
resp.getWriter().write(JSON.toJSONString(new ResponseResult<>(ErrorCode.LOGIN_ERROR)));
return ;
}

chain.doFilter(request, response);
}

}

0 comments on commit 09ff73f

Please sign in to comment.