提交 0f03174c 编写于 作者: N nobodyiam

remove useless authentication codes

上级 2650b3c0
......@@ -23,7 +23,7 @@ public abstract class AbstractControllerTest {
@Autowired
private HttpMessageConverters httpMessageConverters;
RestTemplate restTemplate = new TestRestTemplate("apollo", "");
RestTemplate restTemplate = new TestRestTemplate();
@PostConstruct
private void postConstruct() {
......
......@@ -47,7 +47,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemChangeSets itemSet = new ItemChangeSets();
itemSet.setDataChangeLastModifiedBy("created");
RestTemplate createdTemplate = new TestRestTemplate("created", "");
RestTemplate createdTemplate = new TestRestTemplate();
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3;
......@@ -96,7 +96,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemChangeSets createChangeSet = new ItemChangeSets();
createChangeSet.setDataChangeLastModifiedBy("created");
RestTemplate createdRestTemplate = new TestRestTemplate("created", "");
RestTemplate createdRestTemplate = new TestRestTemplate();
createdRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3;
......@@ -123,7 +123,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemChangeSets updateChangeSet = new ItemChangeSets();
updateChangeSet.setDataChangeLastModifiedBy("updated");
RestTemplate updatedRestTemplate = new TestRestTemplate("updated", "");
RestTemplate updatedRestTemplate = new TestRestTemplate();
updatedRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
int updatedSize = 2;
......@@ -170,7 +170,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemChangeSets createChangeSet = new ItemChangeSets();
createChangeSet.setDataChangeLastModifiedBy("created");
RestTemplate createdTemplate = new TestRestTemplate("created", "");
RestTemplate createdTemplate = new TestRestTemplate();
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
int createdSize = 3;
......@@ -196,7 +196,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemChangeSets deleteChangeSet = new ItemChangeSets();
deleteChangeSet.setDataChangeLastModifiedBy("deleted");
RestTemplate deletedTemplate = new TestRestTemplate("deleted", "");
RestTemplate deletedTemplate = new TestRestTemplate();
deletedTemplate.setMessageConverters(restTemplate.getMessageConverters());
int deletedSize = 1;
......
package com.ctrip.framework.apollo.adminservice.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
......@@ -20,13 +18,4 @@ public class TestWebSecurityConfig extends WebSecurityConfigurerAdapter {
http.headers().frameOptions().disable();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user").password("").roles("USER");
auth.inMemoryAuthentication().withUser("apollo").password("").roles("USER", "ADMIN");
auth.inMemoryAuthentication().withUser("created").password("").roles("TEST");
auth.inMemoryAuthentication().withUser("updated").password("").roles("TEST");
auth.inMemoryAuthentication().withUser("deleted").password("").roles("TEST");
}
}
......@@ -23,6 +23,13 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http.headers().frameOptions().sameOrigin();
}
/**
* Although the authentication below is useless, we may not remove them for backward compatibility.
* Because if we remove them and the old clients(before 0.9.0) still send the authentication
* information, the server will return 401, which should cause big problems.
*
* We may remove the following once we remove spring security from Apollo.
*/
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user").password("").roles("USER").and()
......
package com.ctrip.framework.apollo.util.http;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.URL;
import com.ctrip.framework.apollo.build.ApolloInjector;
import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
import com.ctrip.framework.apollo.exceptions.ApolloConfigStatusCodeException;
import com.ctrip.framework.apollo.util.ConfigUtil;
import com.google.common.base.Function;
import com.google.common.io.BaseEncoding;
import com.google.common.io.CharStreams;
import com.google.gson.Gson;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
/**
......@@ -24,7 +20,6 @@ import java.nio.charset.StandardCharsets;
public class HttpUtil {
private ConfigUtil m_configUtil;
private Gson gson;
private String basicAuth;
/**
* Constructor.
......@@ -32,11 +27,6 @@ public class HttpUtil {
public HttpUtil() {
m_configUtil = ApolloInjector.getInstance(ConfigUtil.class);
gson = new Gson();
try {
basicAuth = "Basic " + BaseEncoding.base64().encode("user:".getBytes("UTF-8"));
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}
}
/**
......@@ -85,7 +75,6 @@ public class HttpUtil {
HttpURLConnection conn = (HttpURLConnection) new URL(httpRequest.getUrl()).openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Authorization", basicAuth);
int connectTimeout = httpRequest.getConnectTimeout();
if (connectTimeout < 0) {
......
package com.ctrip.framework.apollo.configservice.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
......@@ -20,10 +18,4 @@ public class TestWebSecurityConfig extends WebSecurityConfigurerAdapter {
http.headers().frameOptions().disable();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user").password("").roles("USER");
auth.inMemoryAuthentication().withUser("apollo").password("").roles("USER", "ADMIN");
}
}
......@@ -46,7 +46,7 @@ public abstract class AbstractBaseIntegrationTest {
private Gson gson = new Gson();
RestTemplate restTemplate = new TestRestTemplate("user", "");
RestTemplate restTemplate = new TestRestTemplate();
@PostConstruct
private void postConstruct() {
......
......@@ -17,7 +17,7 @@ import javax.annotation.PostConstruct;
@WebIntegrationTest(randomPort = true)
public abstract class AbstractIntegrationTest {
RestTemplate restTemplate = new TestRestTemplate("apollo", "");
RestTemplate restTemplate = new TestRestTemplate();
@PostConstruct
private void postConstruct() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册