This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [#45 & #42]支持服务中心RBAC,支持watch模式 * [#45 & #42]支持服务中心RBAC,支持watch模式 * [#45 & #42]支持服务中心RBAC,支持watch模式 * [#42 & #45]支持服务中心RBAC,支持watch模式 * [#45][#42]support RBAC and watch * [#42][#45] support RBAC and watch * [#42][#45]support RBAC and watch * [#42][#45] support RBAC and watch * [#42][#45]support RBAC and watch
- Loading branch information
1 parent
ee9c914
commit 9f5e4b6
Showing
29 changed files
with
533 additions
and
204 deletions.
There are no files selected for viewing
This file contains 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 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
46 changes: 46 additions & 0 deletions
46
common/src/main/java/com/huaweicloud/dubbo/common/AuthHeaderProviders.java
This file contains 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,46 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.huaweicloud.dubbo.common; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.servicecomb.foundation.auth.AuthHeaderProvider; | ||
import org.apache.servicecomb.http.client.auth.RequestAuthHeaderProvider; | ||
import org.springframework.core.env.Environment; | ||
|
||
public class AuthHeaderProviders { | ||
|
||
public static RequestAuthHeaderProvider getRequestAuthHeaderProvider(CommonConfiguration commonConfiguration, | ||
Environment environment) { | ||
List<AuthHeaderProvider> authHeaderProviders = new ArrayList<>(); | ||
authHeaderProviders.add(commonConfiguration.createAkSkRequestAuthHeaderProvider()); | ||
authHeaderProviders.add(new RBACRequestAuthHeaderProvider(commonConfiguration, environment)); | ||
return getRequestAuthHeaderProvider(authHeaderProviders); | ||
} | ||
|
||
private static RequestAuthHeaderProvider getRequestAuthHeaderProvider(List<AuthHeaderProvider> authHeaderProviders) { | ||
return signRequest -> { | ||
Map<String, String> headers = new HashMap<>(); | ||
authHeaderProviders.forEach(authHeaderProvider -> headers.putAll(authHeaderProvider.authHeaders())); | ||
return headers; | ||
}; | ||
} | ||
} |
This file contains 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
Oops, something went wrong.