You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2019/05/10 02:15:38 UTC

[servicecomb-samples] branch master updated (e51b877 -> 5b965a6)

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

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


    from e51b877  增加分布式运维的例子
     new 0991cc9  authentication: initial project commit
     new 3a458c2  authentication: add tokens logic
     new 3a10a7b  authentication: add gateway & resource server logic
     new 5b965a6  add test cases and modify license info

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 authentication/AuthenticationServer/pom.xml        | 164 +++++++++++++++++++++
 .../AuthenticationConfiguration.java               |  63 ++++++++
 .../authentication/AuthenticationServer.java       |  12 +-
 .../service/AuthenticationServiceImpl.java         |  75 ++++++++++
 .../main/resources/META-INF/spring/user.bean.xml   |  24 +++
 .../src/main/resources/log4j2.xml                  |   0
 .../src/main/resources/microservice.yaml           |  10 +-
 authentication/Client/pom.xml                      | 146 ++++++++++++++++++
 .../authentication/AuthenticationTestCase.java     |  78 ++++++++++
 .../authentication/BootEventListener.java          |  41 ++++++
 .../apache/servicecomb/authentication/Client.java  |  12 +-
 .../authentication/GateRestTemplate.java           | 111 ++++++++++++++
 .../authentication/ITUriTemplateHandler.java       |  38 ++---
 .../servicecomb/authentication/TestCase.java       |   8 +-
 .../servicecomb/authentication/TestEndpoint.java   |  32 ++--
 .../apache/servicecomb/authentication/TestMgr.java | 105 +++++++++++++
 .../Client}/src/main/resources/log4j2.xml          |   0
 .../Client}/src/main/resources/microservice.yaml   |  12 +-
 authentication/Gateway/pom.xml                     | 106 +++++++++++++
 .../authentication}/gateway/ApiDispatcher.java     |   2 +-
 .../authentication/gateway/AuthHandler.java        |  27 +++-
 .../gateway/AuthenticationConfiguration.java       |  17 ++-
 .../gateway/AuthenticationEndpoint.java            |  42 +++---
 .../gateway/AuthenticationFilter.java              |  47 ++++++
 .../gateway/CustomVertxRestDispatcher.java         |   8 +-
 .../authentication}/gateway/EdgeSSLCustom.java     |   2 +-
 .../authentication}/gateway/GatewayMain.java       |   2 +-
 .../gateway/InternalAccessHandler.java             |   2 +-
 .../gateway/StaticWebpageDispatcher.java           |   2 +-
 ...servicecomb.common.rest.filter.HttpServerFilter |   4 +-
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |   6 +-
 .../main/resources/META-INF/spring/cse.bean.xml    |   0
 .../src/main/resources/config/cse.handler.xml      |   4 +-
 .../Gateway}/src/main/resources/log4j2.xml         |   0
 .../Gateway}/src/main/resources/microservice.yaml  |  23 ++-
 .../Gateway}/src/main/resources/ui/css/style.css   |   0
 .../src/main/resources/ui/js/jquery-1.11.1.min.js  |   0
 .../Gateway}/src/main/resources/ui/js/login.js     |   0
 .../Gateway}/src/main/resources/ui/js/upload.js    |   0
 .../Gateway}/src/main/resources/ui/login.html      |   0
 .../Gateway}/src/main/resources/ui/upload.html     |   0
 .../authentication/test/PatternTest.java           |  20 ++-
 authentication/README.md                           |  47 ++++++
 authentication/ResourceServer/pom.xml              | 146 ++++++++++++++++++
 .../servicecomb/authentication/ResourceServer.java |  12 +-
 .../resource/AccessConfiguration.java              |  23 ++-
 .../resource/AccessConfigurationManager.java       |  27 ++--
 .../resource/AuthenticationConfiguration.java      |  17 ++-
 .../authentication/resource}/FileEndpoint.java     |  35 ++---
 .../authentication/resource}/FileStoreService.java |   2 +-
 .../resource/HandlerAuthEndpoint.java              |  30 +++-
 .../resource}/LocalFileStoreService.java           |   2 +-
 .../resource/PreMethodAuthEndpoint.java            |  34 ++++-
 .../resource/ResourceAuthHandler.java              |  87 +++++++++++
 .../resources/META-INF/spring/resource.bean.xml    |   6 +-
 .../src/main/resources/config/cse.handler.xml      |   6 +-
 .../ResourceServer}/src/main/resources/log4j2.xml  |   0
 .../src/main/resources/microservice.yaml           |  27 +++-
 .../api/AuthenticationServer}/endpoint/pom.xml     |  10 +-
 .../authentication/api/AuthenticationEndpoint.java |  30 ++--
 .../api/AuthenticationServer}/pom.xml              |   6 +-
 .../api/AuthenticationServer}/service/pom.xml      |   6 +-
 .../authentication/api/AuthenticationService.java  |  21 ++-
 .../servicecomb/authentication/api/Token.java      |  96 ++++++++++++
 .../api/common/endpoint/pom.xml                    |  10 +-
 .../samples/porter/file/api/InspectorEndpoint.java |   0
 .../samples/porter/file/api/LogEndpoint.java       |   0
 .../api/common/pom.xml                             |   6 +-
 .../api/common/service}/pom.xml                    |  30 +++-
 .../servicecomb/authentication/jwt/JWTClaims.java  |  80 ++++++++++
 .../authentication/jwt/JWTClaimsCommon.java        | 100 +++++++++++++
 .../servicecomb/authentication/jwt/JWTHeader.java  |  26 +++-
 .../servicecomb/authentication/jwt/JsonParser.java |  30 ++--
 .../servicecomb/authentication/util/Constants.java |  12 +-
 .../samples/porter/common/api/LogService.java      |   0
 authentication/api/pom.xml                         |  90 +++++++++++
 76 files changed, 2023 insertions(+), 276 deletions(-)
 create mode 100644 authentication/AuthenticationServer/pom.xml
 create mode 100644 authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
 copy porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/FileMain.java => authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServer.java (80%)
 create mode 100644 authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
 create mode 100644 authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
 copy {porter_lightweight/user-service => authentication/AuthenticationServer}/src/main/resources/log4j2.xml (100%)
 copy {dependency_management/spring4 => authentication/AuthenticationServer}/src/main/resources/microservice.yaml (88%)
 create mode 100644 authentication/Client/pom.xml
 create mode 100644 authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
 create mode 100644 authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
 copy porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/FileMain.java => authentication/Client/src/main/java/org/apache/servicecomb/authentication/Client.java (81%)
 create mode 100644 authentication/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java
 copy porter_lightweight/api/user-service/service/src/main/java/org/apache/servicecomb/samples/porter/user/api/SessionInfo.java => authentication/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java (52%)
 copy porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/dao/UserMapper.java => authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java (82%)
 copy porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InternalAccessEndpoint.java => authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java (62%)
 create mode 100644 authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
 copy {porter_lightweight/user-service => authentication/Client}/src/main/resources/log4j2.xml (100%)
 copy {dependency_management/spring4 => authentication/Client}/src/main/resources/microservice.yaml (88%)
 create mode 100644 authentication/Gateway/pom.xml
 copy {porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter => authentication/Gateway/src/main/java/org/apache/servicecomb/authentication}/gateway/ApiDispatcher.java (97%)
 copy porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java => authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java (54%)
 copy porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/InternalAccessServiceImpl.java => authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java (63%)
 copy porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/FileEndpoint.java => authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java (51%)
 create mode 100644 authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
 copy {porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter => authentication/Gateway/src/main/java/org/apache/servicecomb/authentication}/gateway/CustomVertxRestDispatcher.java (98%)
 copy {porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter => authentication/Gateway/src/main/java/org/apache/servicecomb/authentication}/gateway/EdgeSSLCustom.java (95%)
 copy {porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter => authentication/Gateway/src/main/java/org/apache/servicecomb/authentication}/gateway/GatewayMain.java (94%)
 copy {porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter => authentication/Gateway/src/main/java/org/apache/servicecomb/authentication}/gateway/InternalAccessHandler.java (96%)
 copy {porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter => authentication/Gateway/src/main/java/org/apache/servicecomb/authentication}/gateway/StaticWebpageDispatcher.java (97%)
 copy porter_lightweight/gateway-service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher => authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter (79%)
 copy {porter_lightweight/gateway-service => authentication/Gateway}/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher (80%)
 copy {porter_lightweight/gateway-service => authentication/Gateway}/src/main/resources/META-INF/spring/cse.bean.xml (100%)
 copy {porter_lightweight/gateway-service => authentication/Gateway}/src/main/resources/config/cse.handler.xml (87%)
 copy {porter_lightweight/gateway-service => authentication/Gateway}/src/main/resources/log4j2.xml (100%)
 copy {porter_lightweight/gateway-service => authentication/Gateway}/src/main/resources/microservice.yaml (73%)
 copy {porter_lightweight/gateway-service => authentication/Gateway}/src/main/resources/ui/css/style.css (100%)
 copy {porter_lightweight/gateway-service => authentication/Gateway}/src/main/resources/ui/js/jquery-1.11.1.min.js (100%)
 copy {porter_lightweight/gateway-service => authentication/Gateway}/src/main/resources/ui/js/login.js (100%)
 copy {porter_lightweight/gateway-service => authentication/Gateway}/src/main/resources/ui/js/upload.js (100%)
 copy {porter_lightweight/gateway-service => authentication/Gateway}/src/main/resources/ui/login.html (100%)
 copy {porter_lightweight/gateway-service => authentication/Gateway}/src/main/resources/ui/upload.html (100%)
 copy porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/UserMain.java => authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java (59%)
 create mode 100644 authentication/README.md
 create mode 100644 authentication/ResourceServer/pom.xml
 copy porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/FileMain.java => authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServer.java (80%)
 copy dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java => authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java (57%)
 copy porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java => authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java (52%)
 copy porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service/InternalAccessServiceImpl.java => authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java (63%)
 copy {porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api => authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource}/FileEndpoint.java (66%)
 copy {porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service => authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource}/FileStoreService.java (94%)
 copy dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java => authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java (58%)
 copy {porter_lightweight/file-service/src/main/java/org/apache/servicecomb/samples/porter/file/service => authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource}/LocalFileStoreService.java (97%)
 copy dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java => authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java (53%)
 create mode 100644 authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
 copy porter_lightweight/file-service/src/main/resources/META-INF/spring/file.bean.xml => authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml (71%)
 copy {porter_lightweight/gateway-service => authentication/ResourceServer}/src/main/resources/config/cse.handler.xml (80%)
 copy {porter_lightweight/user-service => authentication/ResourceServer}/src/main/resources/log4j2.xml (100%)
 copy {dependency_management/spring4 => authentication/ResourceServer}/src/main/resources/microservice.yaml (70%)
 copy {porter_lightweight/api/common => authentication/api/AuthenticationServer}/endpoint/pom.xml (81%)
 copy porter_lightweight/api/file-service/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InternalAccessEndpoint.java => authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java (57%)
 copy {porter_lightweight/api/common => authentication/api/AuthenticationServer}/pom.xml (88%)
 copy {porter_lightweight/api/common => authentication/api/AuthenticationServer}/service/pom.xml (87%)
 copy dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java => authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java (59%)
 create mode 100644 authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
 copy {porter_lightweight => authentication}/api/common/endpoint/pom.xml (81%)
 copy {porter_lightweight => authentication}/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java (100%)
 copy {porter_lightweight => authentication}/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java (100%)
 copy {porter_lightweight => authentication}/api/common/pom.xml (88%)
 copy {porter_lightweight/api/common/endpoint => authentication/api/common/service}/pom.xml (58%)
 create mode 100644 authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
 create mode 100644 authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java
 copy porter_lightweight/user-service/src/main/java/org/apache/servicecomb/samples/porter/user/UserMain.java => authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java (70%)
 copy porter_lightweight/gateway-service/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java => authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java (57%)
 copy porter_lightweight/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java => authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java (72%)
 copy {porter_lightweight => authentication}/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java (100%)
 create mode 100644 authentication/api/pom.xml


[servicecomb-samples] 04/04: add test cases and modify license info

Posted by li...@apache.org.
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-samples.git

commit 5b965a65c5c132c1a564f13a504235805f1822a5
Author: liubao <ba...@huawei.com>
AuthorDate: Fri May 10 10:10:00 2019 +0800

    add test cases and modify license info
---
 .../AuthenticationConfiguration.java               |  17 ++++
 .../servicecomb/authentication/user/Role.java      |   5 -
 .../servicecomb/authentication/user/User.java      |  11 --
 .../servicecomb/authentication/user/UserStore.java |   5 -
 authentication/Client/pom.xml                      |  18 ++++
 .../authentication/AuthenticationTestCase.java     |  78 +++++++++++++++
 .../authentication/BootEventListener.java          |  41 ++++++++
 .../authentication/GateRestTemplate.java           | 111 +++++++++++++++++++++
 .../authentication/ITUriTemplateHandler.java}      |  36 +++----
 .../servicecomb/authentication/TestCase.java}      |  32 +-----
 .../servicecomb/authentication/TestEndpoint.java   |  48 +++++++++
 .../apache/servicecomb/authentication/TestMgr.java | 105 +++++++++++++++++++
 .../main/resources/META-INF/spring/user.bean.xml   |  56 -----------
 .../src/main/resources/config/SessionMapper.xml    |  57 -----------
 .../src/main/resources/config/UserMapper.xml       |  46 ---------
 .../src/main/resources/config/create_db_user.sql   |  46 ---------
 .../src/main/resources/config/mybatis-config.xml   |  27 -----
 .../Client/src/main/resources/microservice.yaml    |   7 +-
 .../gateway/AuthenticationConfiguration.java       |  17 ++++
 .../gateway/AuthenticationFilter.java              |  17 ++++
 ...servicecomb.common.rest.filter.HttpServerFilter |  17 ++++
 .../Gateway/src/main/resources/microservice.yaml   |   1 +
 .../authentication/test/PatternTest.java           |  17 ++++
 authentication/README.md                           |  35 +++++--
 .../resource/AccessConfiguration.java              |  17 ++++
 .../resource/AccessConfigurationManager.java       |  17 ++++
 .../resource/AuthenticationConfiguration.java      |  17 ++++
 .../resource/HandlerAuthEndpoint.java              |  17 ++++
 .../resource/PreMethodAuthEndpoint.java            |  17 ++++
 .../resource/ResourceAuthHandler.java              |  17 ++++
 .../servicecomb/authentication/jwt/JWTClaims.java  |  17 ++++
 .../authentication/jwt/JWTClaimsCommon.java        |  17 ++++
 .../servicecomb/authentication/jwt/JWTHeader.java  |  17 ++++
 .../servicecomb/authentication/jwt/JsonParser.java |  17 ++++
 .../servicecomb/authentication/util/Constants.java |  17 ++++
 35 files changed, 725 insertions(+), 312 deletions(-)

diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
index 5840fc3..7d9d076 100644
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication;
 
 import java.util.Arrays;
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java
deleted file mode 100644
index 393cd3e..0000000
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.servicecomb.authentication.user;
-
-public interface Role {
-  String getRoleName();
-}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java
deleted file mode 100644
index b0ba017..0000000
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.servicecomb.authentication.user;
-
-import java.util.Collection;
-
-public interface User {
-  Collection<Role> getRoles();
-
-  String getPassword();
-
-  String getUsername();
-}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java
deleted file mode 100644
index 5bd8459..0000000
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.servicecomb.authentication.user;
-
-public interface UserStore {
-  User loadUserByUsername(String userName);
-}
diff --git a/authentication/Client/pom.xml b/authentication/Client/pom.xml
index 60978df..c94ff12 100644
--- a/authentication/Client/pom.xml
+++ b/authentication/Client/pom.xml
@@ -27,6 +27,16 @@
   <dependencyManagement>
     <dependencies>
       <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-server-api-service</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
         <groupId>org.mybatis</groupId>
         <artifactId>mybatis</artifactId>
         <version>3.4.5</version>
@@ -53,6 +63,14 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-endpoint</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-server-api-service</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>solution-basic</artifactId>
     </dependency>
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
new file mode 100644
index 0000000..1bae5c3
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication;
+
+import org.apache.servicecomb.authentication.api.Token;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.stereotype.Component;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.HttpClientErrorException;
+
+@Component
+public class AuthenticationTestCase implements TestCase {
+  @Override
+  public void run() {
+    // get token
+    MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
+    map.add("userName", "admin");
+    map.add("password", "changeMyPassword");
+    HttpHeaders headers = new HttpHeaders();
+    headers.setContentType(MediaType.MULTIPART_FORM_DATA);
+
+    Token token =
+        BootEventListener.gateEndpoint.postForObject("/v1/auth/login",
+            new HttpEntity<>(map, headers),
+            Token.class);
+    TestMgr.check("bearer", token.getToken_type());
+    TestMgr.check(true, token.getAccess_token().length() > 10);
+
+    // get resources
+    headers = new HttpHeaders();
+    headers.add("Authorization", "Bearer " + token.getAccess_token());
+    headers.setContentType(MediaType.APPLICATION_JSON);
+    String name;
+    name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/everyoneSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/adminSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/guestOrAdminSayHello?name=Hi",
+        new HttpEntity<>(headers),
+        String.class);
+    TestMgr.check("Hi", name);
+
+    name = null;
+    try {
+      name = BootEventListener.resouceServerHandlerAuthEndpoint.postForObject("/guestSayHello?name=Hi",
+          new HttpEntity<>(headers),
+          String.class);
+    } catch (HttpClientErrorException e) {
+      TestMgr.check(403, e.getStatusCode().value());
+    }
+    TestMgr.check(null, name);
+  }
+
+}
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
new file mode 100644
index 0000000..2af0a55
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication;
+
+import org.apache.servicecomb.core.BootListener;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BootEventListener implements BootListener {
+  public static GateRestTemplate authenticationServerAuthenticationEndpoint;
+  public static GateRestTemplate gateEndpoint;
+  public static GateRestTemplate resouceServerHandlerAuthEndpoint;
+  @Override
+  public void onBootEvent(BootEvent event) {
+    if (EventType.AFTER_REGISTRY.equals(event.getEventType())) {
+      authenticationServerAuthenticationEndpoint =
+          GateRestTemplate.createEdgeRestTemplate("gateway", "authentication-server", "AuthenticationEndpoint").init();
+      gateEndpoint =
+          GateRestTemplate.createEdgeRestTemplate("gateway", null, null).init();
+      resouceServerHandlerAuthEndpoint =
+          GateRestTemplate.createEdgeRestTemplate("gateway", "resource-server", "HandlerAuthEndpoint").init();
+    }
+
+  }
+
+}
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java
new file mode 100644
index 0000000..7a6709f
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.authentication;
+
+import java.util.Arrays;
+
+import org.apache.servicecomb.core.definition.MicroserviceVersionMeta;
+import org.apache.servicecomb.core.definition.SchemaMeta;
+import org.apache.servicecomb.foundation.common.net.URIEndpointObject;
+import org.apache.servicecomb.serviceregistry.RegistryUtils;
+import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
+import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersionRule;
+import org.apache.servicecomb.serviceregistry.definition.DefinitionConst;
+import org.springframework.http.converter.FormHttpMessageConverter;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.web.client.RestTemplate;
+
+public class GateRestTemplate extends RestTemplate {
+  private final String gateName;
+
+  private final String schemaId;
+
+  private final String producerName;
+
+  private String urlPrefix;
+
+  public static GateRestTemplate createEdgeRestTemplate(String gateName, String producerName, String schemaId) {
+    return new GateRestTemplate(gateName, producerName, schemaId);
+  }
+
+
+  public GateRestTemplate(String gateName, String producerName, String schemaId) {
+    this.gateName = gateName;
+    this.producerName = producerName;
+    this.schemaId = schemaId;
+  }
+
+  public GateRestTemplate init() {
+    urlPrefix = getUrlPrefix(gateName, producerName, schemaId);
+
+    setUriTemplateHandler(new ITUriTemplateHandler(urlPrefix));
+
+    setMessageConverters(Arrays.asList(
+        new MappingJackson2HttpMessageConverter(),
+        new StringHttpMessageConverter(),
+        new FormHttpMessageConverter()));
+
+    return this;
+  }
+
+  public String getUrlPrefix() {
+    return urlPrefix;
+  }
+
+  private String getUrlPrefix(String gateName, String producerName, String schemaId) {
+    MicroserviceVersionRule microserviceVersionRule = RegistryUtils.getServiceRegistry()
+        .getAppManager()
+        .getOrCreateMicroserviceVersionRule(RegistryUtils.getAppId(),
+            gateName,
+            DefinitionConst.VERSION_RULE_ALL);
+    MicroserviceInstance microserviceInstance = microserviceVersionRule.getInstances()
+        .values()
+        .stream()
+        .findFirst()
+        .get();
+    URIEndpointObject edgeAddress = new URIEndpointObject(microserviceInstance.getEndpoints().get(0));
+
+    String urlSchema = "http";
+    if (edgeAddress.isSslEnabled()) {
+      urlSchema = "https";
+    }
+
+    if(producerName == null) {
+      return String
+          .format("%s://%s:%d",
+              urlSchema,
+              edgeAddress.getHostOrIp(),
+              edgeAddress.getPort());
+    }
+    
+    microserviceVersionRule = RegistryUtils.getServiceRegistry()
+        .getAppManager()
+        .getOrCreateMicroserviceVersionRule(RegistryUtils.getAppId(),
+            producerName,
+            DefinitionConst.VERSION_RULE_ALL);
+    MicroserviceVersionMeta microserviceVersionMeta = microserviceVersionRule.getLatestMicroserviceVersion();
+    SchemaMeta schemaMeta = microserviceVersionMeta.getMicroserviceMeta().ensureFindSchemaMeta(schemaId);
+    return String
+        .format("%s://%s:%d/api/%s%s",
+            urlSchema,
+            edgeAddress.getHostOrIp(),
+            edgeAddress.getPort(),
+            producerName,
+            schemaMeta.getSwagger().getBasePath());
+  }
+}
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
similarity index 52%
copy from authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
copy to authentication/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
index 54c2175..8308599 100644
--- a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
@@ -14,35 +14,31 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.servicecomb.authentication;
 
-package org.apache.servicecomb.authentication.api;
+import java.net.URI;
+import java.util.Map;
 
-/**
- * 
- * After successfully login, tokens are created. </br>
- * <B>Access Token:</B> used to access resources.</br>
- * <B>Refresh Token:</B> used to acquire new tokens.</br>
- *
- */
-public class Tokens {
-  private String accessToken;
+import org.springframework.web.util.DefaultUriTemplateHandler;
 
-  private String refreshToken;
+public class ITUriTemplateHandler extends DefaultUriTemplateHandler {
+  private String urlPrefix;
 
-  public String getAccessToken() {
-    return accessToken;
+  public ITUriTemplateHandler(String urlPrefix) {
+    this.urlPrefix = urlPrefix;
   }
 
-  public void setAccessToken(String accessToken) {
-    this.accessToken = accessToken;
+  @Override
+  protected URI expandInternal(String uriTemplate, Object... uriVariables) {
+    return super.expandInternal(changeUrl(uriTemplate), uriVariables);
   }
 
-  public String getRefreshToken() {
-    return refreshToken;
+  @Override
+  protected URI expandInternal(String uriTemplate, Map<String, ?> uriVariables) {
+    return super.expandInternal(changeUrl(uriTemplate), uriVariables);
   }
 
-  public void setRefreshToken(String refreshToken) {
-    this.refreshToken = refreshToken;
+  private String changeUrl(String uriTemplate) {
+    return urlPrefix + uriTemplate;
   }
-
 }
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
similarity index 55%
rename from authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
rename to authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
index 54c2175..1c511d2 100644
--- a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
@@ -15,34 +15,8 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
-
-/**
- * 
- * After successfully login, tokens are created. </br>
- * <B>Access Token:</B> used to access resources.</br>
- * <B>Refresh Token:</B> used to acquire new tokens.</br>
- *
- */
-public class Tokens {
-  private String accessToken;
-
-  private String refreshToken;
-
-  public String getAccessToken() {
-    return accessToken;
-  }
-
-  public void setAccessToken(String accessToken) {
-    this.accessToken = accessToken;
-  }
-
-  public String getRefreshToken() {
-    return refreshToken;
-  }
-
-  public void setRefreshToken(String refreshToken) {
-    this.refreshToken = refreshToken;
-  }
+package org.apache.servicecomb.authentication;
 
+public interface TestCase {
+  void run();
 }
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
new file mode 100644
index 0000000..04c3927
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication;
+
+import java.util.List;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@RestSchema(schemaId = "TestEndpoint")
+@RequestMapping(path = "/v1/test")
+public class TestEndpoint {
+  @Autowired
+  private List<TestCase> tests;
+  
+  @GetMapping(path = "/start")
+  public String start() {
+    tests.forEach(test -> test.run());
+    
+    List<Throwable> errors = TestMgr.errors();
+    if (errors.isEmpty()) {
+      return "success";
+    } else {
+      StringBuilder sb = new StringBuilder();
+      sb.append("Failed count : " + errors.size());
+      sb.append("\n");
+      errors.forEach(t -> sb.append(t.getMessage() + "\n"));
+      return sb.toString();
+    }
+  }
+}
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
new file mode 100644
index 0000000..6b53045
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.StringUtils;
+
+public class TestMgr {
+  private static final Logger LOGGER = LoggerFactory.getLogger(TestMgr.class);
+
+  private static final List<Throwable> errorList = new ArrayList<>();
+
+  private static String msg = "";
+
+  public static void setMsg(String msg) {
+    TestMgr.msg = msg;
+  }
+
+  public static void setMsg(String microserviceName, String transport) {
+    TestMgr.msg = String.format("microservice=%s, transport=%s", microserviceName, transport);
+  }
+
+  public static void check(Object expect, Object real) {
+    check(expect, real, null);
+  }
+
+  public static void check(Object expect, Object real, Throwable error) {
+    if (expect == real) {
+      return;
+    }
+
+    String strExpect = String.valueOf(expect);
+    String strReal = String.valueOf(real);
+
+    if (!strExpect.equals(strReal)) {
+      Error newError = new Error(msg + " | Expect " + strExpect + ", but " + strReal);
+      if (error != null) {
+        newError.setStackTrace(error.getStackTrace());
+      }
+      errorList.add(newError);
+    }
+  }
+
+  public static void checkNotEmpty(String real) {
+    if (StringUtils.isEmpty(real)) {
+      errorList.add(new Error(msg + " | unexpected null result, method is " + getCaller()));
+    }
+  }
+
+  public static void failed(String desc, Throwable e) {
+    Error error = new Error(msg + " | " + desc + ", method is " + getCaller());
+    if (e != null) {
+      error.setStackTrace(error.getStackTrace());
+    }
+    errorList.add(error);
+  }
+
+  public static boolean isSuccess() {
+    return errorList.isEmpty();
+  }
+
+  public static void summary() {
+    if (errorList.isEmpty()) {
+      LOGGER.info("............. test finished ............");
+      return;
+    }
+
+    LOGGER.info("............. test not finished ............");
+    for (Throwable e : errorList) {
+      LOGGER.info("", e);
+    }
+  }
+
+  public static List<Throwable> errors() {
+    return errorList;
+  }
+
+  private static String getCaller() {
+    StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+    if (stackTrace.length < 3) {
+      return null;
+    }
+    StackTraceElement stackTraceElement = stackTrace[3];
+    return stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName();
+  }
+}
diff --git a/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml b/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml
deleted file mode 100644
index 661608f..0000000
--- a/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-    xmlns:util="http://www.springframework.org/schema/util"
-    xmlns:context="http://www.springframework.org/schema/context"
-    xmlns:tx="http://www.springframework.org/schema/tx"
-    xsi:schemaLocation="
-		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
-        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
-		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
-  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
-    init-method="init"/>
-    
-    <bean id="dataSource"
-        class="org.apache.commons.dbcp2.BasicDataSource"
-        destroy-method="close">
-        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
-        <property name="url"
-            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
-        <property name="username" value="${db.username:root}" />
-        <property name="password" value="${db.password:}" />
-    </bean>
-
-    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
-        <property name="dataSource" ref="dataSource" />
-        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
-    </bean>
-
-    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
-    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
-</beans>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/SessionMapper.xml b/authentication/Client/src/main/resources/config/SessionMapper.xml
deleted file mode 100644
index 989e786..0000000
--- a/authentication/Client/src/main/resources/config/SessionMapper.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
-    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
-        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
-    </sql>
-
-    <sql id="all_column_auto">
-        SESSION_ID, USER_NAME, ROLE_NAME
-    </sql>
-
-    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        insert into T_SESSION (
-        <include refid="all_column_auto" />
-        )
-        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
-        #{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getSessioinInfo" parameterType="java.lang.String"
-        resultMap="sessionInfo">
-        select
-        <include refid="all_column" />
-        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
-    </select>
-    
-    <update id="updateSessionInfo" parameterType="java.lang.String">
-        update T_SESSION
-        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
-    </update>
-</mapper>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/UserMapper.xml b/authentication/Client/src/main/resources/config/UserMapper.xml
deleted file mode 100644
index c02e60d..0000000
--- a/authentication/Client/src/main/resources/config/UserMapper.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
-    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, USER_NAME, PASSWORD, ROLE_NAME
-    </sql>
-
-    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        insert into T_USER (
-        <include refid="all_column" />
-        )
-        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
-        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getUserInfo" parameterType="java.lang.String"
-        resultMap="userInfo">
-        select
-        <include refid="all_column" />
-        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
-    </select>
-</mapper>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/create_db_user.sql b/authentication/Client/src/main/resources/config/create_db_user.sql
deleted file mode 100644
index a07c5d9..0000000
--- a/authentication/Client/src/main/resources/config/create_db_user.sql
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE DATABASE IF NOT EXISTS porter_user_db;
-
-USE porter_user_db;
-
-DROP TABLE IF EXISTS T_USER;
-
-CREATE TABLE `T_USER` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  PRIMARY KEY (`ID`)
-);
-
-#### password is encrypted for test
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
-
-DROP TABLE IF EXISTS T_SESSION;
-
-CREATE TABLE `T_SESSION` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
-  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
-  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
-  PRIMARY KEY (`ID`)
-);
diff --git a/authentication/Client/src/main/resources/config/mybatis-config.xml b/authentication/Client/src/main/resources/config/mybatis-config.xml
deleted file mode 100644
index 894caac..0000000
--- a/authentication/Client/src/main/resources/config/mybatis-config.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE configuration
-  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
-  "http://mybatis.org/dtd/mybatis-3-config.dtd">
-<configuration>
-    <mappers>
-        <mapper resource="config/UserMapper.xml"/>
-        <mapper resource="config/SessionMapper.xml"/>
-    </mappers>
-</configuration>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/microservice.yaml b/authentication/Client/src/main/resources/microservice.yaml
index 411b4c6..f19ca7b 100644
--- a/authentication/Client/src/main/resources/microservice.yaml
+++ b/authentication/Client/src/main/resources/microservice.yaml
@@ -22,8 +22,9 @@ servicecomb-config-order: 100
 APPLICATION_ID: authentication-application
 service_description:
   version: 0.0.1
-  name: authentication-server
-
+  name: authentication-client
+  environment: development
+  
 servicecomb:
   service:
     registry:
@@ -32,4 +33,4 @@ servicecomb:
         watch: false
 
   rest:
-    address: 0.0.0.0:9092
+    address: 0.0.0.0:9093
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
index b188402..87837eb 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.gateway;
 
 import org.springframework.context.annotation.Bean;
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
index a6817bf..bc270b8 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.gateway;
 
 import org.apache.servicecomb.authentication.util.Constants;
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
index 57adadd..662c971 100644
--- a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
+++ b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
@@ -1 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
 org.apache.servicecomb.authentication.gateway.AuthenticationFilter
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/microservice.yaml b/authentication/Gateway/src/main/resources/microservice.yaml
index 8d926ee..2eda242 100644
--- a/authentication/Gateway/src/main/resources/microservice.yaml
+++ b/authentication/Gateway/src/main/resources/microservice.yaml
@@ -41,6 +41,7 @@ servicecomb:
         default: internalAccess,auth,qps-flowcontrol-consumer,loadbalance
         service:
           authentication-server: internalAccess,qps-flowcontrol-consumer,loadbalance
+          authentication-client: internalAccess,qps-flowcontrol-consumer,loadbalance
 
   uploads:
     directory: tmp_for_upload_gateway
diff --git a/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java b/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
index bb737ba..e4b2151 100644
--- a/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
+++ b/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.test;
 
 import java.util.regex.Pattern;
diff --git a/authentication/README.md b/authentication/README.md
index 48798cd..3cd4217 100644
--- a/authentication/README.md
+++ b/authentication/README.md
@@ -2,6 +2,20 @@
 
 项目的目标是提供一个商业可用的鉴权实现,对于项目代码实现的问题可以提交issue,本项目也接纳PR,共同完善。
 
+
+
+## 实现说明
+
+* 用户管理
+用户管理采用了org.springframework.security.core.userdetails的模型,包括:
+  1. UserDetailsService:加载用户信息。
+  2. UserDetails:用户信息。
+  3. GrantedAuthority:角色信息。
+  4. PasswordEncoder:用户密码加密和匹配。
+  
+  
+## 项目结构介绍
+
 * AuthenticationServer
 
 认证鉴权服务。提供用户管理、角色管理。并提供登录认证、权限查询等接口。鉴权服务及相关API是核心交付件,也是能够被重用的部分。开发者可以基于这个项目开发认证鉴权服务。
@@ -15,12 +29,19 @@ Client模拟的是使用使用者。一方面演示客户端如何获取Token,
 * ResourceServer
 ResourceServer模拟的是业务服务。一方面演示业务服务如何进行权限配置,本项目也是自动化测试的组成部分。
 
+* Api
+认证鉴权提取的公共功能,作为复用单元。目前项目处于初始阶段,很多复用代码分散在其他项目中。
+
+
+* 测试介绍
+
+本项目实现了微服务架构的自动化测试。启动AuthenticationServer、Gateway、Client、ResourceServer后,可以提供
+
+```
+http://localhost:9093/v1/test/start
+```
+触发测试用例的执行。 所有的测试用例放到Client微服务里面, 这个微服务实现了简单的测试框架帮助书写测试用例,对测试结果进行检查等功能。 
+
+测试项目同时展示了这个项目的功能,比如: AuthenticationTestCase 的测试逻辑展示了基本的认证功能,从登陆,到接口的权限检查。 
 
-## 实现说明
 
-* 用户管理
-用户管理采用了org.springframework.security.core.userdetails的模型,包括:
-  1. UserDetailsService:加载用户信息。
-  2. UserDetails:用户信息。
-  3. GrantedAuthority:角色信息。
-  4. PasswordEncoder:用户密码加密和匹配。
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
index 136a11a..8167612 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.resource;
 
 import org.apache.servicecomb.config.inject.InjectProperties;
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
index c4cbd1e..c6ea891 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.resource;
 
 import java.util.Map;
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
index 847550f..0e58c30 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.resource;
 
 import org.springframework.context.annotation.Bean;
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
index 32256ad..347db46 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.resource;
 
 import org.apache.servicecomb.provider.rest.common.RestSchema;
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
index eea0968..e07745b 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.resource;
 
 import org.apache.servicecomb.provider.rest.common.RestSchema;
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
index fdfb3ad..800e52d 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.resource;
 
 import java.util.Set;
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
index a5db2c2..c62affc 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.jwt;
 
 import java.util.HashMap;
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java
index 3b71a5c..54e26a5 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.jwt;
 
 public class JWTClaimsCommon {
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java
index b4b1ae7..2cc797c 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.jwt;
 
 public class JWTHeader {
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java
index 37e54d7..2a4bcd1 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.jwt;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java
index a7427fa..96333aa 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.servicecomb.authentication.util;
 
 public final class Constants {


[servicecomb-samples] 02/04: authentication: add tokens logic

Posted by li...@apache.org.
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-samples.git

commit 3a458c2f13a88491b29f1f2794d495f84965a283
Author: liubao <ba...@huawei.com>
AuthorDate: Wed May 8 17:49:16 2019 +0800

    authentication: add tokens logic
---
 authentication/AuthenticationServer/pom.xml        |  9 +++
 .../AuthenticationConfiguration.java               | 28 ++++++++
 .../service/AuthenticationServiceImpl.java         | 45 ++++++++----
 .../servicecomb/authentication/user/Role.java      |  5 ++
 .../servicecomb/authentication/user/User.java      | 11 +++
 .../servicecomb/authentication/user/UserStore.java |  5 ++
 .../servicecomb/authentication/api/Token.java      | 76 +++++++++++++++++---
 .../servicecomb/authentication/jwt/JWTClaims.java  | 45 ++++++++++++
 .../authentication/jwt/JWTClaimsCommon.java        | 83 ++++++++++++++++++++++
 .../servicecomb/authentication/jwt/JWTHeader.java  | 25 +++++++
 .../servicecomb/authentication/jwt/JsonParser.java | 23 ++++++
 11 files changed, 330 insertions(+), 25 deletions(-)

diff --git a/authentication/AuthenticationServer/pom.xml b/authentication/AuthenticationServer/pom.xml
index 0c7a295..baaac03 100644
--- a/authentication/AuthenticationServer/pom.xml
+++ b/authentication/AuthenticationServer/pom.xml
@@ -47,6 +47,11 @@
         <version>0.0.1-SNAPSHOT</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.servicecomb</groupId>
         <artifactId>java-chassis-dependencies</artifactId>
         <version>1.2.0</version>
@@ -77,6 +82,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-endpoint</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
       <artifactId>authentication-server-api-endpoint</artifactId>
     </dependency>
     <dependency>
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
new file mode 100644
index 0000000..77a6342
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
@@ -0,0 +1,28 @@
+package org.apache.servicecomb.authentication;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.crypto.password.PasswordEncoder;
+
+@Configuration
+public class AuthenticationConfiguration {
+  @Bean(name = "authPasswordEncoder")
+  private PasswordEncoder authPasswordEncoder() {
+    return new PasswordEncoder() {
+
+      @Override
+      public String encode(CharSequence rawPassword) {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      @Override
+      public boolean matches(CharSequence rawPassword, String encodedPassword) {
+        // TODO Auto-generated method stub
+        return false;
+      }
+      
+    };
+  }
+  
+}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
index be46f5c..a6e856a 100644
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
@@ -19,34 +19,49 @@ package org.apache.servicecomb.authentication.service;
 
 import org.apache.servicecomb.authentication.api.AuthenticationService;
 import org.apache.servicecomb.authentication.api.Token;
+import org.apache.servicecomb.authentication.jwt.JWTClaims;
+import org.apache.servicecomb.authentication.jwt.JsonParser;
+import org.apache.servicecomb.authentication.user.User;
+import org.apache.servicecomb.authentication.user.UserStore;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.jwt.Jwt;
+import org.springframework.security.jwt.JwtHelper;
+import org.springframework.security.jwt.crypto.sign.Signer;
 import org.springframework.stereotype.Service;
 
 @Service
 public class AuthenticationServiceImpl implements AuthenticationService {
   @Autowired
-  @Qualifier("userDetailsService")
-  private UserDetailsService userDetailsService;
-  
+  @Qualifier("authUserStore")
+  private UserStore userStore;
+
   @Autowired
-  @Qualifier("passwordEncoder")
+  @Qualifier("authPasswordEncoder")
   private PasswordEncoder passwordEncoder;
 
+  @Autowired
+  @Qualifier("authSigner")
+  private Signer signer;
+
   @Override
   public Token login(String userName, String password) {
-    UserDetails userDetails;
-    try {
-      userDetails = userDetailsService.loadUserByUsername(userName);
-    } catch (UsernameNotFoundException e) {
-      return null;
-    }
-    if(passwordEncoder.matches(password, userDetails.getPassword())) {
-      return null;
+    User user = userStore.loadUserByUsername(userName);
+    if (passwordEncoder.matches(password, user.getPassword())) {
+      JWTClaims claims = new JWTClaims();
+      if (user.getRoles() != null) {
+        user.getRoles().forEach(role -> claims.addRole(role.getRoleName()));
+      }
+      claims.setScope("read");
+      String content = JsonParser.unparse(claims);
+      Jwt accessToken = JwtHelper.encode(content, signer);
+
+      Token token = new Token();
+      token.setExpires_in(10 * 60);
+      token.setToken_type("bearer");
+      token.setAccess_token(accessToken.getEncoded());
+      return token;
     } else {
       return null;
     }
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java
new file mode 100644
index 0000000..393cd3e
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/Role.java
@@ -0,0 +1,5 @@
+package org.apache.servicecomb.authentication.user;
+
+public interface Role {
+  String getRoleName();
+}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java
new file mode 100644
index 0000000..b0ba017
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/User.java
@@ -0,0 +1,11 @@
+package org.apache.servicecomb.authentication.user;
+
+import java.util.Collection;
+
+public interface User {
+  Collection<Role> getRoles();
+
+  String getPassword();
+
+  String getUsername();
+}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java
new file mode 100644
index 0000000..5bd8459
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/user/UserStore.java
@@ -0,0 +1,5 @@
+package org.apache.servicecomb.authentication.user;
+
+public interface UserStore {
+  User loadUserByUsername(String userName);
+}
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
index 732fe22..94ce237 100644
--- a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
+++ b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
@@ -17,24 +17,80 @@
 
 package org.apache.servicecomb.authentication.api;
 
+import java.util.Map;
+import java.util.Set;
+
 public class Token {
-  private String accessToken;
+  // Naming conventions https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00#section-3.1
+  private String token_type;
+
+  private String access_token;
+
+  private String refresh_token;
+
+  private int expires_in;
+
+  private Set<String> scope;
+
+  // JWT id
+  private String jti;
+
+  private Map<String, Object> additionalInformation;
 
-  private String refreshToken;
+  public String getToken_type() {
+    return token_type;
+  }
+
+  public void setToken_type(String token_type) {
+    this.token_type = token_type;
+  }
+
+  public String getAccess_token() {
+    return access_token;
+  }
+
+  public void setAccess_token(String access_token) {
+    this.access_token = access_token;
+  }
 
-  public String getAccessToken() {
-    return accessToken;
+  public String getRefresh_token() {
+    return refresh_token;
   }
 
-  public void setAccessToken(String accessToken) {
-    this.accessToken = accessToken;
+  public void setRefresh_token(String refresh_token) {
+    this.refresh_token = refresh_token;
   }
 
-  public String getRefreshToken() {
-    return refreshToken;
+  public int getExpires_in() {
+    return expires_in;
   }
 
-  public void setRefreshToken(String refreshToken) {
-    this.refreshToken = refreshToken;
+  public void setExpires_in(int expires_in) {
+    this.expires_in = expires_in;
   }
+
+  public Set<String> getScope() {
+    return scope;
+  }
+
+  public void setScope(Set<String> scope) {
+    this.scope = scope;
+  }
+
+  public String getJti() {
+    return jti;
+  }
+
+  public void setJti(String jti) {
+    this.jti = jti;
+  }
+
+  public Map<String, Object> getAdditionalInformation() {
+    return additionalInformation;
+  }
+
+  public void setAdditionalInformation(Map<String, Object> additionalInformation) {
+    this.additionalInformation = additionalInformation;
+  }
+
 }
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
new file mode 100644
index 0000000..569b4da
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
@@ -0,0 +1,45 @@
+package org.apache.servicecomb.authentication.jwt;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+public class JWTClaims extends JWTClaimsCommon {
+  protected Set<String> roles = Collections.emptySet();
+
+  protected Map<String, Object> additionalInformation = Collections.emptyMap();
+
+  /**
+   * The scope of the access token as described by <a
+   * href="http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-3.3">Section 3.3</a>
+   */
+  protected String scope;
+
+  public Set<String> getRoles() {
+    return roles;
+  }
+
+  public void setRoles(Set<String> roles) {
+    this.roles = roles;
+  }
+
+  public Map<String, Object> getAdditionalInformation() {
+    return additionalInformation;
+  }
+
+  public void setAdditionalInformation(Map<String, Object> additionalInformation) {
+    this.additionalInformation = additionalInformation;
+  }
+
+  public String getScope() {
+    return scope;
+  }
+
+  public void setScope(String scope) {
+    this.scope = scope;
+  }
+
+  public void addRole(String role) {
+    this.roles.add(role);
+  }
+}
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java
new file mode 100644
index 0000000..3b71a5c
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaimsCommon.java
@@ -0,0 +1,83 @@
+package org.apache.servicecomb.authentication.jwt;
+
+public class JWTClaimsCommon {
+  // see: https://tools.ietf.org/html/rfc7519
+  // (Issuer) Claim
+  protected String iss;
+
+  // (Subject) Claim
+  protected String sub;
+
+  // (Audience) Claim
+  protected String aud;
+
+  // (Expiration Time) Claim
+  protected long exp;
+
+  // (Not Before) Claim
+  protected long nbf;
+
+  // (Issued At) Claim
+  protected long iat;
+
+  // (JWT ID) Claim
+  protected String jti;
+
+  public String getIss() {
+    return iss;
+  }
+
+  public void setIss(String iss) {
+    this.iss = iss;
+  }
+
+  public String getSub() {
+    return sub;
+  }
+
+  public void setSub(String sub) {
+    this.sub = sub;
+  }
+
+  public String getAud() {
+    return aud;
+  }
+
+  public void setAud(String aud) {
+    this.aud = aud;
+  }
+
+  public long getExp() {
+    return exp;
+  }
+
+  public void setExp(long exp) {
+    this.exp = exp;
+  }
+
+  public long getNbf() {
+    return nbf;
+  }
+
+  public void setNbf(long nbf) {
+    this.nbf = nbf;
+  }
+
+  public long getIat() {
+    return iat;
+  }
+
+  public void setIat(long iat) {
+    this.iat = iat;
+  }
+
+  public String getJti() {
+    return jti;
+  }
+
+  public void setJti(String jti) {
+    this.jti = jti;
+  }
+
+
+}
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java
new file mode 100644
index 0000000..b4b1ae7
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTHeader.java
@@ -0,0 +1,25 @@
+package org.apache.servicecomb.authentication.jwt;
+
+public class JWTHeader {
+  private String typ;
+
+  private String alg;
+
+  public String getTyp() {
+    return typ;
+  }
+
+  public void setTyp(String typ) {
+    this.typ = typ;
+  }
+
+  public String getAlg() {
+    return alg;
+  }
+
+  public void setAlg(String alg) {
+    this.alg = alg;
+  }
+
+
+}
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java
new file mode 100644
index 0000000..37e54d7
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JsonParser.java
@@ -0,0 +1,23 @@
+package org.apache.servicecomb.authentication.jwt;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class JsonParser {
+  private static final ObjectMapper MAPPER = new ObjectMapper();
+
+  public static <T> T parse(String json, Class<T> clazz) {
+    try {
+      return MAPPER.readValue(json, clazz);
+    } catch (Exception e) {
+      throw new IllegalArgumentException("Cannot parse json", e);
+    }
+  }
+
+  public static <T> String unparse(T obj) {
+    try {
+      return MAPPER.writeValueAsString(obj);
+    } catch (Exception e) {
+      throw new IllegalArgumentException("Cannot unparse json", e);
+    }
+  }
+}


[servicecomb-samples] 03/04: authentication: add gateway & resource server logic

Posted by li...@apache.org.
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-samples.git

commit 3a10a7b7503a3e73e5f292f0c447494bc27b3c41
Author: liubao <ba...@huawei.com>
AuthorDate: Thu May 9 19:15:26 2019 +0800

    authentication: add gateway & resource server logic
---
 .../AuthenticationConfiguration.java               | 48 ++++++++++-----
 .../service/AuthenticationServiceImpl.java         | 18 +++---
 .../main/resources/META-INF/spring/user.bean.xml   | 64 +++++---------------
 .../src/main/resources/config/SessionMapper.xml    | 57 ------------------
 .../src/main/resources/config/UserMapper.xml       | 46 --------------
 .../src/main/resources/config/create_db_user.sql   | 46 --------------
 .../src/main/resources/microservice.yaml           |  1 +
 authentication/Gateway/pom.xml                     | 50 +++++++++++-----
 .../gateway/ApiDispatcher.java                     |  2 +-
 .../gateway/AuthHandler.java                       | 21 ++++++-
 .../gateway/AuthenticationConfiguration.java       | 14 +++++
 .../gateway}/AuthenticationEndpoint.java           | 13 ++--
 .../gateway/AuthenticationFilter.java              | 30 ++++++++++
 .../gateway/CustomVertxRestDispatcher.java         |  6 +-
 .../gateway/EdgeSSLCustom.java                     |  2 +-
 .../gateway/GatewayMain.java                       |  2 +-
 .../gateway/InternalAccessHandler.java             |  2 +-
 .../gateway/StaticWebpageDispatcher.java           |  2 +-
 ...servicecomb.common.rest.filter.HttpServerFilter |  1 +
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |  6 +-
 .../src/main/resources/config/cse.handler.xml      |  4 +-
 .../Gateway/src/main/resources/microservice.yaml   |  3 +
 .../authentication/test/PatternTest.java           | 19 ++++++
 authentication/ResourceServer/pom.xml              | 18 ++++++
 .../resource/AccessConfiguration.java              | 20 +++++++
 .../resource/AccessConfigurationManager.java       | 19 ++++++
 .../resource/AuthenticationConfiguration.java      | 14 +++++
 .../resource/HandlerAuthEndpoint.java              | 29 +++++++++
 .../resource/PreMethodAuthEndpoint.java            | 33 ++++++++++
 .../resource/ResourceAuthHandler.java              | 70 ++++++++++++++++++++++
 .../spring/{user.bean.xml => resource.bean.xml}    | 26 --------
 .../src/main/resources/config/SessionMapper.xml    | 57 ------------------
 .../src/main/resources/config/UserMapper.xml       | 46 --------------
 .../src/main/resources/config/create_db_user.sql   | 46 --------------
 .../src/main/resources/config/cse.handler.xml}     | 14 ++---
 .../src/main/resources/config/mybatis-config.xml   | 27 ---------
 .../src/main/resources/microservice.yaml           | 18 +++++-
 .../authentication/api/AuthenticationEndpoint.java |  5 +-
 authentication/api/common/service/pom.xml          | 25 ++++++++
 .../servicecomb/authentication/jwt/JWTClaims.java  | 42 +++++++++----
 .../servicecomb/authentication/util/Constants.java |  9 +++
 41 files changed, 493 insertions(+), 482 deletions(-)

diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
index 77a6342..5840fc3 100644
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
@@ -1,28 +1,46 @@
 package org.apache.servicecomb.authentication;
 
+import java.util.Arrays;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
+import org.springframework.security.jwt.crypto.sign.MacSigner;
+import org.springframework.security.jwt.crypto.sign.Signer;
+import org.springframework.security.provisioning.InMemoryUserDetailsManager;
 
 @Configuration
 public class AuthenticationConfiguration {
+  @Autowired
+  @Qualifier("authPasswordEncoder")
+  private PasswordEncoder passwordEncoder;
+
   @Bean(name = "authPasswordEncoder")
-  private PasswordEncoder authPasswordEncoder() {
-    return new PasswordEncoder() {
+  public PasswordEncoder authPasswordEncoder() {
+    return new Pbkdf2PasswordEncoder();
+  }
 
-      @Override
-      public String encode(CharSequence rawPassword) {
-        // TODO Auto-generated method stub
-        return null;
-      }
+  @Bean(name = "authSigner")
+  public Signer authSigner() {
+    return new MacSigner("Please change this key.");
+  }
 
-      @Override
-      public boolean matches(CharSequence rawPassword, String encodedPassword) {
-        // TODO Auto-generated method stub
-        return false;
-      }
-      
-    };
+  @Bean(name = "authUserDetailsService")
+  public UserDetailsService authUserDetailsService() {
+    InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
+    UserDetails uAdmin = new User("admin", passwordEncoder.encode("changeMyPassword"),
+        Arrays.asList(new SimpleGrantedAuthority("ADMIN")));
+    UserDetails uGuest = new User("guest", passwordEncoder.encode("changeMyPassword"),
+        Arrays.asList(new SimpleGrantedAuthority("GUEST")));
+    manager.createUser(uAdmin);
+    manager.createUser(uGuest);
+    return manager;
   }
-  
 }
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
index a6e856a..cfbe22b 100644
--- a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
@@ -21,10 +21,10 @@ import org.apache.servicecomb.authentication.api.AuthenticationService;
 import org.apache.servicecomb.authentication.api.Token;
 import org.apache.servicecomb.authentication.jwt.JWTClaims;
 import org.apache.servicecomb.authentication.jwt.JsonParser;
-import org.apache.servicecomb.authentication.user.User;
-import org.apache.servicecomb.authentication.user.UserStore;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.security.jwt.Jwt;
 import org.springframework.security.jwt.JwtHelper;
@@ -34,8 +34,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class AuthenticationServiceImpl implements AuthenticationService {
   @Autowired
-  @Qualifier("authUserStore")
-  private UserStore userStore;
+  @Qualifier("authUserDetailsService")
+  private UserDetailsService userDetailsService;
 
   @Autowired
   @Qualifier("authPasswordEncoder")
@@ -47,17 +47,17 @@ public class AuthenticationServiceImpl implements AuthenticationService {
 
   @Override
   public Token login(String userName, String password) {
-    User user = userStore.loadUserByUsername(userName);
-    if (passwordEncoder.matches(password, user.getPassword())) {
+    UserDetails userDetails = userDetailsService.loadUserByUsername(userName);
+    if (passwordEncoder.matches(password, userDetails.getPassword())) {
       JWTClaims claims = new JWTClaims();
-      if (user.getRoles() != null) {
-        user.getRoles().forEach(role -> claims.addRole(role.getRoleName()));
+      if (userDetails.getAuthorities() != null) {
+        userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
       }
-      claims.setScope("read");
       String content = JsonParser.unparse(claims);
       Jwt accessToken = JwtHelper.encode(content, signer);
 
       Token token = new Token();
+      token.setScope(claims.getScope());
       token.setExpires_in(10 * 60);
       token.setToken_type("bearer");
       token.setAccess_token(accessToken.getEncoded());
diff --git a/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml b/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
index 661608f..b33e5c9 100644
--- a/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
+++ b/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
@@ -1,56 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
+<!-- ~ Licensed to the Apache Software Foundation (ASF) under one or more 
+  ~ contributor license agreements. See the NOTICE file distributed with ~ 
+  this work for additional information regarding copyright ownership. ~ The 
+  ASF licenses this file to You under the Apache License, Version 2.0 ~ (the 
+  "License"); you may not use this file except in compliance with ~ the License. 
+  You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 
+  ~ ~ Unless required by applicable law or agreed to in writing, software ~ 
+  distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT 
+  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the 
+  License for the specific language governing permissions and ~ limitations 
+  under the License. -->
 
 <beans xmlns="http://www.springframework.org/schema/beans"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-    xmlns:util="http://www.springframework.org/schema/util"
-    xmlns:context="http://www.springframework.org/schema/context"
-    xmlns:tx="http://www.springframework.org/schema/tx"
-    xsi:schemaLocation="
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+  xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
+  xmlns:tx="http://www.springframework.org/schema/tx"
+  xsi:schemaLocation="
 		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
 		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
   <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
-    init-method="init"/>
-    
-    <bean id="dataSource"
-        class="org.apache.commons.dbcp2.BasicDataSource"
-        destroy-method="close">
-        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
-        <property name="url"
-            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
-        <property name="username" value="${db.username:root}" />
-        <property name="password" value="${db.password:}" />
-    </bean>
-
-    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
-        <property name="dataSource" ref="dataSource" />
-        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
-    </bean>
-
-    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
-    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
+    init-method="init" />
 </beans>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml b/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml
deleted file mode 100644
index 989e786..0000000
--- a/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
-    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
-        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
-    </sql>
-
-    <sql id="all_column_auto">
-        SESSION_ID, USER_NAME, ROLE_NAME
-    </sql>
-
-    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        insert into T_SESSION (
-        <include refid="all_column_auto" />
-        )
-        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
-        #{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getSessioinInfo" parameterType="java.lang.String"
-        resultMap="sessionInfo">
-        select
-        <include refid="all_column" />
-        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
-    </select>
-    
-    <update id="updateSessionInfo" parameterType="java.lang.String">
-        update T_SESSION
-        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
-    </update>
-</mapper>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/UserMapper.xml b/authentication/AuthenticationServer/src/main/resources/config/UserMapper.xml
deleted file mode 100644
index c02e60d..0000000
--- a/authentication/AuthenticationServer/src/main/resources/config/UserMapper.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
-    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, USER_NAME, PASSWORD, ROLE_NAME
-    </sql>
-
-    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        insert into T_USER (
-        <include refid="all_column" />
-        )
-        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
-        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getUserInfo" parameterType="java.lang.String"
-        resultMap="userInfo">
-        select
-        <include refid="all_column" />
-        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
-    </select>
-</mapper>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql b/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql
deleted file mode 100644
index a07c5d9..0000000
--- a/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE DATABASE IF NOT EXISTS porter_user_db;
-
-USE porter_user_db;
-
-DROP TABLE IF EXISTS T_USER;
-
-CREATE TABLE `T_USER` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  PRIMARY KEY (`ID`)
-);
-
-#### password is encrypted for test
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
-
-DROP TABLE IF EXISTS T_SESSION;
-
-CREATE TABLE `T_SESSION` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
-  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
-  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
-  PRIMARY KEY (`ID`)
-);
diff --git a/authentication/AuthenticationServer/src/main/resources/microservice.yaml b/authentication/AuthenticationServer/src/main/resources/microservice.yaml
index 1e6b0af..dfedc0f 100644
--- a/authentication/AuthenticationServer/src/main/resources/microservice.yaml
+++ b/authentication/AuthenticationServer/src/main/resources/microservice.yaml
@@ -23,6 +23,7 @@ APPLICATION_ID: authentication-application
 service_description:
   version: 0.0.1
   name: authentication-server
+  environment: development
 
 servicecomb:
   service:
diff --git a/authentication/Gateway/pom.xml b/authentication/Gateway/pom.xml
index 9223b6b..932669e 100644
--- a/authentication/Gateway/pom.xml
+++ b/authentication/Gateway/pom.xml
@@ -1,19 +1,14 @@
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
+<!-- ~ Licensed to the Apache Software Foundation (ASF) under one or more 
+  ~ contributor license agreements. See the NOTICE file distributed with ~ 
+  this work for additional information regarding copyright ownership. ~ The 
+  ASF licenses this file to You under the Apache License, Version 2.0 ~ (the 
+  "License"); you may not use this file except in compliance with ~ the License. 
+  You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 
+  ~ ~ Unless required by applicable law or agreed to in writing, software ~ 
+  distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT 
+  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the 
+  License for the specific language governing permissions and ~ limitations 
+  under the License. -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -37,11 +32,29 @@
         <type>pom</type>
         <scope>import</scope>
       </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-server-api-service</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-endpoint</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-server-api-service</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>solution-basic</artifactId>
     </dependency>
@@ -53,6 +66,11 @@
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>edge-core</artifactId>
     </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
similarity index 97%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
index e801ebd..9f45550 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import java.util.Map;
 
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java
similarity index 55%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java
index 7119753..d6b879a 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java
@@ -15,17 +15,34 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
+import org.apache.servicecomb.authentication.util.Constants;
 import org.apache.servicecomb.core.Handler;
 import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.springframework.security.jwt.Jwt;
+import org.springframework.security.jwt.JwtHelper;
+import org.springframework.security.jwt.crypto.sign.InvalidSignatureException;
 
 
 public class AuthHandler implements Handler {
   @Override
   public void handle(Invocation invocation, AsyncResponse asyncResponse) throws Exception {
-    // TODO check session
+    String token = invocation.getContext(Constants.CONTEXT_HEADER_AUTHORIZATION);
+    if (token == null) {
+      asyncResponse.consumerFail(new InvocationException(403, "forbidden", "not authenticated"));
+      return;
+    }
+    Jwt jwt = JwtHelper.decode(token);
+    try {
+      jwt.verifySignature(BeanUtils.getBean("authSigner"));
+    } catch (InvalidSignatureException e) {
+      asyncResponse.consumerFail(new InvocationException(403, "forbidden", "not authenticated"));
+      return;
+    }
     invocation.next(asyncResponse);
   }
 }
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
new file mode 100644
index 0000000..b188402
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
@@ -0,0 +1,14 @@
+package org.apache.servicecomb.authentication.gateway;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.jwt.crypto.sign.MacSigner;
+import org.springframework.security.jwt.crypto.sign.Signer;
+
+@Configuration
+public class AuthenticationConfiguration {
+  @Bean(name = "authSigner")
+  public Signer authSigner() {
+    return new MacSigner("Please change this key.");
+  }
+}
diff --git a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java
similarity index 74%
copy from authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
copy to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java
index dfc9c51..021b337 100644
--- a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java
@@ -15,24 +15,29 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
+package org.apache.servicecomb.authentication.gateway;
 
+import org.apache.servicecomb.authentication.api.AuthenticationService;
+import org.apache.servicecomb.authentication.api.Token;
+import org.apache.servicecomb.provider.pojo.RpcReference;
 import org.apache.servicecomb.provider.rest.common.RestSchema;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
 @RestSchema(schemaId = "AuthenticationEndpoint")
-@RequestMapping(path = "/v1/auth/login")
+@RequestMapping(path = "/v1/auth")
 public class AuthenticationEndpoint {
-  @Autowired
+  @RpcReference(microserviceName = "authentication-server", schemaId = "AuthenticationEndpoint")
   private AuthenticationService authenticationService;
 
+  @PostMapping(path = "login")
   public Token login(@RequestParam(name = "userName") String userName,
       @RequestParam(name = "password") String password) {
     return authenticationService.login(userName, password);
   }
 
+  @PostMapping(path = "refresh")
   public Token refresh(@RequestParam(name = "refreshToken") String refreshToken) {
     return authenticationService.refresh(refreshToken);
   }
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
new file mode 100644
index 0000000..a6817bf
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
@@ -0,0 +1,30 @@
+package org.apache.servicecomb.authentication.gateway;
+
+import org.apache.servicecomb.authentication.util.Constants;
+import org.apache.servicecomb.common.rest.filter.HttpServerFilter;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
+import org.apache.servicecomb.swagger.invocation.Response;
+
+public class AuthenticationFilter implements HttpServerFilter {
+
+  @Override
+  public int getOrder() {
+    return 0;
+  }
+
+  @Override
+  public Response afterReceiveRequest(Invocation invocation, HttpServletRequestEx requestEx) {
+    String authentication = requestEx.getHeader(Constants.HTTP_HEADER_AUTHORIZATION);
+    if (authentication != null) {
+      String[] tokens = authentication.split(" ");
+      if (tokens.length == 2) {
+        if (tokens[0].equals("Bearer")) {
+          invocation.addContext(Constants.CONTEXT_HEADER_AUTHORIZATION, tokens[1]);
+        }
+      }
+    }
+    return null;
+  }
+
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java
similarity index 98%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java
index a2941be..8d7472f 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
@@ -44,7 +44,7 @@ import io.vertx.ext.web.Router;
 import io.vertx.ext.web.RoutingContext;
 import io.vertx.ext.web.handler.CookieHandler;
 
-// copied from org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher
+// copied from org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher 1.2.0
 public class CustomVertxRestDispatcher extends AbstractVertxHttpDispatcher {
   private static final Logger LOGGER = LoggerFactory.getLogger(VertxRestDispatcher.class);
 
@@ -62,7 +62,7 @@ public class CustomVertxRestDispatcher extends AbstractVertxHttpDispatcher {
 
   @Override
   public void init(Router router) {
-    String regex = "[/v1/log/|/inspector|/v1/auth](.*)";
+    String regex = "(/v1/log|/inspector|/v1/auth)/(.*)";
     router.routeWithRegex(regex).handler(CookieHandler.create());
     router.routeWithRegex(regex).handler(createBodyHandler());
     router.routeWithRegex(regex).failureHandler(this::failureHandler).handler(this::onRequest);
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
similarity index 95%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
index 159c10d..0fb1268 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import java.io.File;
 
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/GatewayMain.java
similarity index 94%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/GatewayMain.java
index a219d2d..862e6c3 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/GatewayMain.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java
similarity index 96%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java
index 0b181d8..e05f867 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import org.apache.servicecomb.core.Handler;
 import org.apache.servicecomb.core.Invocation;
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
similarity index 97%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
rename to authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
index 791c512..555ddc4 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.samples.porter.gateway;
+package org.apache.servicecomb.authentication.gateway;
 
 import org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher;
 import org.slf4j.Logger;
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
new file mode 100644
index 0000000..57adadd
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
@@ -0,0 +1 @@
+org.apache.servicecomb.authentication.gateway.AuthenticationFilter
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
index bada1de..cb82ded 100644
--- a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
+++ b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -15,6 +15,6 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.samples.porter.gateway.ApiDispatcher
-org.apache.servicecomb.samples.porter.gateway.StaticWebpageDispatcher
-org.apache.servicecomb.samples.porter.gateway.CustomVertxRestDispatcher
\ No newline at end of file
+org.apache.servicecomb.authentication.gateway.ApiDispatcher
+org.apache.servicecomb.authentication.gateway.StaticWebpageDispatcher
+org.apache.servicecomb.authentication.gateway.CustomVertxRestDispatcher
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/config/cse.handler.xml b/authentication/Gateway/src/main/resources/config/cse.handler.xml
index e9dd306..b39da71 100644
--- a/authentication/Gateway/src/main/resources/config/cse.handler.xml
+++ b/authentication/Gateway/src/main/resources/config/cse.handler.xml
@@ -17,7 +17,7 @@
 
 <config>
   <handler id="auth"
-    class="org.apache.servicecomb.samples.porter.gateway.AuthHandler" />
+    class="org.apache.servicecomb.authentication.gateway.AuthHandler" />
   <handler id="internalAccess"
-    class="org.apache.servicecomb.samples.porter.gateway.InternalAccessHandler" />
+    class="org.apache.servicecomb.authentication.gateway.InternalAccessHandler" />
 </config>
diff --git a/authentication/Gateway/src/main/resources/microservice.yaml b/authentication/Gateway/src/main/resources/microservice.yaml
index 5b1cd91..8d926ee 100644
--- a/authentication/Gateway/src/main/resources/microservice.yaml
+++ b/authentication/Gateway/src/main/resources/microservice.yaml
@@ -23,6 +23,7 @@ APPLICATION_ID: authentication-application
 service_description:
   version: 0.0.1
   name: gateway
+  environment: development
 
 servicecomb:
   service:
@@ -38,6 +39,8 @@ servicecomb:
     chain:
       Consumer:
         default: internalAccess,auth,qps-flowcontrol-consumer,loadbalance
+        service:
+          authentication-server: internalAccess,qps-flowcontrol-consumer,loadbalance
 
   uploads:
     directory: tmp_for_upload_gateway
diff --git a/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java b/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
new file mode 100644
index 0000000..bb737ba
--- /dev/null
+++ b/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
@@ -0,0 +1,19 @@
+package org.apache.servicecomb.authentication.test;
+
+import java.util.regex.Pattern;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class PatternTest {
+  @Test
+  public void testPattern() {
+    String regex = "(/v1/log|/inspector|/v1/auth)/(.*)";
+    Pattern p = Pattern.compile(regex);
+    Assert.assertTrue(p.matcher("/v1/log/login").matches());
+    Assert.assertTrue(p.matcher("/inspector/login").matches());
+    Assert.assertTrue(p.matcher("/v1/auth/login").matches());
+    Assert.assertTrue(!p.matcher("/api/v1/auth/login").matches());
+  }
+}
diff --git a/authentication/ResourceServer/pom.xml b/authentication/ResourceServer/pom.xml
index 52aea79..baeb56a 100644
--- a/authentication/ResourceServer/pom.xml
+++ b/authentication/ResourceServer/pom.xml
@@ -27,6 +27,16 @@
   <dependencyManagement>
     <dependencies>
       <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-server-api-service</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
         <groupId>org.mybatis</groupId>
         <artifactId>mybatis</artifactId>
         <version>3.4.5</version>
@@ -53,6 +63,14 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-endpoint</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-server-api-service</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>solution-basic</artifactId>
     </dependency>
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
new file mode 100644
index 0000000..136a11a
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
@@ -0,0 +1,20 @@
+package org.apache.servicecomb.authentication.resource;
+
+import org.apache.servicecomb.config.inject.InjectProperties;
+import org.apache.servicecomb.config.inject.InjectProperty;
+
+@InjectProperties(prefix = "servicecomb.authencation.access")
+public class AccessConfiguration {
+  @InjectProperty(keys = {
+      "needAuth.${schemaId}.${operationId}",
+      "needAuth.${schemaId}",
+      "needAuth"},
+      defaultValue = "true")
+  public boolean needAuth;
+
+  @InjectProperty(keys = {
+      "roles.${schemaId}.${operationId}",
+      "roles.${schemaId}",
+      "roles"})
+  public String roles;
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
new file mode 100644
index 0000000..c4cbd1e
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
@@ -0,0 +1,19 @@
+package org.apache.servicecomb.authentication.resource;
+
+import java.util.Map;
+
+import org.apache.servicecomb.config.inject.ConfigObjectFactory;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
+
+public class AccessConfigurationManager {
+  private static final Map<String, AccessConfiguration> CONFIGURATIONS = new ConcurrentHashMapEx<>();
+
+  private static final ConfigObjectFactory FACTORY = new ConfigObjectFactory();
+
+  public static AccessConfiguration getAccessConfiguration(Invocation invocation) {
+    return CONFIGURATIONS.computeIfAbsent(invocation.getOperationMeta().getSchemaQualifiedName(), key -> {
+      return FACTORY.create(AccessConfiguration.class, "schemaId", invocation.getSchemaId(), "operationId", invocation.getOperationName());
+    });
+  }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
new file mode 100644
index 0000000..847550f
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
@@ -0,0 +1,14 @@
+package org.apache.servicecomb.authentication.resource;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.jwt.crypto.sign.MacSigner;
+import org.springframework.security.jwt.crypto.sign.Signer;
+
+@Configuration
+public class AuthenticationConfiguration {
+  @Bean(name = "authSigner")
+  public Signer authSigner() {
+    return new MacSigner("Please change this key.");
+  }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
new file mode 100644
index 0000000..32256ad
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
@@ -0,0 +1,29 @@
+package org.apache.servicecomb.authentication.resource;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@RestSchema(schemaId = "HandlerAuthEndpoint")
+@RequestMapping(path = "/v1/auth/handler")
+public class HandlerAuthEndpoint {
+  @PostMapping(path = "/adminSayHello")
+  public String adminSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/guestSayHello")
+  public String guestSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/guestOrAdminSayHello")
+  public String guestOrAdminSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/everyoneSayHello")
+  public String everyoneSayHello(String name) {
+    return name;
+  }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
new file mode 100644
index 0000000..eea0968
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
@@ -0,0 +1,33 @@
+package org.apache.servicecomb.authentication.resource;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@RestSchema(schemaId = "PreMethodAuthEndpoint")
+@RequestMapping(path = "/v1/auth/method")
+public class PreMethodAuthEndpoint {
+  @PostMapping(path = "/adminSayHello")
+  @PreAuthorize("hasRole('ADMIN')")
+  public String adminSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/guestSayHello")
+  @PreAuthorize("hasRole('USER')")
+  public String guestSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/guestOrAdminSayHello")
+  @PreAuthorize("hasRole('USER,ADMIN')")
+  public String guestOrAdminSayHello(String name) {
+    return name;
+  }
+
+  @PostMapping(path = "/everyoneSayHello")
+  public String everyoneSayHello(String name) {
+    return name;
+  }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
new file mode 100644
index 0000000..fdfb3ad
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
@@ -0,0 +1,70 @@
+package org.apache.servicecomb.authentication.resource;
+
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.servicecomb.authentication.jwt.JWTClaims;
+import org.apache.servicecomb.authentication.jwt.JsonParser;
+import org.apache.servicecomb.authentication.util.Constants;
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.springframework.security.jwt.Jwt;
+import org.springframework.security.jwt.JwtHelper;
+
+public class ResourceAuthHandler implements Handler {
+
+  @Override
+  public void handle(Invocation invocation, AsyncResponse asyncResponse) throws Exception {
+    AccessConfiguration config = AccessConfigurationManager.getAccessConfiguration(invocation);
+
+    // by pass authentication
+    if (!config.needAuth) {
+      invocation.next(asyncResponse);
+      return;
+    }
+
+    String token = invocation.getContext(Constants.CONTEXT_HEADER_AUTHORIZATION);
+    if (token == null) {
+      asyncResponse.consumerFail(new InvocationException(403, "forbidden", "not authenticated"));
+      return;
+    }
+    // verify tokens
+    Jwt jwt = JwtHelper.decode(token);
+    JWTClaims claims;
+    try {
+      jwt.verifySignature(BeanUtils.getBean("authSigner"));
+      claims = JsonParser.parse(jwt.getClaims(), JWTClaims.class);
+      // TODO: verify claims.
+    } catch (Exception e) {
+      asyncResponse.consumerFail(new InvocationException(403, "forbidden", "not authenticated"));
+      return;
+    }
+
+    // check roles
+    if (!StringUtils.isEmpty(config.roles)) {
+      String[] roles = config.roles.split(",");
+      if (roles.length > 0) {
+        boolean valid = false;
+        Set<String> authorities = claims.getAuthorities();
+        for (String role : roles) {
+          if (authorities.contains(role)) {
+            valid = true;
+            break;
+          }
+        }
+        if (!valid) {
+          asyncResponse.consumerFail(new InvocationException(403, "forbidden", "not authenticated"));
+          return;
+        }
+      }
+    }
+
+    // pre method authentiation
+    invocation.addLocalContext(Constants.CONTEXT_HEADER_CLAIMS, jwt.getClaims());
+    invocation.next(asyncResponse);
+  }
+
+}
diff --git a/authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml b/authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml
similarity index 58%
rename from authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml
rename to authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml
index 661608f..fd84e44 100644
--- a/authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml
+++ b/authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml
@@ -27,30 +27,4 @@
 		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
   <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
     init-method="init"/>
-    
-    <bean id="dataSource"
-        class="org.apache.commons.dbcp2.BasicDataSource"
-        destroy-method="close">
-        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
-        <property name="url"
-            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
-        <property name="username" value="${db.username:root}" />
-        <property name="password" value="${db.password:}" />
-    </bean>
-
-    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
-        <property name="dataSource" ref="dataSource" />
-        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
-    </bean>
-
-    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
-    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
-        <property name="mapperInterface"
-            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
-        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
-    </bean>
 </beans>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml b/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml
deleted file mode 100644
index 989e786..0000000
--- a/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
-    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
-        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
-    </sql>
-
-    <sql id="all_column_auto">
-        SESSION_ID, USER_NAME, ROLE_NAME
-    </sql>
-
-    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
-        insert into T_SESSION (
-        <include refid="all_column_auto" />
-        )
-        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
-        #{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getSessioinInfo" parameterType="java.lang.String"
-        resultMap="sessionInfo">
-        select
-        <include refid="all_column" />
-        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
-    </select>
-    
-    <update id="updateSessionInfo" parameterType="java.lang.String">
-        update T_SESSION
-        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
-    </update>
-</mapper>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/UserMapper.xml b/authentication/ResourceServer/src/main/resources/config/UserMapper.xml
deleted file mode 100644
index c02e60d..0000000
--- a/authentication/ResourceServer/src/main/resources/config/UserMapper.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
-    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        <result column="ID" jdbcType="INTEGER" property="id" />
-        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
-        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
-        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
-    </resultMap>
-
-    <sql id="all_column">
-        ID, USER_NAME, PASSWORD, ROLE_NAME
-    </sql>
-
-    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
-        insert into T_USER (
-        <include refid="all_column" />
-        )
-        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
-        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
-    </insert>
-
-    <select id="getUserInfo" parameterType="java.lang.String"
-        resultMap="userInfo">
-        select
-        <include refid="all_column" />
-        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
-    </select>
-</mapper>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/create_db_user.sql b/authentication/ResourceServer/src/main/resources/config/create_db_user.sql
deleted file mode 100644
index a07c5d9..0000000
--- a/authentication/ResourceServer/src/main/resources/config/create_db_user.sql
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE DATABASE IF NOT EXISTS porter_user_db;
-
-USE porter_user_db;
-
-DROP TABLE IF EXISTS T_USER;
-
-CREATE TABLE `T_USER` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  PRIMARY KEY (`ID`)
-);
-
-#### password is encrypted for test
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
-insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
-
-DROP TABLE IF EXISTS T_SESSION;
-
-CREATE TABLE `T_SESSION` (
-  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
-  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
-  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
-  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
-  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
-  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
-  PRIMARY KEY (`ID`)
-);
diff --git a/authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml b/authentication/ResourceServer/src/main/resources/config/cse.handler.xml
similarity index 71%
rename from authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml
rename to authentication/ResourceServer/src/main/resources/config/cse.handler.xml
index 894caac..0efe6d1 100644
--- a/authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml
+++ b/authentication/ResourceServer/src/main/resources/config/cse.handler.xml
@@ -1,4 +1,3 @@
-<?xml version="1.0" encoding="UTF-8" ?>
 <!--
   ~ Licensed to the Apache Software Foundation (ASF) under one or more
   ~ contributor license agreements.  See the NOTICE file distributed with
@@ -16,12 +15,7 @@
   ~ limitations under the License.
   -->
 
-<!DOCTYPE configuration
-  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
-  "http://mybatis.org/dtd/mybatis-3-config.dtd">
-<configuration>
-    <mappers>
-        <mapper resource="config/UserMapper.xml"/>
-        <mapper resource="config/SessionMapper.xml"/>
-    </mappers>
-</configuration>
\ No newline at end of file
+<config>
+  <handler id="resource-auth-provider"
+    class="org.apache.servicecomb.authentication.resource.ResourceAuthHandler" />
+</config>
diff --git a/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml b/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml
deleted file mode 100644
index 894caac..0000000
--- a/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE configuration
-  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
-  "http://mybatis.org/dtd/mybatis-3-config.dtd">
-<configuration>
-    <mappers>
-        <mapper resource="config/UserMapper.xml"/>
-        <mapper resource="config/SessionMapper.xml"/>
-    </mappers>
-</configuration>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/microservice.yaml b/authentication/ResourceServer/src/main/resources/microservice.yaml
index 47b05c1..69b0ffc 100644
--- a/authentication/ResourceServer/src/main/resources/microservice.yaml
+++ b/authentication/ResourceServer/src/main/resources/microservice.yaml
@@ -23,7 +23,8 @@ APPLICATION_ID: authentication-application
 service_description:
   version: 0.0.1
   name: resource-server
-
+  environment: development
+  
 servicecomb:
   service:
     registry:
@@ -33,3 +34,18 @@ servicecomb:
 
   rest:
     address: 0.0.0.0:9092
+
+  authencation:
+    access:
+      needAuth: true
+      roles:
+        HandlerAuthEndpoint:
+          adminSayHello: ADMIN
+          guestSayHello: GUEST
+          guestOrAdminSayHello: ADMIN,GUEST
+          # everyoneSayHello: all can
+
+  handler:
+    chain:
+      Provider:
+        default: qps-flowcontrol-provider,resource-auth-provider
\ No newline at end of file
diff --git a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
index dfc9c51..5177aeb 100644
--- a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
+++ b/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
@@ -19,20 +19,23 @@ package org.apache.servicecomb.authentication.api;
 
 import org.apache.servicecomb.provider.rest.common.RestSchema;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
 @RestSchema(schemaId = "AuthenticationEndpoint")
-@RequestMapping(path = "/v1/auth/login")
+@RequestMapping(path = "/v1/auth")
 public class AuthenticationEndpoint {
   @Autowired
   private AuthenticationService authenticationService;
 
+  @PostMapping(path = "login")
   public Token login(@RequestParam(name = "userName") String userName,
       @RequestParam(name = "password") String password) {
     return authenticationService.login(userName, password);
   }
 
+  @PostMapping(path = "refresh")
   public Token refresh(@RequestParam(name = "refreshToken") String refreshToken) {
     return authenticationService.refresh(refreshToken);
   }
diff --git a/authentication/api/common/service/pom.xml b/authentication/api/common/service/pom.xml
index 538be70..66c5f90 100644
--- a/authentication/api/common/service/pom.xml
+++ b/authentication/api/common/service/pom.xml
@@ -28,4 +28,29 @@
   <artifactId>authentication-common-api-service</artifactId>
   <packaging>jar</packaging>
 
+ <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.springframework.security.oauth</groupId>
+        <artifactId>spring-security-oauth2</artifactId>
+        <version>2.3.2.RELEASE</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework.security</groupId>
+        <artifactId>spring-security-jwt</artifactId>
+        <version>1.0.7.RELEASE</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.security.oauth</groupId>
+      <artifactId>spring-security-oauth2</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.security</groupId>
+      <artifactId>spring-security-jwt</artifactId>
+    </dependency>
+  </dependencies>
 </project>
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
index 569b4da..a5db2c2 100644
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/jwt/JWTClaims.java
@@ -1,26 +1,27 @@
 package org.apache.servicecomb.authentication.jwt;
 
-import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 public class JWTClaims extends JWTClaimsCommon {
-  protected Set<String> roles = Collections.emptySet();
+  protected Set<String> authorities;
 
-  protected Map<String, Object> additionalInformation = Collections.emptyMap();
+  protected Map<String, Object> additionalInformation;
 
   /**
    * The scope of the access token as described by <a
    * href="http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-3.3">Section 3.3</a>
    */
-  protected String scope;
+  protected Set<String> scope;
 
-  public Set<String> getRoles() {
-    return roles;
+  public Set<String> getAuthorities() {
+    return authorities;
   }
 
-  public void setRoles(Set<String> roles) {
-    this.roles = roles;
+  public void setAuthorities(Set<String> authorities) {
+    this.authorities = authorities;
   }
 
   public Map<String, Object> getAdditionalInformation() {
@@ -31,15 +32,32 @@ public class JWTClaims extends JWTClaimsCommon {
     this.additionalInformation = additionalInformation;
   }
 
-  public String getScope() {
+  public Set<String> getScope() {
     return scope;
   }
 
-  public void setScope(String scope) {
+  public void setScope(Set<String> scope) {
     this.scope = scope;
   }
 
-  public void addRole(String role) {
-    this.roles.add(role);
+  public void addAdditionalInformation(String key, Object value) {
+    if (this.additionalInformation == null) {
+      this.additionalInformation = new HashMap<>();
+    }
+    this.additionalInformation.put(key, value);
+  }
+
+  public void addScope(String operation) {
+    if (this.scope == null) {
+      this.scope = new HashSet<>();
+    }
+    this.scope.add(operation);
+  }
+
+  public void addAuthority(String authority) {
+    if (this.authorities == null) {
+      this.authorities = new HashSet<>();
+    }
+    this.authorities.add(authority);
   }
 }
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java
new file mode 100644
index 0000000..a7427fa
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java
@@ -0,0 +1,9 @@
+package org.apache.servicecomb.authentication.util;
+
+public final class Constants {
+  public static final String HTTP_HEADER_AUTHORIZATION = "Authorization";
+
+  public static final String CONTEXT_HEADER_AUTHORIZATION = "Authorization";
+  
+  public static final String CONTEXT_HEADER_CLAIMS = "Claims";
+}


[servicecomb-samples] 01/04: authentication: initial project commit

Posted by li...@apache.org.
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-samples.git

commit 0991cc9ae8cc873ee939140f0809dc07d6340210
Author: liubao <ba...@huawei.com>
AuthorDate: Wed May 8 14:25:29 2019 +0800

    authentication: initial project commit
---
 authentication/AuthenticationServer/pom.xml        | 155 ++++++++++++++++
 .../authentication/AuthenticationServer.java       |  30 +++
 .../service/AuthenticationServiceImpl.java         |  60 ++++++
 .../main/resources/META-INF/spring/user.bean.xml   |  56 ++++++
 .../src/main/resources/config/SessionMapper.xml    |  57 ++++++
 .../src/main/resources/config/UserMapper.xml       |  46 +++++
 .../src/main/resources/config/create_db_user.sql   |  46 +++++
 .../src/main/resources/config/mybatis-config.xml   |  27 +++
 .../src/main/resources/log4j2.xml                  |  43 +++++
 .../src/main/resources/microservice.yaml           |  35 ++++
 authentication/Client/pom.xml                      | 128 +++++++++++++
 .../apache/servicecomb/authentication/Client.java  |  30 +++
 .../main/resources/META-INF/spring/user.bean.xml   |  56 ++++++
 .../src/main/resources/config/SessionMapper.xml    |  57 ++++++
 .../src/main/resources/config/UserMapper.xml       |  46 +++++
 .../src/main/resources/config/create_db_user.sql   |  46 +++++
 .../src/main/resources/config/mybatis-config.xml   |  27 +++
 .../Client/src/main/resources/log4j2.xml           |  43 +++++
 .../Client/src/main/resources/microservice.yaml    |  35 ++++
 authentication/Gateway/pom.xml                     |  88 +++++++++
 .../samples/porter/gateway/ApiDispatcher.java      |  68 +++++++
 .../samples/porter/gateway/AuthHandler.java        |  31 ++++
 .../porter/gateway/CustomVertxRestDispatcher.java  | 196 ++++++++++++++++++++
 .../samples/porter/gateway/EdgeSSLCustom.java      |  38 ++++
 .../samples/porter/gateway/GatewayMain.java        |  26 +++
 .../porter/gateway/InternalAccessHandler.java      |  37 ++++
 .../porter/gateway/StaticWebpageDispatcher.java    |  52 ++++++
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |  20 ++
 .../main/resources/META-INF/spring/cse.bean.xml    |  27 +++
 .../src/main/resources/config/cse.handler.xml      |  23 +++
 .../Gateway/src/main/resources/log4j2.xml          |  43 +++++
 .../Gateway/src/main/resources/microservice.yaml   |  67 +++++++
 .../Gateway/src/main/resources/ui/css/style.css    |  49 +++++
 .../src/main/resources/ui/js/jquery-1.11.1.min.js  |   4 +
 .../Gateway/src/main/resources/ui/js/login.js      |  52 ++++++
 .../Gateway/src/main/resources/ui/js/upload.js     |  63 +++++++
 .../Gateway/src/main/resources/ui/login.html       |  45 +++++
 .../Gateway/src/main/resources/ui/upload.html      |  61 ++++++
 authentication/README.md                           |  26 +++
 authentication/ResourceServer/pom.xml              | 128 +++++++++++++
 .../servicecomb/authentication/ResourceServer.java |  30 +++
 .../authentication/resource/FileEndpoint.java      |  45 +++++
 .../authentication/resource/FileStoreService.java  |  31 ++++
 .../resource/LocalFileStoreService.java            |  64 +++++++
 .../main/resources/META-INF/spring/user.bean.xml   |  56 ++++++
 .../src/main/resources/config/SessionMapper.xml    |  57 ++++++
 .../src/main/resources/config/UserMapper.xml       |  46 +++++
 .../src/main/resources/config/create_db_user.sql   |  46 +++++
 .../src/main/resources/config/mybatis-config.xml   |  27 +++
 .../ResourceServer/src/main/resources/log4j2.xml   |  43 +++++
 .../src/main/resources/microservice.yaml           |  35 ++++
 .../api/AuthenticationServer/endpoint/pom.xml      |  38 ++++
 .../authentication/api/AuthenticationEndpoint.java |  39 ++++
 authentication/api/AuthenticationServer/pom.xml    |  36 ++++
 .../api/AuthenticationServer/service/pom.xml       |  31 ++++
 .../authentication/api/AuthenticationService.java  |  35 ++++
 .../servicecomb/authentication/api/Token.java      |  40 ++++
 .../servicecomb/authentication/api/Tokens.java     |  48 +++++
 authentication/api/common/endpoint/pom.xml         |  38 ++++
 .../samples/porter/file/api/InspectorEndpoint.java | 206 +++++++++++++++++++++
 .../samples/porter/file/api/LogEndpoint.java       |  72 +++++++
 authentication/api/common/pom.xml                  |  36 ++++
 authentication/api/common/service/pom.xml          |  31 ++++
 .../samples/porter/common/api/LogService.java      |  26 +++
 authentication/api/pom.xml                         |  90 +++++++++
 65 files changed, 3413 insertions(+)

diff --git a/authentication/AuthenticationServer/pom.xml b/authentication/AuthenticationServer/pom.xml
new file mode 100644
index 0000000..0c7a295
--- /dev/null
+++ b/authentication/AuthenticationServer/pom.xml
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ~ Licensed to the Apache Software Foundation (ASF) under one or more 
+  ~ contributor license agreements. See the NOTICE file distributed with ~ 
+  this work for additional information regarding copyright ownership. ~ The 
+  ASF licenses this file to You under the Apache License, Version 2.0 ~ (the 
+  "License"); you may not use this file except in compliance with ~ the License. 
+  You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 
+  ~ ~ Unless required by applicable law or agreed to in writing, software ~ 
+  distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT 
+  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the 
+  License for the specific language governing permissions and ~ limitations 
+  under the License. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.authentication</groupId>
+  <artifactId>authentication-server</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis</artifactId>
+        <version>3.4.5</version>
+      </dependency>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis-spring</artifactId>
+        <version>1.3.0</version>
+      </dependency>
+      <dependency>
+        <groupId>mysql</groupId>
+        <artifactId>mysql-connector-java</artifactId>
+        <version>5.1.46</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-server-api-endpoint</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>1.2.0</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework.security.oauth</groupId>
+        <artifactId>spring-security-oauth2</artifactId>
+        <version>2.3.2.RELEASE</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework.security</groupId>
+        <artifactId>spring-security-jwt</artifactId>
+        <version>1.0.7.RELEASE</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.security.oauth</groupId>
+      <artifactId>spring-security-oauth2</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.security</groupId>
+      <artifactId>spring-security-jwt</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-server-api-endpoint</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-dbcp2</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis-spring</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-jdbc</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context-support</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-tx</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.1.2.RELEASE</version>
+          <executions>
+            <execution>
+              <goals>
+                <goal>repackage</goal>
+              </goals>
+              <configuration>
+                <mainClass>${main.class}</mainClass>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServer.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServer.java
new file mode 100644
index 0000000..f38125a
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServer.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class AuthenticationServer {
+  public static void main(String[] args) {
+    try {
+      BeanUtils.init();
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+}
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
new file mode 100644
index 0000000..be46f5c
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication.service;
+
+import org.apache.servicecomb.authentication.api.AuthenticationService;
+import org.apache.servicecomb.authentication.api.Token;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AuthenticationServiceImpl implements AuthenticationService {
+  @Autowired
+  @Qualifier("userDetailsService")
+  private UserDetailsService userDetailsService;
+  
+  @Autowired
+  @Qualifier("passwordEncoder")
+  private PasswordEncoder passwordEncoder;
+
+  @Override
+  public Token login(String userName, String password) {
+    UserDetails userDetails;
+    try {
+      userDetails = userDetailsService.loadUserByUsername(userName);
+    } catch (UsernameNotFoundException e) {
+      return null;
+    }
+    if(passwordEncoder.matches(password, userDetails.getPassword())) {
+      return null;
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public Token refresh(String refreshToken) {
+    return null;
+  }
+
+}
diff --git a/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml b/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
new file mode 100644
index 0000000..661608f
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+    xmlns:util="http://www.springframework.org/schema/util"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:tx="http://www.springframework.org/schema/tx"
+    xsi:schemaLocation="
+		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
+    init-method="init"/>
+    
+    <bean id="dataSource"
+        class="org.apache.commons.dbcp2.BasicDataSource"
+        destroy-method="close">
+        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
+        <property name="url"
+            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
+        <property name="username" value="${db.username:root}" />
+        <property name="password" value="${db.password:}" />
+    </bean>
+
+    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+        <property name="dataSource" ref="dataSource" />
+        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
+    </bean>
+
+    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+</beans>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml b/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml
new file mode 100644
index 0000000..989e786
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/config/SessionMapper.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
+    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
+        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
+    </sql>
+
+    <sql id="all_column_auto">
+        SESSION_ID, USER_NAME, ROLE_NAME
+    </sql>
+
+    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        insert into T_SESSION (
+        <include refid="all_column_auto" />
+        )
+        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
+        #{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getSessioinInfo" parameterType="java.lang.String"
+        resultMap="sessionInfo">
+        select
+        <include refid="all_column" />
+        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
+    </select>
+    
+    <update id="updateSessionInfo" parameterType="java.lang.String">
+        update T_SESSION
+        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
+    </update>
+</mapper>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/UserMapper.xml b/authentication/AuthenticationServer/src/main/resources/config/UserMapper.xml
new file mode 100644
index 0000000..c02e60d
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/config/UserMapper.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
+    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, USER_NAME, PASSWORD, ROLE_NAME
+    </sql>
+
+    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        insert into T_USER (
+        <include refid="all_column" />
+        )
+        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
+        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getUserInfo" parameterType="java.lang.String"
+        resultMap="userInfo">
+        select
+        <include refid="all_column" />
+        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
+    </select>
+</mapper>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql b/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql
new file mode 100644
index 0000000..a07c5d9
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/config/create_db_user.sql
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+CREATE DATABASE IF NOT EXISTS porter_user_db;
+
+USE porter_user_db;
+
+DROP TABLE IF EXISTS T_USER;
+
+CREATE TABLE `T_USER` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  PRIMARY KEY (`ID`)
+);
+
+#### password is encrypted for test
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
+
+DROP TABLE IF EXISTS T_SESSION;
+
+CREATE TABLE `T_SESSION` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
+  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
+  PRIMARY KEY (`ID`)
+);
diff --git a/authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml b/authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml
new file mode 100644
index 0000000..894caac
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/config/mybatis-config.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE configuration
+  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+  "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <mappers>
+        <mapper resource="config/UserMapper.xml"/>
+        <mapper resource="config/SessionMapper.xml"/>
+    </mappers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/log4j2.xml b/authentication/AuthenticationServer/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..3c70391
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./user/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/AuthenticationServer/src/main/resources/microservice.yaml b/authentication/AuthenticationServer/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..1e6b0af
--- /dev/null
+++ b/authentication/AuthenticationServer/src/main/resources/microservice.yaml
@@ -0,0 +1,35 @@
+#
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 100
+
+APPLICATION_ID: authentication-application
+service_description:
+  version: 0.0.1
+  name: authentication-server
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9091
diff --git a/authentication/Client/pom.xml b/authentication/Client/pom.xml
new file mode 100644
index 0000000..60978df
--- /dev/null
+++ b/authentication/Client/pom.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ~ Licensed to the Apache Software Foundation (ASF) under one or more 
+  ~ contributor license agreements. See the NOTICE file distributed with ~ 
+  this work for additional information regarding copyright ownership. ~ The 
+  ASF licenses this file to You under the Apache License, Version 2.0 ~ (the 
+  "License"); you may not use this file except in compliance with ~ the License. 
+  You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 
+  ~ ~ Unless required by applicable law or agreed to in writing, software ~ 
+  distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT 
+  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the 
+  License for the specific language governing permissions and ~ limitations 
+  under the License. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.authentication</groupId>
+  <artifactId>client</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis</artifactId>
+        <version>3.4.5</version>
+      </dependency>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis-spring</artifactId>
+        <version>1.3.0</version>
+      </dependency>
+      <dependency>
+        <groupId>mysql</groupId>
+        <artifactId>mysql-connector-java</artifactId>
+        <version>5.1.46</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>1.2.0</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-dbcp2</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis-spring</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-jdbc</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context-support</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-tx</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.1.2.RELEASE</version>
+          <executions>
+            <execution>
+              <goals>
+                <goal>repackage</goal>
+              </goals>
+              <configuration>
+                <mainClass>${main.class}</mainClass>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
\ No newline at end of file
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/Client.java b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/Client.java
new file mode 100644
index 0000000..4ba1070
--- /dev/null
+++ b/authentication/Client/src/main/java/org/apache/servicecomb/authentication/Client.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class Client {
+  public static void main(String[] args) {
+    try {
+      BeanUtils.init();
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+}
diff --git a/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml b/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml
new file mode 100644
index 0000000..661608f
--- /dev/null
+++ b/authentication/Client/src/main/resources/META-INF/spring/user.bean.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+    xmlns:util="http://www.springframework.org/schema/util"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:tx="http://www.springframework.org/schema/tx"
+    xsi:schemaLocation="
+		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
+    init-method="init"/>
+    
+    <bean id="dataSource"
+        class="org.apache.commons.dbcp2.BasicDataSource"
+        destroy-method="close">
+        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
+        <property name="url"
+            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
+        <property name="username" value="${db.username:root}" />
+        <property name="password" value="${db.password:}" />
+    </bean>
+
+    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+        <property name="dataSource" ref="dataSource" />
+        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
+    </bean>
+
+    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+</beans>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/SessionMapper.xml b/authentication/Client/src/main/resources/config/SessionMapper.xml
new file mode 100644
index 0000000..989e786
--- /dev/null
+++ b/authentication/Client/src/main/resources/config/SessionMapper.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
+    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
+        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
+    </sql>
+
+    <sql id="all_column_auto">
+        SESSION_ID, USER_NAME, ROLE_NAME
+    </sql>
+
+    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        insert into T_SESSION (
+        <include refid="all_column_auto" />
+        )
+        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
+        #{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getSessioinInfo" parameterType="java.lang.String"
+        resultMap="sessionInfo">
+        select
+        <include refid="all_column" />
+        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
+    </select>
+    
+    <update id="updateSessionInfo" parameterType="java.lang.String">
+        update T_SESSION
+        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
+    </update>
+</mapper>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/UserMapper.xml b/authentication/Client/src/main/resources/config/UserMapper.xml
new file mode 100644
index 0000000..c02e60d
--- /dev/null
+++ b/authentication/Client/src/main/resources/config/UserMapper.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
+    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, USER_NAME, PASSWORD, ROLE_NAME
+    </sql>
+
+    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        insert into T_USER (
+        <include refid="all_column" />
+        )
+        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
+        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getUserInfo" parameterType="java.lang.String"
+        resultMap="userInfo">
+        select
+        <include refid="all_column" />
+        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
+    </select>
+</mapper>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/config/create_db_user.sql b/authentication/Client/src/main/resources/config/create_db_user.sql
new file mode 100644
index 0000000..a07c5d9
--- /dev/null
+++ b/authentication/Client/src/main/resources/config/create_db_user.sql
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+CREATE DATABASE IF NOT EXISTS porter_user_db;
+
+USE porter_user_db;
+
+DROP TABLE IF EXISTS T_USER;
+
+CREATE TABLE `T_USER` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  PRIMARY KEY (`ID`)
+);
+
+#### password is encrypted for test
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
+
+DROP TABLE IF EXISTS T_SESSION;
+
+CREATE TABLE `T_SESSION` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
+  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
+  PRIMARY KEY (`ID`)
+);
diff --git a/authentication/Client/src/main/resources/config/mybatis-config.xml b/authentication/Client/src/main/resources/config/mybatis-config.xml
new file mode 100644
index 0000000..894caac
--- /dev/null
+++ b/authentication/Client/src/main/resources/config/mybatis-config.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE configuration
+  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+  "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <mappers>
+        <mapper resource="config/UserMapper.xml"/>
+        <mapper resource="config/SessionMapper.xml"/>
+    </mappers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/log4j2.xml b/authentication/Client/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..3c70391
--- /dev/null
+++ b/authentication/Client/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./user/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/Client/src/main/resources/microservice.yaml b/authentication/Client/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..411b4c6
--- /dev/null
+++ b/authentication/Client/src/main/resources/microservice.yaml
@@ -0,0 +1,35 @@
+#
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 100
+
+APPLICATION_ID: authentication-application
+service_description:
+  version: 0.0.1
+  name: authentication-server
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9092
diff --git a/authentication/Gateway/pom.xml b/authentication/Gateway/pom.xml
new file mode 100644
index 0000000..9223b6b
--- /dev/null
+++ b/authentication/Gateway/pom.xml
@@ -0,0 +1,88 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.authentication</groupId>
+  <artifactId>gateway</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>1.2.0</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>edge-core</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.1.2.RELEASE</version>
+          <executions>
+            <execution>
+              <goals>
+                <goal>repackage</goal>
+              </goals>
+              <configuration>
+                <mainClass>${main.class}</mainClass>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
new file mode 100644
index 0000000..e801ebd
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/ApiDispatcher.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.samples.porter.gateway;
+
+import java.util.Map;
+
+import org.apache.servicecomb.edge.core.AbstractEdgeDispatcher;
+import org.apache.servicecomb.edge.core.EdgeInvocation;
+
+import io.vertx.ext.web.Cookie;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.CookieHandler;
+
+public class ApiDispatcher extends AbstractEdgeDispatcher {
+  @Override
+  public int getOrder() {
+    return 10002;
+  }
+
+  @Override
+  public void init(Router router) {
+    String regex = "/api/([^\\/]+)/(.*)";
+    router.routeWithRegex(regex).handler(CookieHandler.create());
+    router.routeWithRegex(regex).handler(createBodyHandler());
+    router.routeWithRegex(regex).failureHandler(this::onFailure).handler(this::onRequest);
+  }
+
+  protected void onRequest(RoutingContext context) {
+    Map<String, String> pathParams = context.pathParams();
+    String microserviceName = pathParams.get("param0");
+    String path = "/" + pathParams.get("param1");
+
+    EdgeInvocation invoker = new EdgeInvocation() {
+      // Authentication. Notice: adding context must after setContext or will override by network
+      protected void setContext() throws Exception {
+        super.setContext();
+        // get session id from header and cookie for debug reasons
+        String sessionId = context.request().getHeader("session-id");
+        if (sessionId != null) {
+          this.invocation.addContext("session-id", sessionId);
+        } else {
+          Cookie sessionCookie = context.getCookie("session-id");
+          if (sessionCookie != null) {
+            this.invocation.addContext("session-id", sessionCookie.getValue());
+          }
+        }
+      }
+    };
+    invoker.init(microserviceName, context, path, httpServerFilters);
+    invoker.edgeInvoke();
+  }
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
new file mode 100644
index 0000000..7119753
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/AuthHandler.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.samples.porter.gateway;
+
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+
+
+public class AuthHandler implements Handler {
+  @Override
+  public void handle(Invocation invocation, AsyncResponse asyncResponse) throws Exception {
+    // TODO check session
+    invocation.next(asyncResponse);
+  }
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java
new file mode 100644
index 0000000..a2941be
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/CustomVertxRestDispatcher.java
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.samples.porter.gateway;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.apache.servicecomb.common.rest.AbstractRestInvocation;
+import org.apache.servicecomb.common.rest.RestConst;
+import org.apache.servicecomb.common.rest.VertxRestInvocation;
+import org.apache.servicecomb.core.Const;
+import org.apache.servicecomb.core.CseContext;
+import org.apache.servicecomb.core.Transport;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx;
+import org.apache.servicecomb.foundation.vertx.http.VertxServerRequestToHttpServletRequest;
+import org.apache.servicecomb.foundation.vertx.http.VertxServerResponseToHttpServletResponse;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.apache.servicecomb.transport.rest.vertx.AbstractVertxHttpDispatcher;
+import org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException;
+import io.vertx.core.json.JsonObject;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.CookieHandler;
+
+// copied from org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher
+public class CustomVertxRestDispatcher extends AbstractVertxHttpDispatcher {
+  private static final Logger LOGGER = LoggerFactory.getLogger(VertxRestDispatcher.class);
+
+  private Transport transport;
+
+  @Override
+  public int getOrder() {
+    return 10001;
+  }
+
+  @Override
+  public boolean enabled() {
+    return true;
+  }
+
+  @Override
+  public void init(Router router) {
+    String regex = "[/v1/log/|/inspector|/v1/auth](.*)";
+    router.routeWithRegex(regex).handler(CookieHandler.create());
+    router.routeWithRegex(regex).handler(createBodyHandler());
+    router.routeWithRegex(regex).failureHandler(this::failureHandler).handler(this::onRequest);
+  }
+
+  private void failureHandler(RoutingContext context) {
+    LOGGER.error("http server failed.", context.failure());
+
+    AbstractRestInvocation restProducerInvocation = context.get(RestConst.REST_PRODUCER_INVOCATION);
+    Throwable e = context.failure();
+    if (ErrorDataDecoderException.class.isInstance(e)) {
+      Throwable cause = e.getCause();
+      if (InvocationException.class.isInstance(cause)) {
+        e = cause;
+      }
+    }
+
+    // only when unexpected exception happens, it will run into here.
+    // the connection should be closed.
+    handleFailureAndClose(context, restProducerInvocation, e);
+  }
+
+  /**
+   * Try to find out the failure information and send it in response.
+   */
+  private void handleFailureAndClose(RoutingContext context, AbstractRestInvocation restProducerInvocation,
+      Throwable e) {
+    if (null != restProducerInvocation) {
+      // if there is restProducerInvocation, let it send exception in response. The exception is allowed to be null.
+      sendFailResponseByInvocation(context, restProducerInvocation, e);
+      return;
+    }
+
+    if (null != e) {
+      // if there exists exception, try to send this exception by RoutingContext
+      sendExceptionByRoutingContext(context, e);
+      return;
+    }
+
+    // if there is no exception, the response is determined by status code.
+    sendFailureRespDeterminedByStatus(context);
+  }
+
+  /**
+   * Try to determine response by status code, and send response.
+   */
+  private void sendFailureRespDeterminedByStatus(RoutingContext context) {
+    Family statusFamily = Family.familyOf(context.statusCode());
+    if (Family.CLIENT_ERROR.equals(statusFamily) || Family.SERVER_ERROR.equals(statusFamily) || Family.OTHER
+        .equals(statusFamily)) {
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(context.statusCode()).end();
+    } else {
+      // it seems the status code is not set properly
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode())
+          .setStatusMessage(Status.INTERNAL_SERVER_ERROR.getReasonPhrase())
+          .end(wrapResponseBody(Status.INTERNAL_SERVER_ERROR.getReasonPhrase()));
+    }
+    context.response().close();
+  }
+
+  /**
+   * Use routingContext to send failure information in throwable.
+   */
+  private void sendExceptionByRoutingContext(RoutingContext context, Throwable e) {
+    if (InvocationException.class.isInstance(e)) {
+      InvocationException invocationException = (InvocationException) e;
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(invocationException.getStatusCode()).setStatusMessage(invocationException.getReasonPhrase())
+          .end(wrapResponseBody(invocationException.getReasonPhrase()));
+    } else {
+      context.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)
+          .setStatusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).end(wrapResponseBody(e.getMessage()));
+    }
+    context.response().close();
+  }
+
+  /**
+   * Consumer will treat the response body as json by default, so it's necessary to wrap response body as Json string
+   * to avoid deserialization error.
+   *
+   * @param message response body
+   * @return response body wrapped as Json string
+   */
+  String wrapResponseBody(String message) {
+    if (isValidJson(message)) {
+      return message;
+    }
+
+    JsonObject jsonObject = new JsonObject();
+    jsonObject.put("message", message);
+
+    return jsonObject.toString();
+  }
+
+  /**
+   * Check if the message is a valid Json string.
+   * @param message the message to be checked.
+   * @return true if message is a valid Json string, otherwise false.
+   */
+  private boolean isValidJson(String message) {
+    try {
+      new JsonObject(message);
+    } catch (Exception ignored) {
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Use restProducerInvocation to send failure message. The throwable is allowed to be null.
+   */
+  private void sendFailResponseByInvocation(RoutingContext context, AbstractRestInvocation restProducerInvocation,
+      Throwable e) {
+    restProducerInvocation.sendFailResponse(e);
+    context.response().close();
+  }
+
+  private void onRequest(RoutingContext context) {
+    if (transport == null) {
+      transport = CseContext.getInstance().getTransportManager().findTransport(Const.RESTFUL);
+    }
+    HttpServletRequestEx requestEx = new VertxServerRequestToHttpServletRequest(context);
+    HttpServletResponseEx responseEx = new VertxServerResponseToHttpServletResponse(context.response());
+
+    VertxRestInvocation vertxRestInvocation = new VertxRestInvocation();
+    context.put(RestConst.REST_PRODUCER_INVOCATION, vertxRestInvocation);
+    vertxRestInvocation.invoke(transport, requestEx, responseEx, httpServerFilters);
+  }
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java
new file mode 100644
index 0000000..159c10d
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/EdgeSSLCustom.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.samples.porter.gateway;
+
+import java.io.File;
+
+import org.apache.servicecomb.foundation.ssl.SSLCustom;
+
+public class EdgeSSLCustom extends SSLCustom {
+
+    @Override
+    public char[] decode(char[] plain) {
+        return plain;
+    }
+
+    @Override
+    public String getFullPath(String name) {
+        String fullName = System.getProperty("user.dir") + File.separator + name;
+        System.out.println(fullName);
+        return (new File(fullName)).getAbsolutePath();
+    }
+
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
new file mode 100644
index 0000000..a219d2d
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/GatewayMain.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.samples.porter.gateway;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class GatewayMain {
+    public static void main(String[] args) throws Exception {
+        BeanUtils.init();
+    }
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java
new file mode 100644
index 0000000..0b181d8
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/InternalAccessHandler.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.samples.porter.gateway;
+
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+
+public class InternalAccessHandler implements Handler {
+
+  @Override
+  public void handle(Invocation invocation, AsyncResponse asyncReponse) throws Exception {
+    if (invocation.getOperationMeta().getSwaggerOperation().getTags() != null
+        && invocation.getOperationMeta().getSwaggerOperation().getTags().contains("INTERNAL")) {
+      asyncReponse.consumerFail(new InvocationException(403, "", "not allowed"));
+      return;
+    }
+    invocation.next(asyncReponse);
+  }
+
+}
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
new file mode 100644
index 0000000..791c512
--- /dev/null
+++ b/authentication/Gateway/src/main/java/org/apache/servicecomb/samples/porter/gateway/StaticWebpageDispatcher.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.samples.porter.gateway;
+
+import org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.handler.StaticHandler;
+
+public class StaticWebpageDispatcher implements VertxHttpDispatcher {
+  private static final Logger LOGGER = LoggerFactory.getLogger(StaticWebpageDispatcher.class);
+
+  private static final String WEB_ROOT = DynamicPropertyFactory.getInstance()
+      .getStringProperty("gateway.webroot", "/var/static")
+      .get();
+
+  @Override
+  public int getOrder() {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public void init(Router router) {
+    String regex = "/ui/(.*)";
+    StaticHandler webpageHandler = StaticHandler.create();
+    webpageHandler.setWebRoot(WEB_ROOT);
+    LOGGER.info("server static web page for WEB_ROOT={}", WEB_ROOT);
+    router.routeWithRegex(regex).failureHandler((context) -> {
+      LOGGER.error("", context.failure());
+    }).handler(webpageHandler);
+  }
+
+}
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
new file mode 100644
index 0000000..bada1de
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.servicecomb.samples.porter.gateway.ApiDispatcher
+org.apache.servicecomb.samples.porter.gateway.StaticWebpageDispatcher
+org.apache.servicecomb.samples.porter.gateway.CustomVertxRestDispatcher
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml b/authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml
new file mode 100644
index 0000000..b5816c3
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:context="http://www.springframework.org/schema/context"
+  xsi:schemaLocation="
+		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+
+  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
+    init-method="init"/>
+</beans>
diff --git a/authentication/Gateway/src/main/resources/config/cse.handler.xml b/authentication/Gateway/src/main/resources/config/cse.handler.xml
new file mode 100644
index 0000000..e9dd306
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/config/cse.handler.xml
@@ -0,0 +1,23 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<config>
+  <handler id="auth"
+    class="org.apache.servicecomb.samples.porter.gateway.AuthHandler" />
+  <handler id="internalAccess"
+    class="org.apache.servicecomb.samples.porter.gateway.InternalAccessHandler" />
+</config>
diff --git a/authentication/Gateway/src/main/resources/log4j2.xml b/authentication/Gateway/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..b51f28e
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./gateway/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/microservice.yaml b/authentication/Gateway/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..5b1cd91
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/microservice.yaml
@@ -0,0 +1,67 @@
+#
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 100
+
+APPLICATION_ID: authentication-application
+service_description:
+  version: 0.0.1
+  name: gateway
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9090
+
+  handler:
+    chain:
+      Consumer:
+        default: internalAccess,auth,qps-flowcontrol-consumer,loadbalance
+
+  uploads:
+    directory: tmp_for_upload_gateway
+
+  samples:
+    logdir: D:\code\servicecomb-samples\porter_lightweight\gateway-service
+    
+  inspector:
+    enabled: false
+
+  executors:
+   Provider:
+     log: servicecomb.samples.executor.groupThreadPool
+     inspector: servicecomb.samples.executor.groupThreadPool
+
+# disable all servicecomb difault dispatchers, all of them are overriden
+  http:
+    dispatcher:
+      edge:
+        default:
+          enabled: false # overriden by ApiDispatcher
+      rest:
+        eanbled: false # overriden by CustomVertxRestDispatcher
+
+# StaticWebpageDispatcher checking file exists is async, and will mark request status to ended, and VertxRestDispatcher read 
+# body will print exception. 
+#gateway.webroot: /code/servicecomb-samples/porter_lightweight/gateway-service/src/main/resources
diff --git a/authentication/Gateway/src/main/resources/ui/css/style.css b/authentication/Gateway/src/main/resources/ui/css/style.css
new file mode 100644
index 0000000..5731863
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/css/style.css
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+.error {
+    font-family:verdana;
+    color:red;
+}
+
+.header {
+    background-color:black;
+    color:white;
+    text-align:center;
+    padding:5px;
+}
+
+.nav {
+    line-height:30px;
+    background-color:#eeeeee;
+    height:300px;
+    width:100px;
+    float:left;
+    padding:5px; 
+}
+
+.section {
+    text-align:center;
+    padding:5px;
+}
+
+.footer {
+    color:red;
+    clear:both;
+    text-align:center;
+    padding:25px; 
+}
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/ui/js/jquery-1.11.1.min.js b/authentication/Gateway/src/main/resources/ui/js/jquery-1.11.1.min.js
new file mode 100644
index 0000000..ab28a24
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/js/jquery-1.11.1.min.js
@@ -0,0 +1,4 @@
+/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
+!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b [...]
+if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&& [...]
+},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.prop [...]
diff --git a/authentication/Gateway/src/main/resources/ui/js/login.js b/authentication/Gateway/src/main/resources/ui/js/login.js
new file mode 100644
index 0000000..c7e7c8e
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/js/login.js
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function loginAction() {
+     var username = document.getElementById("username").value;
+     var password = document.getElementById("paasword").value;
+     var formData = {};
+     formData.userName = username;
+     formData.password = password;
+
+     $.ajax({
+        type: 'POST',
+        url: "/api/user-service/v1/user/login",
+        data: formData,
+        success: function (data) {
+            console.log(data);
+            setCookie("session-id", data.sessiondId, 1);
+            window.location = "/ui/upload.html";
+        },
+        error: function(data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Login failed";
+            error.hidden=false;
+        },
+        async: true
+    });
+}
+
+function setCookie(name,value,days) {
+    var expires = "";
+    if (days) {
+        var date = new Date();
+        date.setTime(date.getTime() + (days*24*60*60*1000));
+        expires = "; expires=" + date.toUTCString();
+    }
+    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
+}
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/ui/js/upload.js b/authentication/Gateway/src/main/resources/ui/js/upload.js
new file mode 100644
index 0000000..7d66555
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/js/upload.js
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function uploadAction() {
+     var formData = new FormData(document.getElementById("upload_form"));
+
+     $.ajax({
+        type: 'POST',
+        url: "/api/file-service/upload",
+        data: formData,
+        processData:false,
+        contentType:false,
+        success: function (data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Upload Successfully";
+            error.hidden=false;
+        },
+        error: function(data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Upload failed";
+            error.hidden=false;
+        },
+        async: true
+    });
+}
+
+function deleteAction() {
+     var fileID = document.getElementById("fileID").value;
+     $.ajax({
+        type: 'DELETE',
+        url: "/api/file-service/delete?" + $.param({ id: fileID }),
+        data: {},
+        success: function (data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Delete successfully";
+            error.hidden=false;
+        },
+        error: function(data) {
+            console.log(data);
+            var error = document.getElementById("error");
+            error.textContent="Delete failed";
+            error.hidden=false;
+        },
+        async: true
+    });
+}
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/ui/login.html b/authentication/Gateway/src/main/resources/ui/login.html
new file mode 100644
index 0000000..c8b45fb
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/login.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<html>
+
+    <head>
+        <title>PORTER</title>
+        <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
+        <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
+        <script type="text/javascript" src="js/login.js"></script>
+    </head>
+
+    <body>
+    <div class="header">
+        <h2>Login</h2>
+    </div>
+    <div class="section">
+        <form method="POST" enctype="multipart/form-data">
+            <input id="username" type="text" placeholder="Username" required="true"/>
+            <input id="paasword" type="password" placeholder="Password" required="true"/>
+            <input type="button" value="Login" onclick="loginAction()">
+        </form>
+    </div>
+    <div class="footer">
+        <p id="error" hidden="true" class="error"/>
+    </div>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/ui/upload.html b/authentication/Gateway/src/main/resources/ui/upload.html
new file mode 100644
index 0000000..bd5eeff
--- /dev/null
+++ b/authentication/Gateway/src/main/resources/ui/upload.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<html>
+
+    <head>
+        <title>PORTER</title>
+        <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
+        <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
+        <script type="text/javascript" src="js/upload.js"></script>
+    </head>
+
+    <body>
+    <div class="header">
+        <h2>Upload</h2>
+    </div>
+    <div class="section">
+        <form id="upload_form" method="POST">
+            <p>
+                File Name: <input type="file" name="fileName"/>
+            </p>
+            <p>
+                <input type="button" value="Upload" onclick="uploadAction()">
+            </p>
+        </form>
+    </div>
+
+    <div class="header">
+        <h2>Delete file</h2>
+    </div>
+    <div class="section">
+        <form id="delete_form" method="DELETE">
+            <p>
+                File ID: <input id="fileID" type="text"/>
+            </p>
+            <p>
+                <input type="button" value="Delete" onclick="deleteAction()">
+            </p>
+        </form>
+    </div>
+    <div class="footer">
+        <p id="error" hidden="true" class="error"/>
+    </div>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/authentication/README.md b/authentication/README.md
new file mode 100644
index 0000000..48798cd
--- /dev/null
+++ b/authentication/README.md
@@ -0,0 +1,26 @@
+本项目提供认证鉴权服务的实现,主要提供了基于角色的权限管理,和基于JWT的微服务授权模式。微服务的命名参考了OAuth2协议里面的命名方式。可以参考[OAuth2.0原理和验证流程分析](https://www.jianshu.com/p/d74ce6ca0c33)对于OAuth2认证过程的介绍,本项目的认证过程非常类似OAuth2的密码模式。
+
+项目的目标是提供一个商业可用的鉴权实现,对于项目代码实现的问题可以提交issue,本项目也接纳PR,共同完善。
+
+* AuthenticationServer
+
+认证鉴权服务。提供用户管理、角色管理。并提供登录认证、权限查询等接口。鉴权服务及相关API是核心交付件,也是能够被重用的部分。开发者可以基于这个项目开发认证鉴权服务。
+
+* Gateway
+提供请求拦截,校验用户是否已经经过认证。一方面演示网关如何和配套鉴权服务完成开发,本项目也是自动化测试的组成部分。
+
+* Client
+Client模拟的是使用使用者。一方面演示客户端如何获取Token,本项目也是自动化测试的组成部分。
+
+* ResourceServer
+ResourceServer模拟的是业务服务。一方面演示业务服务如何进行权限配置,本项目也是自动化测试的组成部分。
+
+
+## 实现说明
+
+* 用户管理
+用户管理采用了org.springframework.security.core.userdetails的模型,包括:
+  1. UserDetailsService:加载用户信息。
+  2. UserDetails:用户信息。
+  3. GrantedAuthority:角色信息。
+  4. PasswordEncoder:用户密码加密和匹配。
\ No newline at end of file
diff --git a/authentication/ResourceServer/pom.xml b/authentication/ResourceServer/pom.xml
new file mode 100644
index 0000000..52aea79
--- /dev/null
+++ b/authentication/ResourceServer/pom.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ~ Licensed to the Apache Software Foundation (ASF) under one or more 
+  ~ contributor license agreements. See the NOTICE file distributed with ~ 
+  this work for additional information regarding copyright ownership. ~ The 
+  ASF licenses this file to You under the Apache License, Version 2.0 ~ (the 
+  "License"); you may not use this file except in compliance with ~ the License. 
+  You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 
+  ~ ~ Unless required by applicable law or agreed to in writing, software ~ 
+  distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT 
+  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the 
+  License for the specific language governing permissions and ~ limitations 
+  under the License. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.authentication</groupId>
+  <artifactId>resource-server</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis</artifactId>
+        <version>3.4.5</version>
+      </dependency>
+      <dependency>
+        <groupId>org.mybatis</groupId>
+        <artifactId>mybatis-spring</artifactId>
+        <version>1.3.0</version>
+      </dependency>
+      <dependency>
+        <groupId>mysql</groupId>
+        <artifactId>mysql-connector-java</artifactId>
+        <version>5.1.46</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>1.2.0</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-dbcp2</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis-spring</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-jdbc</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context-support</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-tx</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.1.2.RELEASE</version>
+          <executions>
+            <execution>
+              <goals>
+                <goal>repackage</goal>
+              </goals>
+              <configuration>
+                <mainClass>${main.class}</mainClass>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServer.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServer.java
new file mode 100644
index 0000000..f2653ab
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServer.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class ResourceServer {
+  public static void main(String[] args) {
+    try {
+      BeanUtils.init();
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java
new file mode 100644
index 0000000..4b6a5b6
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication.resource;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.multipart.MultipartFile;
+
+@RestSchema(schemaId = "FileEndpoint")
+@RequestMapping(path = "/v1/file")
+public class FileEndpoint {
+    @Autowired
+    private FileStoreService fileService;
+
+    @PostMapping(path = "/upload", produces = MediaType.TEXT_PLAIN_VALUE)
+    public String uploadFile(@RequestPart(name = "fileName") MultipartFile file) {
+        return fileService.uploadFile(file);
+    }
+
+    @DeleteMapping(path = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
+    public boolean deleteFile(@RequestParam(name = "id") String id) {
+        return fileService.deleteFile(id);
+    }
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java
new file mode 100644
index 0000000..ed03665
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication.resource;
+
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * file storage service, can implement using file system, OBS, etc.
+ */
+public interface FileStoreService {
+
+    public String uploadFile(MultipartFile file);
+
+    public boolean deleteFile(String id);
+
+}
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java
new file mode 100644
index 0000000..d487144
--- /dev/null
+++ b/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication.resource;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.UUID;
+
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ *  Simple file storage implementation.
+ *  Caution: file check and other security constraints not implemented. 
+ */
+@Component
+public class LocalFileStoreService implements FileStoreService {
+    // maxmum BUFFER_SIZE * BUFFER_NUM
+    private static final int BUFFER_SIZE = 10240;
+
+    private static final File BASE_FILE = new File(".");
+
+    @Override
+    public String uploadFile(MultipartFile file) {
+        byte[] buffer = new byte[BUFFER_SIZE];
+        String fileId = UUID.randomUUID().toString();
+
+        File outFile = new File(BASE_FILE, fileId);
+        int len;
+        try (InputStream is = file.getInputStream(); OutputStream os = new FileOutputStream(outFile)) {
+            while ((len = is.read(buffer)) != -1) {
+                os.write(buffer, 0, len);
+            }
+        } catch (IOException e) {
+            return null;
+        }
+        return fileId;
+    }
+
+    @Override
+    public boolean deleteFile(String id) {
+        File outFile = new File(BASE_FILE, id);
+        return outFile.delete();
+    }
+
+}
diff --git a/authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml b/authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml
new file mode 100644
index 0000000..661608f
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/META-INF/spring/user.bean.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+    xmlns:util="http://www.springframework.org/schema/util"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:tx="http://www.springframework.org/schema/tx"
+    xsi:schemaLocation="
+		http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
+    init-method="init"/>
+    
+    <bean id="dataSource"
+        class="org.apache.commons.dbcp2.BasicDataSource"
+        destroy-method="close">
+        <property name="driverClassName" value="${db.driverClassName:com.mysql.jdbc.Driver}" />
+        <property name="url"
+            value="${db.url:jdbc:mysql://localhost/porter_user_db}" />
+        <property name="username" value="${db.username:root}" />
+        <property name="password" value="${db.password:}" />
+    </bean>
+
+    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+        <property name="dataSource" ref="dataSource" />
+        <property name="configLocation" value="classpath:/config/mybatis-config.xml"></property>
+    </bean>
+
+    <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.UserMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+    <bean id="sessionMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
+        <property name="mapperInterface"
+            value="org.apache.servicecomb.samples.porter.user.dao.SessionMapper" />
+        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
+    </bean>
+</beans>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml b/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml
new file mode 100644
index 0000000..989e786
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/config/SessionMapper.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.SessionMapper">
+    <resultMap id="sessionInfo" type="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="SESSION_ID" jdbcType="VARCHAR" property="sessiondId" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+        <result column="CREATION_TIME" jdbcType="TIMESTAMP" property="creationTime" />
+        <result column="ACTIVE_TIME" jdbcType="TIMESTAMP" property="activeTime" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, SESSION_ID, USER_NAME, ROLE_NAME, CREATION_TIME, ACTIVE_TIME
+    </sql>
+
+    <sql id="all_column_auto">
+        SESSION_ID, USER_NAME, ROLE_NAME
+    </sql>
+
+    <insert id="createSession" parameterType="org.apache.servicecomb.samples.porter.user.dao.SessionInfoModel">
+        insert into T_SESSION (
+        <include refid="all_column_auto" />
+        )
+        values (#{sessiondId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
+        #{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getSessioinInfo" parameterType="java.lang.String"
+        resultMap="sessionInfo">
+        select
+        <include refid="all_column" />
+        from T_SESSION where SESSION_ID = #{0,jdbcType=VARCHAR}
+    </select>
+    
+    <update id="updateSessionInfo" parameterType="java.lang.String">
+        update T_SESSION
+        set CREATION_TIME = CREATION_TIME where SESSION_ID = #{0,jdbcType=VARCHAR};
+    </update>
+</mapper>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/UserMapper.xml b/authentication/ResourceServer/src/main/resources/config/UserMapper.xml
new file mode 100644
index 0000000..c02e60d
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/config/UserMapper.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.servicecomb.samples.porter.user.dao.UserMapper">
+    <resultMap id="userInfo" type="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        <result column="ID" jdbcType="INTEGER" property="id" />
+        <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
+        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
+        <result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
+    </resultMap>
+
+    <sql id="all_column">
+        ID, USER_NAME, PASSWORD, ROLE_NAME
+    </sql>
+
+    <insert id="createUser" parameterType="org.apache.servicecomb.samples.porter.user.dao.UserInfo">
+        insert into T_USER (
+        <include refid="all_column" />
+        )
+        values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR},
+        #{password,jdbcType=VARCHAR},#{roleName,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="getUserInfo" parameterType="java.lang.String"
+        resultMap="userInfo">
+        select
+        <include refid="all_column" />
+        from T_USER where USER_NAME = #{0,jdbcType=VARCHAR}
+    </select>
+</mapper>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/config/create_db_user.sql b/authentication/ResourceServer/src/main/resources/config/create_db_user.sql
new file mode 100644
index 0000000..a07c5d9
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/config/create_db_user.sql
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+CREATE DATABASE IF NOT EXISTS porter_user_db;
+
+USE porter_user_db;
+
+DROP TABLE IF EXISTS T_USER;
+
+CREATE TABLE `T_USER` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'user id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `PASSWORD`  VARCHAR(64) NOT NULL COMMENT 'user password',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  PRIMARY KEY (`ID`)
+);
+
+#### password is encrypted for test
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("admin", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "admin");
+insert into T_USER(USER_NAME, PASSWORD, ROLE_NAME) values("guest", "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "guest");
+
+DROP TABLE IF EXISTS T_SESSION;
+
+CREATE TABLE `T_SESSION` (
+  `ID`  INTEGER(8) NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `SESSION_ID`  VARCHAR(64) NOT NULL COMMENT 'session id',
+  `USER_NAME`  VARCHAR(64) NOT NULL COMMENT 'user name',
+  `ROLE_NAME`  VARCHAR(64) NOT NULL COMMENT 'user role',
+  `CREATION_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time',
+  `ACTIVE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last active time',
+  PRIMARY KEY (`ID`)
+);
diff --git a/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml b/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml
new file mode 100644
index 0000000..894caac
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/config/mybatis-config.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE configuration
+  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+  "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <mappers>
+        <mapper resource="config/UserMapper.xml"/>
+        <mapper resource="config/SessionMapper.xml"/>
+    </mappers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/log4j2.xml b/authentication/ResourceServer/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..3c70391
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./user/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/microservice.yaml b/authentication/ResourceServer/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..47b05c1
--- /dev/null
+++ b/authentication/ResourceServer/src/main/resources/microservice.yaml
@@ -0,0 +1,35 @@
+#
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+# override common configurations in common module
+servicecomb-config-order: 100
+
+APPLICATION_ID: authentication-application
+service_description:
+  version: 0.0.1
+  name: resource-server
+
+servicecomb:
+  service:
+    registry:
+      address: http://localhost:30100
+      instance:
+        watch: false
+
+  rest:
+    address: 0.0.0.0:9092
diff --git a/authentication/api/AuthenticationServer/endpoint/pom.xml b/authentication/api/AuthenticationServer/endpoint/pom.xml
new file mode 100644
index 0000000..5eebece
--- /dev/null
+++ b/authentication/api/AuthenticationServer/endpoint/pom.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-server-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-server-api-endpoint</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-server-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
new file mode 100644
index 0000000..dfc9c51
--- /dev/null
+++ b/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication.api;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "AuthenticationEndpoint")
+@RequestMapping(path = "/v1/auth/login")
+public class AuthenticationEndpoint {
+  @Autowired
+  private AuthenticationService authenticationService;
+
+  public Token login(@RequestParam(name = "userName") String userName,
+      @RequestParam(name = "password") String password) {
+    return authenticationService.login(userName, password);
+  }
+
+  public Token refresh(@RequestParam(name = "refreshToken") String refreshToken) {
+    return authenticationService.refresh(refreshToken);
+  }
+}
diff --git a/authentication/api/AuthenticationServer/pom.xml b/authentication/api/AuthenticationServer/pom.xml
new file mode 100644
index 0000000..946a2fb
--- /dev/null
+++ b/authentication/api/AuthenticationServer/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-server-api</artifactId>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>service</module>
+    <module>endpoint</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/authentication/api/AuthenticationServer/service/pom.xml b/authentication/api/AuthenticationServer/service/pom.xml
new file mode 100644
index 0000000..4433ff6
--- /dev/null
+++ b/authentication/api/AuthenticationServer/service/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-server-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-server-api-service</artifactId>
+  <packaging>jar</packaging>
+
+</project>
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
new file mode 100644
index 0000000..77635ad
--- /dev/null
+++ b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication.api;
+
+public interface AuthenticationService {
+  /**
+   * login using user name and password.
+   * @param userName user name
+   * @param password password
+   * @return After successfully login, token is created. Or null is returned. 
+   */
+  Token login(String userName, String password);
+
+  /**
+   * acquired new token using refresh token.
+   * @param refreshToken refresh token
+   * @return After successfully authenticated, token is created. Or null is returned. 
+   */
+  Token refresh(String refreshToken);
+}
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
new file mode 100644
index 0000000..732fe22
--- /dev/null
+++ b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication.api;
+
+public class Token {
+  private String accessToken;
+
+  private String refreshToken;
+
+  public String getAccessToken() {
+    return accessToken;
+  }
+
+  public void setAccessToken(String accessToken) {
+    this.accessToken = accessToken;
+  }
+
+  public String getRefreshToken() {
+    return refreshToken;
+  }
+
+  public void setRefreshToken(String refreshToken) {
+    this.refreshToken = refreshToken;
+  }
+}
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
new file mode 100644
index 0000000..54c2175
--- /dev/null
+++ b/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Tokens.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.authentication.api;
+
+/**
+ * 
+ * After successfully login, tokens are created. </br>
+ * <B>Access Token:</B> used to access resources.</br>
+ * <B>Refresh Token:</B> used to acquire new tokens.</br>
+ *
+ */
+public class Tokens {
+  private String accessToken;
+
+  private String refreshToken;
+
+  public String getAccessToken() {
+    return accessToken;
+  }
+
+  public void setAccessToken(String accessToken) {
+    this.accessToken = accessToken;
+  }
+
+  public String getRefreshToken() {
+    return refreshToken;
+  }
+
+  public void setRefreshToken(String refreshToken) {
+    this.refreshToken = refreshToken;
+  }
+
+}
diff --git a/authentication/api/common/endpoint/pom.xml b/authentication/api/common/endpoint/pom.xml
new file mode 100644
index 0000000..de2736a
--- /dev/null
+++ b/authentication/api/common/endpoint/pom.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-common-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-common-api-endpoint</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-common-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java b/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java
new file mode 100644
index 0000000..731f6ac
--- /dev/null
+++ b/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.samples.porter.file.api;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.util.Collection;
+import java.util.Map.Entry;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import javax.servlet.http.Part;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.Status;
+
+import org.apache.servicecomb.common.rest.resource.ClassPathStaticResourceHandler;
+import org.apache.servicecomb.common.rest.resource.StaticResourceHandler;
+import org.apache.servicecomb.config.inject.ConfigObjectFactory;
+import org.apache.servicecomb.foundation.common.part.InputStreamPart;
+import org.apache.servicecomb.inspector.internal.InspectorConfig;
+import org.apache.servicecomb.inspector.internal.swagger.AppendStyleProcessor;
+import org.apache.servicecomb.inspector.internal.swagger.SchemaFormat;
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.serviceregistry.RegistryUtils;
+import org.apache.servicecomb.swagger.SwaggerUtils;
+import org.apache.servicecomb.swagger.invocation.Response;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.asciidoctor.Asciidoctor;
+import org.asciidoctor.Asciidoctor.Factory;
+import org.asciidoctor.Attributes;
+import org.asciidoctor.AttributesBuilder;
+import org.asciidoctor.OptionsBuilder;
+import org.asciidoctor.SafeMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Ordering;
+
+import io.github.swagger2markup.Swagger2MarkupConfig;
+import io.github.swagger2markup.Swagger2MarkupConverter;
+import io.github.swagger2markup.Swagger2MarkupConverter.Builder;
+import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.models.parameters.Parameter;
+
+// copied from org.apache.servicecomb.inspector.internal.InspectorImpl;
+@RestSchema(schemaId = "inspector")
+@Path("/inspector")
+public class InspectorEndpoint {
+  private static final Logger LOGGER = LoggerFactory.getLogger(InspectorEndpoint.class);
+
+  private InspectorConfig inspectorConfig;
+
+  private volatile Asciidoctor asciidoctor;
+
+  private StaticResourceHandler resourceHandler = new ClassPathStaticResourceHandler();
+
+  public InspectorEndpoint() {
+    this.inspectorConfig = new ConfigObjectFactory().create(InspectorConfig.class);
+  }
+
+  @Path("/schemas")
+  @GET
+  public Collection<String> getSchemaIds() {
+    return RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().keySet();
+  }
+
+  @Path("/download/schemas")
+  @GET
+  @ApiResponse(code = 200, message = "", response = File.class)
+  public Response downloadSchemas(@QueryParam("format") SchemaFormat format) {
+    if (format == null) {
+      format = SchemaFormat.SWAGGER;
+    }
+
+    // normally, schema will not be too big, just save them in memory temporarily
+    ByteArrayOutputStream os = new ByteArrayOutputStream();
+    try (ZipOutputStream zos = new ZipOutputStream(os)) {
+      for (Entry<String, String> entry : RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().entrySet()) {
+        // begin writing a new ZIP entry, positions the stream to the start of the entry data
+        zos.putNextEntry(new ZipEntry(entry.getKey() + format.getSuffix()));
+
+        String content = entry.getValue();
+        if (SchemaFormat.HTML.equals(format)) {
+          content = swaggerToHtml(content);
+        }
+        zos.write(content.getBytes(StandardCharsets.UTF_8));
+        zos.closeEntry();
+      }
+    } catch (Throwable e) {
+      String msg = "failed to create schemas zip file, format=" + format + ".";
+      LOGGER.error(msg, e);
+      return Response.failResp(new InvocationException(Status.INTERNAL_SERVER_ERROR, msg));
+    }
+
+    Part part = new InputStreamPart(null, new ByteArrayInputStream(os.toByteArray()))
+        .setSubmittedFileName(RegistryUtils.getMicroservice().getServiceName() + format.getSuffix() + ".zip");
+    return Response.ok(part);
+  }
+
+  @Path("/schemas/{schemaId}")
+  @GET
+  @ApiResponse(code = 200, message = "", response = File.class)
+  public Response getSchemaContentById(@PathParam("schemaId") String schemaId,
+      @QueryParam("format") SchemaFormat format, @QueryParam("download") boolean download) {
+    String swaggerContent = RegistryUtils.getServiceRegistry().getMicroservice().getSchemaMap().get(schemaId);
+    if (swaggerContent == null) {
+      return Response.failResp(new InvocationException(Status.NOT_FOUND, Status.NOT_FOUND.getReasonPhrase()));
+    }
+
+    if (format == null) {
+      format = SchemaFormat.SWAGGER;
+    }
+
+    byte[] bytes;
+    if (SchemaFormat.HTML.equals(format)) {
+      String html = swaggerToHtml(swaggerContent);
+      bytes = html.getBytes(StandardCharsets.UTF_8);
+    } else {
+      bytes = swaggerContent.getBytes(StandardCharsets.UTF_8);
+    }
+
+    Part part = new InputStreamPart(null, new ByteArrayInputStream(bytes))
+        .setSubmittedFileName(schemaId + format.getSuffix());
+
+    Response response = Response.ok(part);
+    if (!download) {
+      response.getHeaders().addHeader(HttpHeaders.CONTENT_DISPOSITION, "inline");
+    }
+    response.getHeaders().addHeader(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML);
+    return response;
+  }
+
+  // swagger not support cookie parameter
+  // so if swaggerContent contains cookie parameter, will cause problem.
+  private String swaggerToHtml(String swaggerContent) {
+    if (asciidoctor == null) {
+      synchronized (this) {
+        if (asciidoctor == null) {
+          // very slow, need a few seconds
+          LOGGER.info("create AsciiDoctor start.");
+          asciidoctor = Factory.create();
+          asciidoctor.javaExtensionRegistry().docinfoProcessor(AppendStyleProcessor.class);
+          LOGGER.info("create AsciiDoctor end.");
+        }
+      }
+    }
+
+    // swagger to markup
+    Builder markupBuilder = Swagger2MarkupConverter.from(SwaggerUtils.parseSwagger(swaggerContent));
+    // default not support cookie parameter
+    // so must customize config
+    Swagger2MarkupConfig markupConfig = new Swagger2MarkupConfigBuilder()
+        .withParameterOrdering(Ordering
+            .explicit("path", "query", "header", "cookie", "formData", "body")
+            .onResultOf(Parameter::getIn))
+        .build();
+    String markup = markupBuilder.withConfig(markupConfig).build().toString();
+
+    // markup to html
+    OptionsBuilder builder = OptionsBuilder.options();
+    builder.docType("book")
+        .backend("html5")
+        .headerFooter(true)
+        .safe(SafeMode.UNSAFE)
+        .attributes(AttributesBuilder.attributes()
+            .attribute("toclevels", 3)
+            .attribute(Attributes.TOC_2, true)
+            .attribute(Attributes.TOC_POSITION, "left")
+            .attribute(Attributes.LINK_CSS, true)
+            .attribute(Attributes.STYLESHEET_NAME, inspectorConfig.getAsciidoctorCss())
+            .attribute(Attributes.SECTION_NUMBERS, true)
+            .attribute(Attributes.SECT_NUM_LEVELS, 4));
+    return asciidoctor.convert(markup, builder.asMap());
+  }
+
+  @Path("/{path : .+}")
+  @GET
+  @ApiResponse(code = 200, message = "", response = File.class)
+  public Response getStaticResource(@PathParam("path") String path) {
+    return resourceHandler.handle(path);
+  }
+}
+
diff --git a/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java b/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java
new file mode 100644
index 0000000..8e49a6e
--- /dev/null
+++ b/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.samples.porter.file.api;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.samples.porter.common.api.LogService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+@RestSchema(schemaId = "log")
+@RequestMapping(path = "/v1/log")
+public class LogEndpoint implements LogService {
+  // protect your file in real applications
+  private static final File LOG_DIR =
+      new File(DynamicPropertyFactory.getInstance().getStringProperty("servicecomb.samples.logdir", ".").get());
+
+  private static final String FILE_POST_FIX = ".log";
+
+  @Override
+  @GetMapping(path = "/getLogFileList")
+  public List<String> getLogFileList() {
+    File[] files = LOG_DIR.listFiles(new FileFilter() {
+      @Override
+      public boolean accept(File file) {
+        return isLogFile(file);
+      }
+    });
+
+    List<String> result = new ArrayList<>(files.length);
+    for (int i = 0; i < files.length; i++) {
+      result.add(files[i].getName());
+    }
+    return result;
+  }
+
+  @Override
+  @GetMapping(path = "/getLogFileContent")
+  public File getLogFileContent(@RequestParam(name = "fileName") String fileName) {
+    File file = new File(LOG_DIR, fileName);
+    if (isLogFile(file)) {
+      return file;
+    }
+    return null;
+  }
+
+  private boolean isLogFile(File file) {
+    return file.isFile() && file.canRead() && file.getName().endsWith(FILE_POST_FIX);
+  }
+}
diff --git a/authentication/api/common/pom.xml b/authentication/api/common/pom.xml
new file mode 100644
index 0000000..b4a9fbc
--- /dev/null
+++ b/authentication/api/common/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-common-api</artifactId>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>service</module>
+    <module>endpoint</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/authentication/api/common/service/pom.xml b/authentication/api/common/service/pom.xml
new file mode 100644
index 0000000..538be70
--- /dev/null
+++ b/authentication/api/common/service/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-common-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-common-api-service</artifactId>
+  <packaging>jar</packaging>
+
+</project>
diff --git a/authentication/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java b/authentication/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java
new file mode 100644
index 0000000..9991543
--- /dev/null
+++ b/authentication/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.samples.porter.common.api;
+
+import java.io.File;
+import java.util.List;
+
+public interface LogService {
+  List<String> getLogFileList();
+  File getLogFileContent(String fileName);
+}
diff --git a/authentication/api/pom.xml b/authentication/api/pom.xml
new file mode 100644
index 0000000..cdc3926
--- /dev/null
+++ b/authentication/api/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.servicecomb.authentication</groupId>
+  <artifactId>authentication-api</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <modules>
+    <module>common</module>
+    <module>AuthenticationServer</module>
+  </modules>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>1.2.0</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>solution-basic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-maven-plugin</artifactId>
+          <version>2.1.2.RELEASE</version>
+          <executions>
+            <execution>
+              <goals>
+                <goal>repackage</goal>
+              </goals>
+              <configuration>
+                <mainClass>${main.class}</mainClass>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
\ No newline at end of file