[SCB-1641]fix auth filter default token type error (#19)
diff --git a/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationFilter.java b/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationFilter.java
index fa69552..56733c3 100644
--- a/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationFilter.java
+++ b/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationFilter.java
@@ -40,7 +40,7 @@
if (tokens[0].equals(CommonConstants.TOKEN_TYPE_BEARER)) {
invocation.addContext(CommonConstants.CONTEXT_HEADER_AUTHORIZATION, tokens[1]);
invocation.addContext(CommonConstants.CONTEXT_HEADER_AUTHORIZATION_TYPE,
- type == null ? CommonConstants.AUTHORIZATION_TYPE_ID_TOKEN : type);
+ type == null ? CommonConstants.AUTHORIZATION_TYPE_ACCESS_TOKEN : type);
}
}
}
diff --git a/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java b/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
index d51dd54..3ebad16 100644
--- a/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
+++ b/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
@@ -20,6 +20,8 @@
import java.util.List;
import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -27,6 +29,8 @@
@RestSchema(schemaId = "TestEndpoint")
@RequestMapping(path = "/v1/test")
public class TestEndpoint {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestEndpoint.class);
+
@Autowired
private List<TestCase> tests;
@@ -36,6 +40,7 @@
try {
test.run();
} catch (Throwable e) {
+ LOGGER.error("", e);
TestMgr.failed(e.getMessage(), e);
}
});
diff --git a/samples/EdgeService/src/main/resources/ui/js/operation.js b/samples/EdgeService/src/main/resources/ui/js/operation.js
index f911432..3927670 100644
--- a/samples/EdgeService/src/main/resources/ui/js/operation.js
+++ b/samples/EdgeService/src/main/resources/ui/js/operation.js
@@ -20,7 +20,8 @@
type: 'POST',
url: "/api/resource-server/v1/auth/handler/everyoneSayHello?name=Hi",
headers: {
- Authorization: "Bearer " + JSON.parse(window.localStorage.getItem("token")).id_token
+ "Authorization": "Bearer " + JSON.parse(window.localStorage.getItem("token")).id_token,
+ "Authorization-TYPE": "ID_TOKEN"
},
success: function (data) {
console.log(data);
@@ -43,7 +44,8 @@
type: 'POST',
url: "/api/resource-server/v1/auth/handler/adminSayHello?name=Hi",
headers: {
- Authorization: "Bearer " + JSON.parse(window.localStorage.getItem("token")).id_token
+ "Authorization": "Bearer " + JSON.parse(window.localStorage.getItem("token")).id_token,
+ "Authorization-TYPE": "ID_TOKEN"
},
success: function (data) {
console.log(data);
@@ -66,7 +68,8 @@
type: 'POST',
url: "/api/resource-server/v1/auth/handler/guestOrAdminSayHello?name=Hi",
headers: {
- Authorization: "Bearer " + JSON.parse(window.localStorage.getItem("token")).id_token
+ "Authorization": "Bearer " + JSON.parse(window.localStorage.getItem("token")).id_token,
+ "Authorization-TYPE": "ID_TOKEN"
},
success: function (data) {
console.log(data);
@@ -89,7 +92,8 @@
type: 'POST',
url: "/api/resource-server/v1/auth/handler/guestSayHello?name=Hi",
headers: {
- Authorization: "Bearer " + JSON.parse(window.localStorage.getItem("token")).id_token
+ "Authorization": "Bearer " + JSON.parse(window.localStorage.getItem("token")).id_token,
+ "Authorization-TYPE": "ID_TOKEN"
},
success: function (data) {
console.log(data);