|
| 1 | +// Copyright 2025 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_GRPC_COMPUTE_ENGINE_AUTHENTICATION_H |
| 16 | +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_GRPC_COMPUTE_ENGINE_AUTHENTICATION_H |
| 17 | + |
| 18 | +#include "google/cloud/internal/credentials_impl.h" |
| 19 | +#include "google/cloud/internal/unified_grpc_credentials.h" |
| 20 | +#include "google/cloud/version.h" |
| 21 | +#include <grpcpp/grpcpp.h> |
| 22 | + |
| 23 | +namespace google { |
| 24 | +namespace cloud { |
| 25 | +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN |
| 26 | +namespace internal { |
| 27 | + |
| 28 | +class GrpcComputeEngineAuthentication : public GrpcAuthenticationStrategy { |
| 29 | + public: |
| 30 | + explicit GrpcComputeEngineAuthentication(Options const& opts = {}); |
| 31 | + ~GrpcComputeEngineAuthentication() override = default; |
| 32 | + |
| 33 | + std::shared_ptr<grpc::Channel> CreateChannel( |
| 34 | + std::string const& endpoint, |
| 35 | + grpc::ChannelArguments const& arguments) override; |
| 36 | + bool RequiresConfigureContext() const override; |
| 37 | + Status ConfigureContext(grpc::ClientContext&) override; |
| 38 | + future<StatusOr<std::shared_ptr<grpc::ClientContext>>> AsyncConfigureContext( |
| 39 | + std::shared_ptr<grpc::ClientContext> context) override; |
| 40 | + |
| 41 | + private: |
| 42 | + std::shared_ptr<grpc::CallCredentials> credentials_; |
| 43 | + grpc::SslCredentialsOptions ssl_options_; |
| 44 | +}; |
| 45 | + |
| 46 | +} // namespace internal |
| 47 | +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END |
| 48 | +} // namespace cloud |
| 49 | +} // namespace google |
| 50 | + |
| 51 | +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_GRPC_COMPUTE_ENGINE_AUTHENTICATION_H |
0 commit comments