广西联通bug解决

This commit is contained in:
Administrator 2023-04-11 18:57:47 +08:00
parent 9802f3e78a
commit 9c8318eb4e
5 changed files with 45 additions and 14 deletions

View File

@ -307,7 +307,7 @@ public class VideoItemServiceImpl extends ServiceImpl<VideoItemMapper, VideoItem
// 如果config type = 1 获取token
Map<String, Object> data = new HashMap<>();
List<EntityMap> videoList = videoItemMapper.selectProjectVideoList(map);
if (videoList.size() > 0) {
if (videoList.size() > 0 && "1".equals(MapUtils.getString(videoList.get(0), "videoType"))) {
String token = YsVideoUtil.getToken(MapUtils.getString(videoList.get(0), "appId"), MapUtils.getString(videoList.get(0), "appSecret"));
for (EntityMap entityMap : videoList) {
entityMap.put("token", token);

View File

@ -1,5 +1,6 @@
package com.zhgd.xmgl.security;
import com.zhgd.xmgl.util.ProfileJudgeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
@ -42,6 +43,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Value("${security.enable}")
private boolean securityEnable;
@Autowired
ProfileJudgeUtil profileJudgeUtil;
@Autowired
public WebSecurityConfig(JwtAuthenticationEntryPoint unauthorizedHandler,
@Qualifier("RestAuthenticationAccessDeniedHandler") AccessDeniedHandler accessDeniedHandler,
@ -66,6 +70,12 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
http.headers().frameOptions().disable();
if (securityEnable) {
if (profileJudgeUtil.isGxlt()) {
http.authorizeRequests()
//请求路径允许访问
.antMatchers("/xmgl/project/getProjectInfoBySn").permitAll();
}
http.authorizeRequests()
//请求路径允许访问
.antMatchers("/xmgl/base/**").permitAll()
@ -229,6 +239,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.and()
// 定制我们自己的 session 策略调整为让 Spring Security 不创建和使用 session
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
//以下这句就可以控制单个用户只能创建一个session也就只能在服务器登录一次
//http.sessionManagement().maximumSessions(1).expiredUrl("/login");

View File

@ -1,5 +1,6 @@
package com.zhgd.xmgl.util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@ -9,6 +10,7 @@ import java.util.stream.Stream;
* 环境判断
*/
@Component
@Slf4j
public class ProfileJudgeUtil {
@Value("${spring.profiles.active}")
private String activeProfile;
@ -67,5 +69,22 @@ public class ProfileJudgeUtil {
return "ylww".equals(activeProfile);
}
/**
* 是否广西联通生产环境
*
* @return
*/
public boolean isGxltProd() {
return "gxlt".equals(activeProfile);
}
/**
* 是否广西联通环境
*
* @return
*/
public boolean isGxlt() {
return Stream.of("gxlt", "gxlt-gsx").anyMatch(s -> s.equals(activeProfile));
}
}

View File

@ -17,8 +17,8 @@ public class SjUnifiedAuthenticationHttpUtil {
@Value("${sj.unifiedAuthentication.login.url:}")
private String sjUnifiedAuthenticationLoginUrl;
@Value("${sj.unifiedAuthentication.login.code.url:}")
private String sjUnifiedAuthenticationLoginCodeUrl;
//@Value("${sj.unifiedAuthentication.login.code.url:}")
//private String sjUnifiedAuthenticationLoginCodeUrl;
/**
* 令牌检验
@ -46,14 +46,14 @@ public class SjUnifiedAuthenticationHttpUtil {
/**
* 获取授权码重定向
*/
public void getCodeRedirect(HttpServletResponse response) throws IOException {
//获取授权码客户端申请授权的URI在浏览器中以GET请求发送到认证服务器
String redirectLoginUrl = sjUnifiedAuthenticationLoginUrl + "/oauth2/authorize?client_id=EuPYxx1mTw-0JIA47wBYww&response_type=code" +
"&redirect_uri=" + sjUnifiedAuthenticationLoginCodeUrl + "&scope=user.read";
log.info("getCode重定向的url{}", sjUnifiedAuthenticationLoginCodeUrl);
// 将data数据进行响应
response.sendRedirect(redirectLoginUrl);
}
//public void getCodeRedirect(HttpServletResponse response) throws IOException {
// //获取授权码客户端申请授权的URI在浏览器中以GET请求发送到认证服务器
// String redirectLoginUrl = sjUnifiedAuthenticationLoginUrl + "/oauth2/authorize?client_id=EuPYxx1mTw-0JIA47wBYww&response_type=code" +
// "&redirect_uri=" + sjUnifiedAuthenticationLoginCodeUrl + "&scope=user.read";
// log.info("getCode重定向的url{}", sjUnifiedAuthenticationLoginCodeUrl);
// // 将data数据进行响应
// response.sendRedirect(redirectLoginUrl);
//}
/**
* 获取令牌

View File

@ -85,9 +85,9 @@ c2_orguser_subscription=true
#\u4E09\u6C5F\u7EDF\u4E00\u767B\u5F55\u5730\u5740
sj.unifiedAuthentication.login.url=http://116.169.63.183:30913
#\u4E09\u6C5F\u7EDF\u4E00\u767B\u5F55\u6210\u529F\u8DF3\u8F6C\u540E\u63A5\u6536code\u7684\u5730\u5740
sj.unifiedAuthentication.login.code.url=http://wbtqry.natappfree.cc/xmgl/sj/unifiedAuthentication/getTokenByCode
#sj.unifiedAuthentication.login.code.url=http://wbtqry.natappfree.cc/xmgl/sj/unifiedAuthentication/getTokenByCode
#\u7EDF\u4E00\u767B\u5F55\u6210\u529F\u540E\u8DF3\u8F6Curl
sj.unifiedAuthentication.success.redirect=http://192.168.34.150:8080/index.html#/login?UID=
sj.unifiedAuthentication.success.redirect=http://192.168.34.226:8080/index.html#/login?UID=
sj.upload.image.url=http://192.168.34.221:11111/image/
sj.upload.image.url=http://192.168.34.221:11111/image/