This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-fence.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d116c0  [SCB-1641]fix auth filter default token type error (#19)
0d116c0 is described below

commit 0d116c031852bae520f4a5a6a00dfb54f1dc6f65
Author: bao liu <[email protected]>
AuthorDate: Thu Dec 5 19:34:07 2019 +0800

    [SCB-1641]fix auth filter default token type error (#19)
---
 .../authentication/edge/AuthenticationFilter.java            |  2 +-
 .../org/apache/servicecomb/authentication/TestEndpoint.java  |  5 +++++
 samples/EdgeService/src/main/resources/ui/js/operation.js    | 12 ++++++++----
 3 files changed, 14 insertions(+), 5 deletions(-)

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 @@ public class AuthenticationFilter implements HttpServerFilter 
{
         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 @@ package org.apache.servicecomb.authentication;
 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 @@ import org.springframework.web.bind.annotation.RequestMapping;
 @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 @@ public class TestEndpoint {
       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 @@ function everyoneSayHello() {
         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 @@ function adminSayHello() {
         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 @@ function guestOrAdminSayHello() {
         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 @@ function guestSayHello() {
         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);

Reply via email to