-
Notifications
You must be signed in to change notification settings - Fork 827
JAV-358 Operation filter #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1adf4e7
JAV-358 create CompatiblePathVersionMapper to convert pathVersion to …
a139004
JAV-358 create OperationInstancesDiscoveryFilter to avoid dispatch ne…
7a864e0
JAV-358 EdgeInvocation support control versionRule by caller
b98c90e
JAV-358 change edge demo to verify operation instance filter
9ef71e3
JAV-358 PojoProvider provide api to create schema proxy
802a2b3
JAV-358 change edge demo to show how to do authentication logic
3dac1c2
JAV-358 edge support use thread pool, default is reactive mode
73c9ea0
JAV-358 change demo edge service from reactive mode to threadPool mod…
4b98f73
modify by review comments.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<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>io.servicecomb.demo</groupId> | ||
<artifactId>demo-edge</artifactId> | ||
<version>0.4.1-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>authentication</artifactId> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.servicecomb</groupId> | ||
<artifactId>provider-springmvc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.servicecomb</groupId> | ||
<artifactId>transport-rest-vertx</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
32 changes: 32 additions & 0 deletions
32
...o-edge/authentication/src/main/java/io/servicecomb/demo/edge/authentication/AuthImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2017 Huawei Technologies Co., Ltd | ||
* | ||
* Licensed 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 io.servicecomb.demo.edge.authentication; | ||
|
||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import io.servicecomb.provider.rest.common.RestSchema; | ||
|
||
@RestSchema(schemaId = "auth") | ||
@RequestMapping(path = "auth/v1") | ||
public class AuthImpl { | ||
@PostMapping(path = "/auth") | ||
public boolean auth(@RequestHeader(name = "info") String info) { | ||
return true; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...o-edge/authentication/src/main/java/io/servicecomb/demo/edge/authentication/AuthMain.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2017 Huawei Technologies Co., Ltd | ||
* | ||
* Licensed 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 io.servicecomb.demo.edge.authentication; | ||
|
||
import io.servicecomb.foundation.common.utils.BeanUtils; | ||
import io.servicecomb.foundation.common.utils.Log4jUtils; | ||
|
||
public class AuthMain { | ||
public static void main(String[] args) throws Exception { | ||
Log4jUtils.init(); | ||
BeanUtils.init(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
demo/demo-edge/authentication/src/main/resources/microservice.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
APPLICATION_ID: hiboard | ||
service_description: | ||
name: auth | ||
version: 0.0.1 | ||
cse: | ||
service: | ||
registry: | ||
address: http://127.0.0.1:30100 | ||
rest: | ||
address: 127.0.0.1:7070 | ||
server: | ||
thread-count: 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
demo/demo-edge/edge-service/src/main/java/io/servicecomb/demo/edge/service/handler/Auth.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2017 Huawei Technologies Co., Ltd | ||
* | ||
* Licensed 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 io.servicecomb.demo.edge.service.handler; | ||
|
||
public interface Auth { | ||
boolean auth(String info); | ||
} |
55 changes: 55 additions & 0 deletions
55
...edge/edge-service/src/main/java/io/servicecomb/demo/edge/service/handler/AuthHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2017 Huawei Technologies Co., Ltd | ||
* | ||
* Licensed 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 io.servicecomb.demo.edge.service.handler; | ||
|
||
import javax.ws.rs.core.Response.Status; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.servicecomb.core.Handler; | ||
import io.servicecomb.core.Invocation; | ||
import io.servicecomb.core.definition.MicroserviceMeta; | ||
import io.servicecomb.provider.pojo.Invoker; | ||
import io.servicecomb.swagger.invocation.AsyncResponse; | ||
import io.servicecomb.swagger.invocation.InvocationType; | ||
import io.servicecomb.swagger.invocation.exception.InvocationException; | ||
|
||
public class AuthHandler implements Handler { | ||
private static Logger LOGGER = LoggerFactory.getLogger(AuthHandler.class); | ||
|
||
private Auth auth; | ||
|
||
public AuthHandler() { | ||
auth = Invoker.createProxy("auth", "auth", Auth.class); | ||
} | ||
|
||
@Override | ||
public void init(MicroserviceMeta microserviceMeta, InvocationType invocationType) { | ||
} | ||
|
||
@Override | ||
public void handle(Invocation invocation, AsyncResponse asyncResp) throws Exception { | ||
if (!auth.auth("")) { | ||
asyncResp.consumerFail(new InvocationException(Status.UNAUTHORIZED, (Object) "auth failed")); | ||
return; | ||
} | ||
|
||
LOGGER.debug("auth success."); | ||
invocation.next(asyncResp); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
demo/demo-edge/edge-service/src/main/resources/config/cse.handler.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- | ||
~ Copyright 2017 Huawei Technologies Co., Ltd | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<config> | ||
<handler id="auth" | ||
class="io.servicecomb.demo.edge.service.handler.AuthHandler" /> | ||
</config> |
1 change: 1 addition & 0 deletions
1
demo/demo-edge/edge-service/src/main/resources/config/log4j.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
log4j.rootLogger=DEBUG,stdout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2017 Huawei Technologies Co., Ltd | ||
~ | ||
~ Licensed 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>io.servicecomb.demo</groupId> | ||
<artifactId>demo-edge</artifactId> | ||
<version>0.4.1-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>hiboard-business-1-1-0</artifactId> | ||
<properties> | ||
<demo.main>io.servicecomb.demo.edge.business.BusinessMain_V1_1_0</demo.main> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.servicecomb</groupId> | ||
<artifactId>provider-springmvc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.servicecomb</groupId> | ||
<artifactId>transport-rest-vertx</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.servicecomb</groupId> | ||
<artifactId>transport-rest-servlet</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.servicecomb.demo</groupId> | ||
<artifactId>hiboard-model</artifactId> | ||
<version>0.4.1-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we tell the path by removing the first 4 characters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a demo
and the path rule is :/api/ms/version/......