• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 //
3 // Copyright 2016 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
19 #ifndef GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H
20 #define GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H
21 
22 #include <grpc/credentials.h>
23 #include <grpc/grpc_security.h>
24 #include <grpc/support/port_platform.h>
25 
26 #include <string>
27 
28 #include "absl/status/statusor.h"
29 #include "absl/types/optional.h"
30 #include "src/core/lib/promise/arena_promise.h"
31 #include "src/core/lib/security/credentials/credentials.h"
32 #include "src/core/lib/slice/slice.h"
33 #include "src/core/lib/transport/transport.h"
34 #include "src/core/util/unique_type_name.h"
35 #include "src/core/util/useful.h"
36 
37 class grpc_google_iam_credentials : public grpc_call_credentials {
38  public:
39   grpc_google_iam_credentials(const char* token,
40                               const char* authority_selector);
41 
Orphaned()42   void Orphaned() override {}
43 
44   grpc_core::ArenaPromise<absl::StatusOr<grpc_core::ClientMetadataHandle>>
45   GetRequestMetadata(grpc_core::ClientMetadataHandle initial_metadata,
46                      const GetRequestMetadataArgs* args) override;
47 
debug_string()48   std::string debug_string() override { return debug_string_; }
49 
50   static grpc_core::UniqueTypeName Type();
51 
type()52   grpc_core::UniqueTypeName type() const override { return Type(); }
53 
54  private:
cmp_impl(const grpc_call_credentials * other)55   int cmp_impl(const grpc_call_credentials* other) const override {
56     // TODO(yashykt): Check if we can do something better here
57     return grpc_core::QsortCompare(
58         static_cast<const grpc_call_credentials*>(this), other);
59   }
60 
61   const absl::optional<grpc_core::Slice> token_;
62   const grpc_core::Slice authority_selector_;
63   const std::string debug_string_;
64 };
65 
66 #endif  // GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H
67