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/20 13:28:43 UTC

[servicecomb-samples] branch master updated (8e5bdc9 -> db88215)

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 8e5bdc9  add project index
     new 161f796  refract project structures
     new ab23af1  provide default authentication service implementation
     new db88215  using oauth 2 password mode to grant tokens

The 3 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:
 .../service/AuthenticationServiceImpl.java         |  75 --------
 .../main/resources/META-INF/spring/user.bean.xml   |  24 ---
 .../gateway/AuthenticationEndpoint.java            |  44 -----
 .../main/resources/META-INF/spring/cse.bean.xml    |  27 ---
 authentication/README.md                           |   4 +-
 .../resources/META-INF/spring/resource.bean.xml    |  30 ---
 .../authentication/api/AuthenticationEndpoint.java |  42 -----
 .../authentication/api/AuthenticationService.java  |  35 ----
 .../endpoint/pom.xml                               |   5 +
 .../authentication/server/TokenEndpoint.java       |  94 ++++++++++
 .../pom.xml                                        |   0
 .../service/pom.xml                                |   0
 .../servicecomb/authentication/server}/Token.java  |   2 +-
 .../authentication/server/TokenConst.java}         |  12 +-
 .../authentication/server/TokenService.java}       |  10 +-
 .../samples/porter/file/api/InspectorEndpoint.java | 206 ---------------------
 .../samples/porter/file/api/LogEndpoint.java       |  72 -------
 authentication/api/edge-service/endpoint/pom.xml   |  38 ++++
 .../{AuthenticationServer => edge-service}/pom.xml |   2 +-
 authentication/api/edge-service/service/pom.xml    |  42 +++++
 .../authentication/edge}/AuthHandler.java          |   2 +-
 .../authentication/edge}/AuthenticationFilter.java |   2 +-
 .../edge}/CustomVertxRestDispatcher.java           |   3 +-
 .../edge}/InternalAccessHandler.java               |   2 +-
 ...servicecomb.common.rest.filter.HttpServerFilter |   2 +-
 ...ecomb.transport.rest.vertx.VertxHttpDispatcher} |   2 +-
 .../src/main/resources/config/cse.handler.xml      |   4 +-
 authentication/api/pom.xml                         |   4 +-
 .../endpoint/pom.xml                               |   6 +-
 .../pom.xml                                        |   2 +-
 authentication/api/resource-server/service/pom.xml |  42 +++++
 .../resource/AccessConfiguration.java              |   0
 .../resource/AccessConfigurationManager.java       |   0
 ...eptionExceptionToProducerResponseConverter.java |   0
 .../resource/ResourceAuthHandler.java              |   0
 .../resource/SimpleAuthentication.java             |   0
 ....exception.ExceptionToProducerResponseConverter |   0
 .../src/main/resources/config/cse.handler.xml      |   0
 .../{ => samples}/AuthenticationServer/pom.xml     |   8 +-
 .../AuthenticationConfiguration.java               |   0
 .../authentication/AuthenticationServerMain.java   |   0
 .../src/main/resources/log4j2.xml                  |   0
 .../src/main/resources/microservice.yaml           |   0
 authentication/{ => samples}/Client/pom.xml        |   9 +-
 .../authentication/AuthenticationClientMain.java   |   0
 .../authentication/AuthenticationTestCase.java     |  12 +-
 .../authentication/BootEventListener.java          |  12 +-
 .../authentication/GateRestTemplate.java           |   0
 .../authentication/ITUriTemplateHandler.java       |   0
 .../servicecomb/authentication/TestCase.java       |   0
 .../servicecomb/authentication/TestEndpoint.java   |   0
 .../apache/servicecomb/authentication/TestMgr.java |   0
 .../Client/src/main/resources/log4j2.xml           |   0
 .../Client/src/main/resources/microservice.yaml    |   0
 .../{Gateway => samples/EdgeService}/pom.xml       |  15 +-
 .../authentication/gateway/ApiDispatcher.java      |   1 +
 .../gateway/AuthenticationConfiguration.java       |   0
 .../gateway/AuthenticationEdgeMain.java}           |   2 +-
 .../authentication/gateway/EdgeSSLCustom.java      |   0
 .../gateway/StaticWebpageDispatcher.java           |   0
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |   3 +-
 .../EdgeService}/src/main/resources/log4j2.xml     |   0
 .../src/main/resources/microservice.yaml           |   2 +-
 .../src/main/resources/ui/css/style.css            |   0
 .../src/main/resources/ui/js/jquery-1.11.1.min.js  |   0
 .../EdgeService}/src/main/resources/ui/js/login.js |   0
 .../src/main/resources/ui/js/upload.js             |   0
 .../EdgeService}/src/main/resources/ui/login.html  |   0
 .../EdgeService}/src/main/resources/ui/upload.html |   0
 .../authentication/test/PatternTest.java           |   0
 .../{ => samples}/ResourceServer/pom.xml           |  22 +--
 .../resource/AuthenticationConfiguration.java      |   0
 .../authentication/resource/FileEndpoint.java      |   0
 .../authentication/resource/FileStoreService.java  |   0
 .../resource/HandlerAuthEndpoint.java              |   0
 .../resource/LocalFileStoreService.java            |   0
 .../resource/MethodSecurityConfiguration.java      |   0
 .../resource/PreMethodAuthEndpoint.java            |   0
 .../resource}/ResourceServerMain.java              |   2 +-
 .../ResourceServer}/src/main/resources/log4j2.xml  |   0
 .../src/main/resources/microservice.yaml           |   0
 authentication/{api => samples}/pom.xml            |   6 +-
 82 files changed, 307 insertions(+), 622 deletions(-)
 delete mode 100644 authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
 delete mode 100644 authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
 delete mode 100644 authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java
 delete mode 100644 authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml
 delete mode 100644 authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml
 delete mode 100644 authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
 delete mode 100644 authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
 copy authentication/api/{AuthenticationServer => authentication-server}/endpoint/pom.xml (88%)
 create mode 100644 authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenEndpoint.java
 copy authentication/api/{AuthenticationServer => authentication-server}/pom.xml (100%)
 rename authentication/api/{AuthenticationServer => authentication-server}/service/pom.xml (100%)
 rename authentication/api/{AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api => authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server}/Token.java (97%)
 copy authentication/api/{common/service/src/main/java/org/apache/servicecomb/authentication/util/Constants.java => authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java} (71%)
 rename authentication/api/{common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java => authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenService.java} (79%)
 delete mode 100644 authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java
 delete mode 100644 authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java
 create mode 100644 authentication/api/edge-service/endpoint/pom.xml
 copy authentication/api/{AuthenticationServer => edge-service}/pom.xml (95%)
 create mode 100644 authentication/api/edge-service/service/pom.xml
 rename authentication/{Gateway/src/main/java/org/apache/servicecomb/authentication/gateway => api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge}/AuthHandler.java (97%)
 rename authentication/{Gateway/src/main/java/org/apache/servicecomb/authentication/gateway => api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge}/AuthenticationFilter.java (96%)
 rename authentication/{Gateway/src/main/java/org/apache/servicecomb/authentication/gateway => api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge}/CustomVertxRestDispatcher.java (98%)
 rename authentication/{Gateway/src/main/java/org/apache/servicecomb/authentication/gateway => api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge}/InternalAccessHandler.java (96%)
 copy authentication/{Gateway => api/edge-service/service}/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter (92%)
 rename authentication/{Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter => api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher} (91%)
 rename authentication/{Gateway => api/edge-service/service}/src/main/resources/config/cse.handler.xml (85%)
 rename authentication/api/{AuthenticationServer => resource-server}/endpoint/pom.xml (88%)
 rename authentication/api/{AuthenticationServer => resource-server}/pom.xml (95%)
 create mode 100644 authentication/api/resource-server/service/pom.xml
 rename authentication/{ResourceServer => api/resource-server/service}/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java (100%)
 rename authentication/{ResourceServer => api/resource-server/service}/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java (100%)
 rename authentication/{ResourceServer => api/resource-server/service}/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java (100%)
 rename authentication/{ResourceServer => api/resource-server/service}/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java (100%)
 rename authentication/{ResourceServer => api/resource-server/service}/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java (100%)
 rename authentication/{ResourceServer => api/resource-server/service}/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter (100%)
 rename authentication/{ResourceServer => api/resource-server/service}/src/main/resources/config/cse.handler.xml (100%)
 rename authentication/{ => samples}/AuthenticationServer/pom.xml (96%)
 rename authentication/{ => samples}/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java (100%)
 rename authentication/{ => samples}/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java (100%)
 rename authentication/{ResourceServer => samples/AuthenticationServer}/src/main/resources/log4j2.xml (100%)
 rename authentication/{ => samples}/AuthenticationServer/src/main/resources/microservice.yaml (100%)
 rename authentication/{ => samples}/Client/pom.xml (96%)
 rename authentication/{ => samples}/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java (100%)
 rename authentication/{ => samples}/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java (92%)
 rename authentication/{ => samples}/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java (72%)
 rename authentication/{ => samples}/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java (100%)
 rename authentication/{ => samples}/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java (100%)
 rename authentication/{ => samples}/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java (100%)
 rename authentication/{ => samples}/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java (100%)
 rename authentication/{ => samples}/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java (100%)
 rename authentication/{ => samples}/Client/src/main/resources/log4j2.xml (100%)
 rename authentication/{ => samples}/Client/src/main/resources/microservice.yaml (100%)
 rename authentication/{Gateway => samples/EdgeService}/pom.xml (90%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java (98%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java (100%)
 rename authentication/{Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationGatewayMain.java => samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEdgeMain.java} (96%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java (100%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java (100%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher (92%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/resources/log4j2.xml (100%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/resources/microservice.yaml (99%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/resources/ui/css/style.css (100%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/resources/ui/js/jquery-1.11.1.min.js (100%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/resources/ui/js/login.js (100%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/resources/ui/js/upload.js (100%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/resources/ui/login.html (100%)
 rename authentication/{Gateway => samples/EdgeService}/src/main/resources/ui/upload.html (100%)
 rename authentication/{Gateway => samples/EdgeService}/test/org/apache/servicecomb/authentication/test/PatternTest.java (100%)
 rename authentication/{ => samples}/ResourceServer/pom.xml (88%)
 rename authentication/{ => samples}/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java (100%)
 rename authentication/{ => samples}/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java (100%)
 rename authentication/{ => samples}/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java (100%)
 rename authentication/{ => samples}/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java (100%)
 rename authentication/{ => samples}/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java (100%)
 rename authentication/{ => samples}/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.java (100%)
 rename authentication/{ => samples}/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java (100%)
 rename authentication/{ResourceServer/src/main/java/org/apache/servicecomb/authentication => samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource}/ResourceServerMain.java (94%)
 rename authentication/{AuthenticationServer => samples/ResourceServer}/src/main/resources/log4j2.xml (100%)
 rename authentication/{ => samples}/ResourceServer/src/main/resources/microservice.yaml (100%)
 copy authentication/{api => samples}/pom.xml (94%)


[servicecomb-samples] 03/03: using oauth 2 password mode to grant tokens

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 db8821565eb92ad727d0cc0076d231fa7c87d4ce
Author: liubao <ba...@huawei.com>
AuthorDate: Fri May 17 17:12:32 2019 +0800

    using oauth 2 password mode to grant tokens
---
 authentication/README.md                           |  4 +-
 .../TokenEndpoint.java}                            | 68 +++++++++++++---------
 .../authentication/{api => server}/Token.java      |  2 +-
 .../TokenConst.java}                               | 23 +++-----
 .../TokenService.java}                             | 19 ++----
 .../edge/AuthenticationEndpoint.java               | 44 --------------
 .../edge/CustomVertxRestDispatcher.java            |  1 +
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |  2 +-
 .../authentication/AuthenticationTestCase.java     | 12 ++--
 .../authentication/BootEventListener.java          | 12 ++--
 .../authentication/gateway/ApiDispatcher.java      |  1 +
 .../src/main/resources/microservice.yaml           |  2 +-
 12 files changed, 74 insertions(+), 116 deletions(-)

diff --git a/authentication/README.md b/authentication/README.md
index 2274bb4..6d477bb 100644
--- a/authentication/README.md
+++ b/authentication/README.md
@@ -87,4 +87,6 @@ http://localhost:9093/v1/test/start
 
 测试项目同时展示了这个项目的功能,比如: AuthenticationTestCase 的测试逻辑展示了基本的认证功能,从登陆,到接口的权限检查。 
 
-
+# TODO LIST
+1. provide TLS for authentication server & edge service
+2. grant scope for INTERNAL access & EXTERNAL access 
diff --git a/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenEndpoint.java
similarity index 51%
rename from authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
rename to authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenEndpoint.java
index c777bc5..67c7ba4 100644
--- a/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
+++ b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/server/TokenEndpoint.java
@@ -15,26 +15,32 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
+package org.apache.servicecomb.authentication.server;
+
+import java.util.Map;
+
+import javax.ws.rs.core.MediaType;
 
 import org.apache.servicecomb.authentication.jwt.JWTClaims;
 import org.apache.servicecomb.authentication.jwt.JsonParser;
 import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
 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.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
 
-@RestSchema(schemaId = "AuthenticationEndpoint")
-@RequestMapping(path = "/v1/auth")
-public class AuthenticationEndpoint implements AuthenticationService {
+@RestSchema(schemaId = "TokenEndpoint")
+@RequestMapping(path = "/v1/oauth/token")
+public class TokenEndpoint implements TokenService {
   @Autowired
   @Qualifier("authUserDetailsService")
   private UserDetailsService userDetailsService;
@@ -48,33 +54,41 @@ public class AuthenticationEndpoint implements AuthenticationService {
   private Signer signer;
 
   @Override
-  @PostMapping(path = "login")
-  public Token login(@RequestParam(name = "userName") String userName,
-      @RequestParam(name = "password") String password) {
-    UserDetails userDetails = userDetailsService.loadUserByUsername(userName);
-    if (passwordEncoder.matches(password, userDetails.getPassword())) {
-      JWTClaims claims = new JWTClaims();
-      if (userDetails.getAuthorities() != null) {
-        userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
-      }
-      String content = JsonParser.unparse(claims);
-      Jwt accessToken = JwtHelper.encode(content, signer);
+  @PostMapping(path = "/", consumes = MediaType.APPLICATION_FORM_URLENCODED)
+  public Token getAccessToken(@RequestBody Map<String, String> parameters) {
+    String grantType = parameters.get(TokenConst.PARAM_GRANT_TYPE);
+
+    if (TokenConst.GRANT_TYPE_PASSWORD.equals(grantType)) {
+
+      String username = parameters.get(TokenConst.PARAM_USERNAME);
+      String password = parameters.get(TokenConst.PARAM_PASSWORD);
 
-      Token token = new Token();
-      token.setScope(claims.getScope());
-      token.setExpires_in(10 * 60);
-      token.setToken_type("bearer");
-      token.setAccess_token(accessToken.getEncoded());
-      return token;
+      try {
+        UserDetails userDetails = userDetailsService.loadUserByUsername(username);
+        if (passwordEncoder.matches(password, userDetails.getPassword())) {
+          JWTClaims claims = new JWTClaims();
+          if (userDetails.getAuthorities() != null) {
+            userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
+          }
+          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());
+          return token;
+        } else {
+          return null;
+        }
+      } catch (UsernameNotFoundException e) {
+        throw new InvocationException(403, "", "forbidden");
+      }
     } else {
       return null;
     }
-  }
 
-  @Override
-  @PostMapping(path = "refresh")
-  public Token refresh(@RequestParam(name = "refreshToken") String refreshToken) {
-    return null;
   }
 
 }
diff --git a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/Token.java
similarity index 97%
rename from authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
rename to authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/Token.java
index 94ce237..8758bd1 100644
--- a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
+++ b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/Token.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
+package org.apache.servicecomb.authentication.server;
 
 import java.util.Map;
 import java.util.Set;
diff --git a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java
similarity index 59%
copy from authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
copy to authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java
index 77635ad..a46a7b9 100644
--- a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
+++ b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenConst.java
@@ -15,21 +15,14 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
+package org.apache.servicecomb.authentication.server;
 
-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);
+public class TokenConst {
+  public static final String PARAM_GRANT_TYPE = "grant_type";
 
-  /**
-   * 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);
+  public static final String PARAM_USERNAME = "username";
+
+  public static final String PARAM_PASSWORD = "password";
+  
+  public static final String GRANT_TYPE_PASSWORD = "password";
 }
diff --git a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenService.java
similarity index 59%
rename from authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
rename to authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenService.java
index 77635ad..b0cea22 100644
--- a/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
+++ b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/server/TokenService.java
@@ -15,21 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.api;
+package org.apache.servicecomb.authentication.server;
 
-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);
+import java.util.Map;
 
-  /**
-   * 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);
+public interface TokenService {
+  Token getAccessToken(Map<String, String> parameters);
 }
diff --git a/authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.java b/authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.java
deleted file mode 100644
index 68fe5d7..0000000
--- a/authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.java
+++ /dev/null
@@ -1,44 +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.
- */
-
-package org.apache.servicecomb.authentication.edge;
-
-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.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")
-public class AuthenticationEndpoint {
-  @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/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
index d1c6ef4..521b71c 100644
--- a/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
+++ b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
@@ -45,6 +45,7 @@ import io.vertx.ext.web.RoutingContext;
 import io.vertx.ext.web.handler.CookieHandler;
 
 // copied from org.apache.servicecomb.transport.rest.vertx.VertxRestDispatcher 1.2.0
+// TODO: using 1.2.2+ to make it simpler
 public class CustomVertxRestDispatcher extends AbstractVertxHttpDispatcher {
   private static final Logger LOGGER = LoggerFactory.getLogger(VertxRestDispatcher.class);
 
diff --git a/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
index 53481f1..32c1583 100644
--- a/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
+++ b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.authentication.edge.CustomVertxRestDispatcher
\ No newline at end of file
+# org.apache.servicecomb.authentication.edge.CustomVertxRestDispatcher
\ No newline at end of file
diff --git a/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
index 61ba97f..50a4519 100644
--- a/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
+++ b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
@@ -17,7 +17,7 @@
 
 package org.apache.servicecomb.authentication;
 
-import org.apache.servicecomb.authentication.api.Token;
+import org.apache.servicecomb.authentication.server.Token;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
@@ -38,13 +38,14 @@ public class AuthenticationTestCase implements TestCase {
   private void testHanlderAuth() {
     // get token
     MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
-    map.add("userName", "admin");
+    map.add("grant_type", "password");
+    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",
+        BootEventListener.authenticationServerTokenEndpoint.postForObject("/",
             new HttpEntity<>(map, headers),
             Token.class);
     TestMgr.check("bearer", token.getToken_type());
@@ -85,13 +86,14 @@ public class AuthenticationTestCase implements TestCase {
   private void testMethodAuth() {
     // get token
     MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
-    map.add("userName", "admin");
+    map.add("grant_type", "password");
+    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",
+        BootEventListener.authenticationServerTokenEndpoint.postForObject("/",
             new HttpEntity<>(map, headers),
             Token.class);
     TestMgr.check("bearer", token.getToken_type());
diff --git a/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
index 5512f8c..08d1bb3 100644
--- a/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
+++ b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
@@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
 
 @Component
 public class BootEventListener implements BootListener {
-  public static GateRestTemplate authenticationServerAuthenticationEndpoint;
+  public static GateRestTemplate authenticationServerTokenEndpoint;
   public static GateRestTemplate gateEndpoint;
   public static GateRestTemplate resouceServerHandlerAuthEndpoint;
   public static GateRestTemplate resouceServerMethodAuthEndpoint;
@@ -30,14 +30,14 @@ public class BootEventListener implements BootListener {
   @Override
   public void onBootEvent(BootEvent event) {
     if (EventType.AFTER_REGISTRY.equals(event.getEventType())) {
-      authenticationServerAuthenticationEndpoint =
-          GateRestTemplate.createEdgeRestTemplate("gateway", "authentication-server", "AuthenticationEndpoint").init();
+      authenticationServerTokenEndpoint =
+          GateRestTemplate.createEdgeRestTemplate("edge-service", "authentication-server", "TokenEndpoint").init();
       gateEndpoint =
-          GateRestTemplate.createEdgeRestTemplate("gateway", null, null).init();
+          GateRestTemplate.createEdgeRestTemplate("edge-service", null, null).init();
       resouceServerHandlerAuthEndpoint =
-          GateRestTemplate.createEdgeRestTemplate("gateway", "resource-server", "HandlerAuthEndpoint").init();
+          GateRestTemplate.createEdgeRestTemplate("edge-service", "resource-server", "HandlerAuthEndpoint").init();
       resouceServerMethodAuthEndpoint =
-          GateRestTemplate.createEdgeRestTemplate("gateway", "resource-server", "PreMethodAuthEndpoint").init();
+          GateRestTemplate.createEdgeRestTemplate("edge-service", "resource-server", "PreMethodAuthEndpoint").init();
     }
 
   }
diff --git a/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
index 9f45550..7642268 100644
--- a/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
+++ b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
@@ -27,6 +27,7 @@ import io.vertx.ext.web.Router;
 import io.vertx.ext.web.RoutingContext;
 import io.vertx.ext.web.handler.CookieHandler;
 
+//TODO: using 1.2.2+ to make it simpler
 public class ApiDispatcher extends AbstractEdgeDispatcher {
   @Override
   public int getOrder() {
diff --git a/authentication/samples/EdgeService/src/main/resources/microservice.yaml b/authentication/samples/EdgeService/src/main/resources/microservice.yaml
index 2eda242..7531d52 100644
--- a/authentication/samples/EdgeService/src/main/resources/microservice.yaml
+++ b/authentication/samples/EdgeService/src/main/resources/microservice.yaml
@@ -22,7 +22,7 @@ servicecomb-config-order: 100
 APPLICATION_ID: authentication-application
 service_description:
   version: 0.0.1
-  name: gateway
+  name: edge-service
   environment: development
 
 servicecomb:


[servicecomb-samples] 01/03: refract project structures

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 161f7960091dd8ef486707882d872d90d861f7be
Author: liubao <ba...@huawei.com>
AuthorDate: Fri May 17 10:51:09 2019 +0800

    refract project structures
---
 .../main/resources/META-INF/spring/user.bean.xml   |  24 ---
 .../resources/META-INF/spring/resource.bean.xml    |  30 ---
 .../endpoint/pom.xml                               |   0
 .../authentication/api/AuthenticationEndpoint.java |   0
 .../pom.xml                                        |   0
 .../service/pom.xml                                |   0
 .../authentication/api/AuthenticationService.java  |   0
 .../servicecomb/authentication/api/Token.java      |   0
 .../samples/porter/file/api/InspectorEndpoint.java | 206 ---------------------
 .../samples/porter/file/api/LogEndpoint.java       |  72 -------
 .../samples/porter/common/api/LogService.java      |  26 ---
 authentication/api/edge-service/endpoint/pom.xml   |  38 ++++
 .../edge}/AuthenticationEndpoint.java              |   2 +-
 .../cse.bean.xml => api/edge-service/pom.xml}      |  25 ++-
 authentication/api/edge-service/service/pom.xml    |  42 +++++
 .../authentication/edge}/AuthHandler.java          |   2 +-
 .../authentication/edge}/AuthenticationFilter.java |   2 +-
 .../edge}/CustomVertxRestDispatcher.java           |   2 +-
 .../edge}/InternalAccessHandler.java               |   2 +-
 ...servicecomb.common.rest.filter.HttpServerFilter |   2 +-
 ...ecomb.transport.rest.vertx.VertxHttpDispatcher} |   2 +-
 .../src/main/resources/config/cse.handler.xml      |   4 +-
 authentication/api/pom.xml                         |   4 +-
 .../endpoint/pom.xml                               |   6 +-
 .../pom.xml                                        |   2 +-
 authentication/api/resource-server/service/pom.xml |  42 +++++
 .../resource/AccessConfiguration.java              |   0
 .../resource/AccessConfigurationManager.java       |   0
 ...eptionExceptionToProducerResponseConverter.java |   0
 .../resource/ResourceAuthHandler.java              |   0
 .../resource/SimpleAuthentication.java             |   0
 ....exception.ExceptionToProducerResponseConverter |   0
 .../src/main/resources/config/cse.handler.xml      |   0
 .../{ => samples}/AuthenticationServer/pom.xml     |   8 +-
 .../AuthenticationConfiguration.java               |   0
 .../authentication/AuthenticationServerMain.java   |   0
 .../service/AuthenticationServiceImpl.java         |   0
 .../src/main/resources/log4j2.xml                  |   0
 .../src/main/resources/microservice.yaml           |   0
 authentication/{ => samples}/Client/pom.xml        |   9 +-
 .../authentication/AuthenticationClientMain.java   |   0
 .../authentication/AuthenticationTestCase.java     |   0
 .../authentication/BootEventListener.java          |   0
 .../authentication/GateRestTemplate.java           |   0
 .../authentication/ITUriTemplateHandler.java       |   0
 .../servicecomb/authentication/TestCase.java       |   0
 .../servicecomb/authentication/TestEndpoint.java   |   0
 .../apache/servicecomb/authentication/TestMgr.java |   0
 .../Client/src/main/resources/log4j2.xml           |   0
 .../Client/src/main/resources/microservice.yaml    |   0
 .../{Gateway => samples/EdgeService}/pom.xml       |  15 +-
 .../authentication/gateway/ApiDispatcher.java      |   0
 .../gateway/AuthenticationConfiguration.java       |   0
 .../gateway/AuthenticationEdgeMain.java}           |   2 +-
 .../authentication/gateway/EdgeSSLCustom.java      |   0
 .../gateway/StaticWebpageDispatcher.java           |   0
 ...cecomb.transport.rest.vertx.VertxHttpDispatcher |   3 +-
 .../EdgeService}/src/main/resources/log4j2.xml     |   0
 .../src/main/resources/microservice.yaml           |   0
 .../src/main/resources/ui/css/style.css            |   0
 .../src/main/resources/ui/js/jquery-1.11.1.min.js  |   0
 .../EdgeService}/src/main/resources/ui/js/login.js |   0
 .../src/main/resources/ui/js/upload.js             |   0
 .../EdgeService}/src/main/resources/ui/login.html  |   0
 .../EdgeService}/src/main/resources/ui/upload.html |   0
 .../authentication/test/PatternTest.java           |   0
 .../{ => samples}/ResourceServer/pom.xml           |  22 +--
 .../resource/AuthenticationConfiguration.java      |   0
 .../authentication/resource/FileEndpoint.java      |   0
 .../authentication/resource/FileStoreService.java  |   0
 .../resource/HandlerAuthEndpoint.java              |   0
 .../resource/LocalFileStoreService.java            |   0
 .../resource/MethodSecurityConfiguration.java      |   0
 .../resource/PreMethodAuthEndpoint.java            |   0
 .../resource}/ResourceServerMain.java              |   2 +-
 .../ResourceServer}/src/main/resources/log4j2.xml  |   0
 .../src/main/resources/microservice.yaml           |   0
 authentication/{api => samples}/pom.xml            |   6 +-
 78 files changed, 194 insertions(+), 408 deletions(-)

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
deleted file mode 100644
index b33e5c9..0000000
--- a/authentication/AuthenticationServer/src/main/resources/META-INF/spring/user.bean.xml
+++ /dev/null
@@ -1,24 +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" />
-</beans>
\ No newline at end of file
diff --git a/authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml b/authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml
deleted file mode 100644
index fd84e44..0000000
--- a/authentication/ResourceServer/src/main/resources/META-INF/spring/resource.bean.xml
+++ /dev/null
@@ -1,30 +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"/>
-</beans>
\ No newline at end of file
diff --git a/authentication/api/AuthenticationServer/endpoint/pom.xml b/authentication/api/authentication-server/endpoint/pom.xml
similarity index 100%
copy from authentication/api/AuthenticationServer/endpoint/pom.xml
copy to authentication/api/authentication-server/endpoint/pom.xml
diff --git a/authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
similarity index 100%
rename from authentication/api/AuthenticationServer/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
rename to authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
diff --git a/authentication/api/AuthenticationServer/pom.xml b/authentication/api/authentication-server/pom.xml
similarity index 100%
copy from authentication/api/AuthenticationServer/pom.xml
copy to authentication/api/authentication-server/pom.xml
diff --git a/authentication/api/AuthenticationServer/service/pom.xml b/authentication/api/authentication-server/service/pom.xml
similarity index 100%
rename from authentication/api/AuthenticationServer/service/pom.xml
rename to authentication/api/authentication-server/service/pom.xml
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
similarity index 100%
rename from authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
rename to authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationService.java
diff --git a/authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java b/authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
similarity index 100%
rename from authentication/api/AuthenticationServer/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
rename to authentication/api/authentication-server/service/src/main/java/org/apache/servicecomb/authentication/api/Token.java
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
deleted file mode 100644
index 731f6ac..0000000
--- a/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/InspectorEndpoint.java
+++ /dev/null
@@ -1,206 +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.
- */
-
-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
deleted file mode 100644
index 8e49a6e..0000000
--- a/authentication/api/common/endpoint/src/main/java/org/apache/servicecomb/samples/porter/file/api/LogEndpoint.java
+++ /dev/null
@@ -1,72 +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.
- */
-
-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/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
deleted file mode 100644
index 9991543..0000000
--- a/authentication/api/common/service/src/main/java/org/apache/servicecomb/samples/porter/common/api/LogService.java
+++ /dev/null
@@ -1,26 +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.
- */
-
-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/edge-service/endpoint/pom.xml b/authentication/api/edge-service/endpoint/pom.xml
new file mode 100644
index 0000000..66c4a87
--- /dev/null
+++ b/authentication/api/edge-service/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-edge-api-endpoint</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.authentication</groupId>
+      <artifactId>authentication-edge-api-service</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+    <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/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java b/authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.java
similarity index 97%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java
rename to authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.java
index 021b337..68fe5d7 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEndpoint.java
+++ b/authentication/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationEndpoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.gateway;
+package org.apache.servicecomb.authentication.edge;
 
 import org.apache.servicecomb.authentication.api.AuthenticationService;
 import org.apache.servicecomb.authentication.api.Token;
diff --git a/authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml b/authentication/api/edge-service/pom.xml
similarity index 59%
rename from authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml
rename to authentication/api/edge-service/pom.xml
index b5816c3..24d393b 100644
--- a/authentication/Gateway/src/main/resources/META-INF/spring/cse.bean.xml
+++ b/authentication/api/edge-service/pom.xml
@@ -16,12 +16,21 @@
   ~ 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">
+<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>
 
-  <bean id="servicecomb.samples.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
-    init-method="init"/>
-</beans>
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-edge-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/edge-service/service/pom.xml b/authentication/api/edge-service/service/pom.xml
new file mode 100644
index 0000000..8d86c00
--- /dev/null
+++ b/authentication/api/edge-service/service/pom.xml
@@ -0,0 +1,42 @@
+<?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-edge-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-edge-api-service</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</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>
+  </dependencies>
+</project>
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthHandler.java
similarity index 97%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java
rename to authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthHandler.java
index d6b879a..2c8d63c 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthHandler.java
+++ b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.gateway;
+package org.apache.servicecomb.authentication.edge;
 
 import org.apache.servicecomb.authentication.util.Constants;
 import org.apache.servicecomb.core.Handler;
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationFilter.java
similarity index 96%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
rename to authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationFilter.java
index bc270b8..46ba288 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationFilter.java
+++ b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/AuthenticationFilter.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.gateway;
+package org.apache.servicecomb.authentication.edge;
 
 import org.apache.servicecomb.authentication.util.Constants;
 import org.apache.servicecomb.common.rest.filter.HttpServerFilter;
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
similarity index 99%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java
rename to authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
index 8d7472f..d1c6ef4 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/CustomVertxRestDispatcher.java
+++ b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/CustomVertxRestDispatcher.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.gateway;
+package org.apache.servicecomb.authentication.edge;
 
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/InternalAccessHandler.java
similarity index 96%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java
rename to authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/InternalAccessHandler.java
index e05f867..d01620f 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/InternalAccessHandler.java
+++ b/authentication/api/edge-service/service/src/main/java/org/apache/servicecomb/authentication/edge/InternalAccessHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication.gateway;
+package org.apache.servicecomb.authentication.edge;
 
 import org.apache.servicecomb.core.Handler;
 import org.apache.servicecomb.core.Invocation;
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
similarity index 92%
copy from authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
copy to authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
index 662c971..75e40b9 100644
--- a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
+++ b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.authentication.gateway.AuthenticationFilter
\ No newline at end of file
+org.apache.servicecomb.authentication.edge.AuthenticationFilter
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
similarity index 92%
rename from authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
rename to authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
index 662c971..53481f1 100644
--- a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
+++ b/authentication/api/edge-service/service/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.authentication.gateway.AuthenticationFilter
\ No newline at end of file
+org.apache.servicecomb.authentication.edge.CustomVertxRestDispatcher
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/config/cse.handler.xml b/authentication/api/edge-service/service/src/main/resources/config/cse.handler.xml
similarity index 85%
rename from authentication/Gateway/src/main/resources/config/cse.handler.xml
rename to authentication/api/edge-service/service/src/main/resources/config/cse.handler.xml
index b39da71..43a5258 100644
--- a/authentication/Gateway/src/main/resources/config/cse.handler.xml
+++ b/authentication/api/edge-service/service/src/main/resources/config/cse.handler.xml
@@ -17,7 +17,7 @@
 
 <config>
   <handler id="auth"
-    class="org.apache.servicecomb.authentication.gateway.AuthHandler" />
+    class="org.apache.servicecomb.authentication.edge.AuthHandler" />
   <handler id="internalAccess"
-    class="org.apache.servicecomb.authentication.gateway.InternalAccessHandler" />
+    class="org.apache.servicecomb.authentication.edge.InternalAccessHandler" />
 </config>
diff --git a/authentication/api/pom.xml b/authentication/api/pom.xml
index cdc3926..92c7f27 100644
--- a/authentication/api/pom.xml
+++ b/authentication/api/pom.xml
@@ -31,7 +31,9 @@
 
   <modules>
     <module>common</module>
-    <module>AuthenticationServer</module>
+    <module>authentication-server</module>
+    <module>resource-server</module>
+    <module>edge-service</module>
   </modules>
 
   <dependencyManagement>
diff --git a/authentication/api/AuthenticationServer/endpoint/pom.xml b/authentication/api/resource-server/endpoint/pom.xml
similarity index 88%
rename from authentication/api/AuthenticationServer/endpoint/pom.xml
rename to authentication/api/resource-server/endpoint/pom.xml
index 5eebece..dc5d549 100644
--- a/authentication/api/AuthenticationServer/endpoint/pom.xml
+++ b/authentication/api/resource-server/endpoint/pom.xml
@@ -21,17 +21,17 @@
 
   <parent>
     <groupId>org.apache.servicecomb.authentication</groupId>
-    <artifactId>authentication-server-api</artifactId>
+    <artifactId>authentication-resource-api</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>authentication-server-api-endpoint</artifactId>
+  <artifactId>authentication-resource-api-endpoint</artifactId>
   <packaging>jar</packaging>
 
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.authentication</groupId>
-      <artifactId>authentication-server-api-service</artifactId>
+      <artifactId>authentication-resource-api-service</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
   </dependencies>
diff --git a/authentication/api/AuthenticationServer/pom.xml b/authentication/api/resource-server/pom.xml
similarity index 95%
rename from authentication/api/AuthenticationServer/pom.xml
rename to authentication/api/resource-server/pom.xml
index 946a2fb..7c3f228 100644
--- a/authentication/api/AuthenticationServer/pom.xml
+++ b/authentication/api/resource-server/pom.xml
@@ -26,7 +26,7 @@
     <version>0.0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>authentication-server-api</artifactId>
+  <artifactId>authentication-resource-api</artifactId>
   <packaging>pom</packaging>
 
   <modules>
diff --git a/authentication/api/resource-server/service/pom.xml b/authentication/api/resource-server/service/pom.xml
new file mode 100644
index 0000000..cf045ce
--- /dev/null
+++ b/authentication/api/resource-server/service/pom.xml
@@ -0,0 +1,42 @@
+<?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-resource-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>authentication-resource-api-service</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.servicecomb.authentication</groupId>
+        <artifactId>authentication-common-api-endpoint</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>
+  </dependencies>
+</project>
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
rename to authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfiguration.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
rename to authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessConfigurationManager.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java
rename to authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/AccessDeniedExceptionExceptionToProducerResponseConverter.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
rename to authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/ResourceAuthHandler.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java b/authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java
rename to authentication/api/resource-server/service/src/main/java/org/apache/servicecomb/authentication/resource/SimpleAuthentication.java
diff --git a/authentication/ResourceServer/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter b/authentication/api/resource-server/service/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter
similarity index 100%
rename from authentication/ResourceServer/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter
rename to authentication/api/resource-server/service/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter
diff --git a/authentication/ResourceServer/src/main/resources/config/cse.handler.xml b/authentication/api/resource-server/service/src/main/resources/config/cse.handler.xml
similarity index 100%
rename from authentication/ResourceServer/src/main/resources/config/cse.handler.xml
rename to authentication/api/resource-server/service/src/main/resources/config/cse.handler.xml
diff --git a/authentication/AuthenticationServer/pom.xml b/authentication/samples/AuthenticationServer/pom.xml
similarity index 96%
rename from authentication/AuthenticationServer/pom.xml
rename to authentication/samples/AuthenticationServer/pom.xml
index baaac03..488d06d 100644
--- a/authentication/AuthenticationServer/pom.xml
+++ b/authentication/samples/AuthenticationServer/pom.xml
@@ -15,9 +15,13 @@
   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>
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-samples</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
   <artifactId>authentication-server</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>
 
   <properties>
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java b/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
similarity index 100%
rename from authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
rename to authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationConfiguration.java
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java b/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java
similarity index 100%
rename from authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java
rename to authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/AuthenticationServerMain.java
diff --git a/authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java b/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
similarity index 100%
rename from authentication/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
rename to authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
diff --git a/authentication/ResourceServer/src/main/resources/log4j2.xml b/authentication/samples/AuthenticationServer/src/main/resources/log4j2.xml
similarity index 100%
rename from authentication/ResourceServer/src/main/resources/log4j2.xml
rename to authentication/samples/AuthenticationServer/src/main/resources/log4j2.xml
diff --git a/authentication/AuthenticationServer/src/main/resources/microservice.yaml b/authentication/samples/AuthenticationServer/src/main/resources/microservice.yaml
similarity index 100%
rename from authentication/AuthenticationServer/src/main/resources/microservice.yaml
rename to authentication/samples/AuthenticationServer/src/main/resources/microservice.yaml
diff --git a/authentication/Client/pom.xml b/authentication/samples/Client/pom.xml
similarity index 96%
rename from authentication/Client/pom.xml
rename to authentication/samples/Client/pom.xml
index c94ff12..d879756 100644
--- a/authentication/Client/pom.xml
+++ b/authentication/samples/Client/pom.xml
@@ -15,9 +15,14 @@
   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>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-samples</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
   <artifactId>client</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>
 
   <properties>
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationClientMain.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/AuthenticationTestCase.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/BootEventListener.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/GateRestTemplate.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/ITUriTemplateHandler.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestCase.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestEndpoint.java
diff --git a/authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java b/authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
similarity index 100%
rename from authentication/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
rename to authentication/samples/Client/src/main/java/org/apache/servicecomb/authentication/TestMgr.java
diff --git a/authentication/Client/src/main/resources/log4j2.xml b/authentication/samples/Client/src/main/resources/log4j2.xml
similarity index 100%
rename from authentication/Client/src/main/resources/log4j2.xml
rename to authentication/samples/Client/src/main/resources/log4j2.xml
diff --git a/authentication/Client/src/main/resources/microservice.yaml b/authentication/samples/Client/src/main/resources/microservice.yaml
similarity index 100%
rename from authentication/Client/src/main/resources/microservice.yaml
rename to authentication/samples/Client/src/main/resources/microservice.yaml
diff --git a/authentication/Gateway/pom.xml b/authentication/samples/EdgeService/pom.xml
similarity index 90%
rename from authentication/Gateway/pom.xml
rename to authentication/samples/EdgeService/pom.xml
index 932669e..cb50f95 100644
--- a/authentication/Gateway/pom.xml
+++ b/authentication/samples/EdgeService/pom.xml
@@ -14,9 +14,14 @@
   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>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-samples</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>edge-service</artifactId>
   <packaging>jar</packaging>
 
   <properties>
@@ -34,7 +39,7 @@
       </dependency>
       <dependency>
         <groupId>org.apache.servicecomb.authentication</groupId>
-        <artifactId>authentication-common-api-endpoint</artifactId>
+        <artifactId>authentication-edge-api-endpoint</artifactId>
         <version>0.0.1-SNAPSHOT</version>
       </dependency>
       <dependency>
@@ -48,7 +53,7 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb.authentication</groupId>
-      <artifactId>authentication-common-api-endpoint</artifactId>
+      <artifactId>authentication-edge-api-endpoint</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb.authentication</groupId>
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
similarity index 100%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
rename to authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/ApiDispatcher.java
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
similarity index 100%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
rename to authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationConfiguration.java
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationGatewayMain.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEdgeMain.java
similarity index 96%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationGatewayMain.java
rename to authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEdgeMain.java
index be15a24..b040342 100644
--- a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationGatewayMain.java
+++ b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/AuthenticationEdgeMain.java
@@ -19,7 +19,7 @@ package org.apache.servicecomb.authentication.gateway;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 
-public class AuthenticationGatewayMain {
+public class AuthenticationEdgeMain {
     public static void main(String[] args) throws Exception {
         BeanUtils.init();
     }
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
similarity index 100%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
rename to authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/EdgeSSLCustom.java
diff --git a/authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java b/authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
similarity index 100%
rename from authentication/Gateway/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
rename to authentication/samples/EdgeService/src/main/java/org/apache/servicecomb/authentication/gateway/StaticWebpageDispatcher.java
diff --git a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher b/authentication/samples/EdgeService/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
similarity index 92%
rename from authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
rename to authentication/samples/EdgeService/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
index cb82ded..cf4f35b 100644
--- a/authentication/Gateway/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
+++ b/authentication/samples/EdgeService/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
@@ -16,5 +16,4 @@
 #
 
 org.apache.servicecomb.authentication.gateway.ApiDispatcher
-org.apache.servicecomb.authentication.gateway.StaticWebpageDispatcher
-org.apache.servicecomb.authentication.gateway.CustomVertxRestDispatcher
\ No newline at end of file
+org.apache.servicecomb.authentication.gateway.StaticWebpageDispatcher
\ No newline at end of file
diff --git a/authentication/Gateway/src/main/resources/log4j2.xml b/authentication/samples/EdgeService/src/main/resources/log4j2.xml
similarity index 100%
rename from authentication/Gateway/src/main/resources/log4j2.xml
rename to authentication/samples/EdgeService/src/main/resources/log4j2.xml
diff --git a/authentication/Gateway/src/main/resources/microservice.yaml b/authentication/samples/EdgeService/src/main/resources/microservice.yaml
similarity index 100%
rename from authentication/Gateway/src/main/resources/microservice.yaml
rename to authentication/samples/EdgeService/src/main/resources/microservice.yaml
diff --git a/authentication/Gateway/src/main/resources/ui/css/style.css b/authentication/samples/EdgeService/src/main/resources/ui/css/style.css
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/css/style.css
rename to authentication/samples/EdgeService/src/main/resources/ui/css/style.css
diff --git a/authentication/Gateway/src/main/resources/ui/js/jquery-1.11.1.min.js b/authentication/samples/EdgeService/src/main/resources/ui/js/jquery-1.11.1.min.js
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/js/jquery-1.11.1.min.js
rename to authentication/samples/EdgeService/src/main/resources/ui/js/jquery-1.11.1.min.js
diff --git a/authentication/Gateway/src/main/resources/ui/js/login.js b/authentication/samples/EdgeService/src/main/resources/ui/js/login.js
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/js/login.js
rename to authentication/samples/EdgeService/src/main/resources/ui/js/login.js
diff --git a/authentication/Gateway/src/main/resources/ui/js/upload.js b/authentication/samples/EdgeService/src/main/resources/ui/js/upload.js
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/js/upload.js
rename to authentication/samples/EdgeService/src/main/resources/ui/js/upload.js
diff --git a/authentication/Gateway/src/main/resources/ui/login.html b/authentication/samples/EdgeService/src/main/resources/ui/login.html
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/login.html
rename to authentication/samples/EdgeService/src/main/resources/ui/login.html
diff --git a/authentication/Gateway/src/main/resources/ui/upload.html b/authentication/samples/EdgeService/src/main/resources/ui/upload.html
similarity index 100%
rename from authentication/Gateway/src/main/resources/ui/upload.html
rename to authentication/samples/EdgeService/src/main/resources/ui/upload.html
diff --git a/authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java b/authentication/samples/EdgeService/test/org/apache/servicecomb/authentication/test/PatternTest.java
similarity index 100%
rename from authentication/Gateway/test/org/apache/servicecomb/authentication/test/PatternTest.java
rename to authentication/samples/EdgeService/test/org/apache/servicecomb/authentication/test/PatternTest.java
diff --git a/authentication/ResourceServer/pom.xml b/authentication/samples/ResourceServer/pom.xml
similarity index 88%
rename from authentication/ResourceServer/pom.xml
rename to authentication/samples/ResourceServer/pom.xml
index baeb56a..df24f7a 100644
--- a/authentication/ResourceServer/pom.xml
+++ b/authentication/samples/ResourceServer/pom.xml
@@ -15,9 +15,14 @@
   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>
+
+  <parent>
+    <groupId>org.apache.servicecomb.authentication</groupId>
+    <artifactId>authentication-samples</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
   <artifactId>resource-server</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>
 
   <properties>
@@ -28,12 +33,7 @@
     <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>
+        <artifactId>authentication-resource-api-endpoint</artifactId>
         <version>0.0.1-SNAPSHOT</version>
       </dependency>
       <dependency>
@@ -64,11 +64,7 @@
   <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>
+      <artifactId>authentication-resource-api-endpoint</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/AuthenticationConfiguration.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileEndpoint.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/FileStoreService.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/HandlerAuthEndpoint.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/LocalFileStoreService.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/MethodSecurityConfiguration.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
similarity index 100%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/PreMethodAuthEndpoint.java
diff --git a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServerMain.java b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceServerMain.java
similarity index 94%
rename from authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServerMain.java
rename to authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceServerMain.java
index 5aae72f..1964390 100644
--- a/authentication/ResourceServer/src/main/java/org/apache/servicecomb/authentication/ResourceServerMain.java
+++ b/authentication/samples/ResourceServer/src/main/java/org/apache/servicecomb/authentication/resource/ResourceServerMain.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.authentication;
+package org.apache.servicecomb.authentication.resource;
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 
diff --git a/authentication/AuthenticationServer/src/main/resources/log4j2.xml b/authentication/samples/ResourceServer/src/main/resources/log4j2.xml
similarity index 100%
rename from authentication/AuthenticationServer/src/main/resources/log4j2.xml
rename to authentication/samples/ResourceServer/src/main/resources/log4j2.xml
diff --git a/authentication/ResourceServer/src/main/resources/microservice.yaml b/authentication/samples/ResourceServer/src/main/resources/microservice.yaml
similarity index 100%
rename from authentication/ResourceServer/src/main/resources/microservice.yaml
rename to authentication/samples/ResourceServer/src/main/resources/microservice.yaml
diff --git a/authentication/api/pom.xml b/authentication/samples/pom.xml
similarity index 94%
copy from authentication/api/pom.xml
copy to authentication/samples/pom.xml
index cdc3926..9bf4cac 100644
--- a/authentication/api/pom.xml
+++ b/authentication/samples/pom.xml
@@ -21,7 +21,7 @@
   <modelVersion>4.0.0</modelVersion>
 
   <groupId>org.apache.servicecomb.authentication</groupId>
-  <artifactId>authentication-api</artifactId>
+  <artifactId>authentication-samples</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>pom</packaging>
 
@@ -30,8 +30,10 @@
   </properties>
 
   <modules>
-    <module>common</module>
     <module>AuthenticationServer</module>
+    <module>ResourceServer</module>
+    <module>EdgeService</module>
+    <module>Client</module>
   </modules>
 
   <dependencyManagement>


[servicecomb-samples] 02/03: provide default authentication service implementation

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 ab23af153a31eca1daa4406797caa80d89250c26
Author: liubao <ba...@huawei.com>
AuthorDate: Fri May 17 11:35:41 2019 +0800

    provide default authentication service implementation
---
 .../api/authentication-server/endpoint/pom.xml     |  5 ++
 .../authentication/api/AuthenticationEndpoint.java | 46 +++++++++++--
 .../service/AuthenticationServiceImpl.java         | 75 ----------------------
 3 files changed, 47 insertions(+), 79 deletions(-)

diff --git a/authentication/api/authentication-server/endpoint/pom.xml b/authentication/api/authentication-server/endpoint/pom.xml
index 5eebece..a653462 100644
--- a/authentication/api/authentication-server/endpoint/pom.xml
+++ b/authentication/api/authentication-server/endpoint/pom.xml
@@ -34,5 +34,10 @@
       <artifactId>authentication-server-api-service</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
+    <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/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
index 5177aeb..c777bc5 100644
--- a/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
+++ b/authentication/api/authentication-server/endpoint/src/main/java/org/apache/servicecomb/authentication/api/AuthenticationEndpoint.java
@@ -17,26 +17,64 @@
 
 package org.apache.servicecomb.authentication.api;
 
+import org.apache.servicecomb.authentication.jwt.JWTClaims;
+import org.apache.servicecomb.authentication.jwt.JsonParser;
 import org.apache.servicecomb.provider.rest.common.RestSchema;
 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;
+import org.springframework.security.jwt.crypto.sign.Signer;
 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")
-public class AuthenticationEndpoint {
+public class AuthenticationEndpoint implements AuthenticationService {
   @Autowired
-  private AuthenticationService authenticationService;
+  @Qualifier("authUserDetailsService")
+  private UserDetailsService userDetailsService;
 
+  @Autowired
+  @Qualifier("authPasswordEncoder")
+  private PasswordEncoder passwordEncoder;
+
+  @Autowired
+  @Qualifier("authSigner")
+  private Signer signer;
+
+  @Override
   @PostMapping(path = "login")
   public Token login(@RequestParam(name = "userName") String userName,
       @RequestParam(name = "password") String password) {
-    return authenticationService.login(userName, password);
+    UserDetails userDetails = userDetailsService.loadUserByUsername(userName);
+    if (passwordEncoder.matches(password, userDetails.getPassword())) {
+      JWTClaims claims = new JWTClaims();
+      if (userDetails.getAuthorities() != null) {
+        userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
+      }
+      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());
+      return token;
+    } else {
+      return null;
+    }
   }
 
+  @Override
   @PostMapping(path = "refresh")
   public Token refresh(@RequestParam(name = "refreshToken") String refreshToken) {
-    return authenticationService.refresh(refreshToken);
+    return null;
   }
+
 }
diff --git a/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java b/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
deleted file mode 100644
index cfbe22b..0000000
--- a/authentication/samples/AuthenticationServer/src/main/java/org/apache/servicecomb/authentication/service/AuthenticationServiceImpl.java
+++ /dev/null
@@ -1,75 +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.
- */
-
-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.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;
-import org.springframework.security.jwt.crypto.sign.Signer;
-import org.springframework.stereotype.Service;
-
-@Service
-public class AuthenticationServiceImpl implements AuthenticationService {
-  @Autowired
-  @Qualifier("authUserDetailsService")
-  private UserDetailsService userDetailsService;
-
-  @Autowired
-  @Qualifier("authPasswordEncoder")
-  private PasswordEncoder passwordEncoder;
-
-  @Autowired
-  @Qualifier("authSigner")
-  private Signer signer;
-
-  @Override
-  public Token login(String userName, String password) {
-    UserDetails userDetails = userDetailsService.loadUserByUsername(userName);
-    if (passwordEncoder.matches(password, userDetails.getPassword())) {
-      JWTClaims claims = new JWTClaims();
-      if (userDetails.getAuthorities() != null) {
-        userDetails.getAuthorities().forEach(authority -> claims.addAuthority(authority.getAuthority()));
-      }
-      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());
-      return token;
-    } else {
-      return null;
-    }
-  }
-
-  @Override
-  public Token refresh(String refreshToken) {
-    return null;
-  }
-
-}