forked from grpc/grpc-java
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: Don't leak CallCredentials into OOB channels
The addition of CompositeChannelCredentials allowed CallCredentials to be passed to the ManagedChannel itself. But the implementation was buggy and used the call creds for out-of-band channels as well, which is inappropriate since they have a different authority. This also fixes a bug where resolving OOB channels would have CallCreds duplicated; that wasn't noticed or important because we don't use CallCreds in OOB channels. Fixes grpc#7643
- Loading branch information
Showing
4 changed files
with
136 additions
and
22 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
43 changes: 43 additions & 0 deletions
43
core/src/test/java/io/grpc/internal/FakeCallCredentials.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,43 @@ | ||
/* | ||
* Copyright 2020 The gRPC Authors | ||
* | ||
* 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.grpc.internal; | ||
|
||
import io.grpc.CallCredentials; | ||
import io.grpc.Metadata; | ||
import java.util.concurrent.Executor; | ||
|
||
/** | ||
* CallCredentials that provides a single, fixed header. | ||
*/ | ||
final class FakeCallCredentials extends CallCredentials { | ||
private final Metadata headers; | ||
|
||
public <T> FakeCallCredentials(Metadata.Key<T> key, T value) { | ||
headers = new Metadata(); | ||
headers.put(key, value); | ||
} | ||
|
||
@Override | ||
public void applyRequestMetadata( | ||
CallCredentials.RequestInfo requestInfo, | ||
Executor appExecutor, | ||
CallCredentials.MetadataApplier applier) { | ||
applier.apply(headers); | ||
} | ||
|
||
@Override public void thisUsesUnstableApi() {} | ||
} |
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