cors开启
This commit is contained in:
parent
3d7bb21968
commit
3fe7e97b71
@ -14,6 +14,10 @@
|
||||
max(d.create_date) as create_date
|
||||
from sewage_data d
|
||||
right join sewage_dev sd on d.dev_sn = sd.dev_sn
|
||||
where 1 = 1
|
||||
<if test="devSn != null and devSn != ''">
|
||||
and sd.dev_sn = #{devSn}
|
||||
</if>
|
||||
group by sd.dev_sn
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -31,7 +31,7 @@ public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Se
|
||||
log.info("认证失败:" + authException.getMessage() + "--请求路径:" + request.getRequestURL());
|
||||
response.setStatus(401);
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json; charset=utf-8");
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
PrintWriter printWriter = response.getWriter();
|
||||
JSONObject resParam = new JSONObject();
|
||||
resParam.put("message", authException.getMessage());
|
||||
|
||||
@ -4,6 +4,7 @@ import cn.hutool.core.util.IdUtil;
|
||||
import com.zhgd.exception.CustomException;
|
||||
import com.zhgd.redis.lock.RedisRepository;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
|
||||
import com.zhgd.xmgl.util.EnvironmentUtil;
|
||||
import io.jsonwebtoken.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -32,7 +33,7 @@ public class JwtTokenProvider {
|
||||
private Integer userTokenExpireMinute;
|
||||
@Autowired
|
||||
private RedisRepository redisRepository;
|
||||
private static final String USER_TOKEN_EXPIRE_PREFIX = "USER_TOKEN_EXPIRE:";
|
||||
private final String USER_TOKEN_EXPIRE_PREFIX = "USER_TOKEN_EXPIRE:" + EnvironmentUtil.activeEnvironment + ":";
|
||||
private static ConcurrentHashMap<String, String> userMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Autowired
|
||||
|
||||
@ -246,6 +246,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers(HttpMethod.OPTIONS, "/**").anonymous()
|
||||
.anyRequest().authenticated() // 剩下所有的验证都需要验证
|
||||
.and()
|
||||
//设置跨域, 如果不设置, 即使配置了filter, 也不会生效
|
||||
.cors()
|
||||
.and()
|
||||
// 禁用 Spring Security 自带的跨域处理
|
||||
.csrf().disable()
|
||||
// 授权异常
|
||||
|
||||
@ -12,8 +12,15 @@ import java.util.stream.Stream;
|
||||
@Component
|
||||
@Slf4j
|
||||
public class EnvironmentUtil {
|
||||
/**
|
||||
* 激活的环境
|
||||
*/
|
||||
public static String activeEnvironment;
|
||||
|
||||
@Value("${active.environment.name}")
|
||||
private String activeEnvironment;
|
||||
public void setActiveEnvironment(String activeEnvironment) {
|
||||
EnvironmentUtil.activeEnvironment = activeEnvironment;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否本地开发环境
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user