| 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_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H |
| 20 |
#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H |
| 21 |
|
| 22 |
#include <grpc/support/port_platform.h> |
| 23 |
|
| 24 |
#include <string> |
| 25 |
|
| 26 |
#include "absl/status/statusor.h" |
| 27 |
#include "absl/types/optional.h" |
| 28 |
|
| 29 |
#include <grpc/grpc_security.h> |
| 30 |
|
| 31 |
#include "src/core/lib/gpr/useful.h" |
| 32 |
#include "src/core/lib/gprpp/unique_type_name.h" |
| 33 |
#include "src/core/lib/promise/arena_promise.h" |
| 34 |
#include "src/core/lib/security/credentials/credentials.h" |
| 35 |
#include "src/core/lib/slice/slice.h" |
| 36 |
#include "src/core/lib/transport/transport.h" |
| 37 |
|
| 38 |
class grpc_google_iam_credentials : public grpc_call_credentials { |
| 39 |
public: |
| 40 |
grpc_google_iam_credentials(const char* token, |
| 41 |
const char* authority_selector); |
| 42 |
|
| 43 |
grpc_core::ArenaPromise<absl::StatusOr<grpc_core::ClientMetadataHandle>> |
| 44 |
GetRequestMetadata(grpc_core::ClientMetadataHandle initial_metadata, |
| 45 |
const GetRequestMetadataArgs* args) override; |
| 46 |
|
| 47 |
std::string debug_string() override { return debug_string_; } |
| 48 |
|
| 49 |
static grpc_core::UniqueTypeName Type(); |
| 50 |
|
| 51 |
grpc_core::UniqueTypeName type() const override { return Type(); } |
| 52 |
|
| 53 |
private: |
| 54 |
int cmp_impl(const grpc_call_credentials* other) const override { |
| 55 |
// TODO(yashykt): Check if we can do something better here |
| 56 |
return grpc_core::QsortCompare( |
| 57 |
static_cast<const grpc_call_credentials*>(this), other); |
| 58 |
} |
| 59 |
|
| 60 |
const absl::optional<grpc_core::Slice> token_; |
| 61 |
const grpc_core::Slice authority_selector_; |
| 62 |
const std::string debug_string_; |
| 63 |
}; |
| 64 |
|
| 65 |
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H */ |