|
|
@ -5,6 +5,8 @@ import com.sztzjy.forex.trading_trading.config.Constant;
|
|
|
|
import com.sztzjy.forex.trading_trading.config.exception.UnAuthorizedException;
|
|
|
|
import com.sztzjy.forex.trading_trading.config.exception.UnAuthorizedException;
|
|
|
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
|
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
|
|
import org.springframework.security.core.Authentication;
|
|
|
|
import org.springframework.security.core.Authentication;
|
|
|
|
|
|
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
|
|
|
|
|
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
|
import org.springframework.util.AntPathMatcher;
|
|
|
|
import org.springframework.util.AntPathMatcher;
|
|
|
|
import org.springframework.util.PathMatcher;
|
|
|
|
import org.springframework.util.PathMatcher;
|
|
|
@ -17,6 +19,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
@ -54,7 +57,9 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
|
|
|
throw new UnAuthorizedException("令牌错误: 缺失Bearer..");
|
|
|
|
throw new UnAuthorizedException("令牌错误: 缺失Bearer..");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JwtUser currentUser = TokenProvider.getJWTUser(token);
|
|
|
|
JwtUser currentUser = TokenProvider.getJWTUser(token);
|
|
|
|
|
|
|
|
|
|
|
|
Authentication authentication = new UsernamePasswordAuthenticationToken(currentUser, token == null ? "****" : token, currentUser.getAuthorities());
|
|
|
|
Authentication authentication = new UsernamePasswordAuthenticationToken(currentUser, token == null ? "****" : token, currentUser.getAuthorities());
|
|
|
|
|
|
|
|
|
|
|
|
request.getUserPrincipal();
|
|
|
|
request.getUserPrincipal();
|
|
|
|
SecurityContextHolder.getContext().setAuthentication(authentication);
|
|
|
|
SecurityContextHolder.getContext().setAuthentication(authentication);
|
|
|
|
filterChain.doFilter(request, response);
|
|
|
|
filterChain.doFilter(request, response);
|
|
|
|