mirror of
https://github.com/luoye663/e5.git
synced 2024-12-26 03:38:53 +00:00
增加允许跨域
This commit is contained in:
parent
fad520cb97
commit
de9c974bbf
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
/.idea/
|
||||
/target/
|
@ -1,17 +1,14 @@
|
||||
package io.qyi.e5.config.security.filter;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.qyi.e5.bean.result.Result;
|
||||
import io.qyi.e5.bean.result.ResultEnum;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken;
|
||||
import io.qyi.e5.util.ResultUtil;
|
||||
import io.qyi.e5.util.SpringUtil;
|
||||
import io.qyi.e5.util.redis.RedisUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Configurable;
|
||||
import org.springframework.security.core.authority.AuthorityUtils;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
@ -49,6 +46,13 @@ public class LinkTokenAuthenticationFilter extends OncePerRequestFilter {
|
||||
}
|
||||
}
|
||||
System.out.println("--------------Token鉴权---------------");
|
||||
/*设置跨域*/
|
||||
HttpServletResponse response = httpServletResponse;
|
||||
response.setHeader("Access-Control-Allow-Origin","*");
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
response.setHeader("Access-Control-Allow-Methods", "POST, GET, PATCH, DELETE, PUT");
|
||||
response.setHeader("Access-Control-Max-Age", "3600");
|
||||
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||
filterChain.doFilter(httpServletRequest, httpServletResponse);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@ public class LoginAuthenticationFilter extends AbstractAuthenticationProcessingF
|
||||
|
||||
public LoginAuthenticationFilter() {
|
||||
super(new AntPathRequestMatcher("/auth2/receive", "GET"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,13 @@
|
||||
package io.qyi.e5.string;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* @program: e5
|
||||
* @description:
|
||||
@ -9,12 +15,26 @@ import org.junit.jupiter.api.Test;
|
||||
* @create: 2020-03-05 17:09
|
||||
**/
|
||||
public class dome01 {
|
||||
|
||||
@Test
|
||||
public void test01(){
|
||||
public void test01() {
|
||||
String[] s = new String[]{"CompactToken validation", "Access token has expired.", "Access token validation failure"};
|
||||
String msg = "Access token has expired.";
|
||||
|
||||
System.out.println(s[1]);
|
||||
System.out.println(msg.indexOf(s[1]));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
JsonObject jsonObject = new Gson().fromJson("", JsonObject.class);
|
||||
JsonArray data = jsonObject.getAsJsonArray("data");
|
||||
for (JsonElement j : data) {
|
||||
int pid = j.getAsJsonObject().get("pid").getAsInt();
|
||||
}
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JsonObject JsonObject = data.get(i).getAsJsonObject();
|
||||
JsonObject.get("pid").getAsInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user