• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2020 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_EXTERNAL_URL_EXTERNAL_ACCOUNT_CREDENTIALS_H
18 #define GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_EXTERNAL_URL_EXTERNAL_ACCOUNT_CREDENTIALS_H
19 
20 #include <grpc/support/port_platform.h>
21 
22 #include <functional>
23 #include <map>
24 #include <string>
25 #include <vector>
26 
27 #include "absl/strings/string_view.h"
28 #include "src/core/lib/iomgr/error.h"
29 #include "src/core/lib/security/credentials/external/external_account_credentials.h"
30 #include "src/core/util/http_client/httpcli.h"
31 #include "src/core/util/orphanable.h"
32 #include "src/core/util/ref_counted_ptr.h"
33 #include "src/core/util/uri.h"
34 
35 namespace grpc_core {
36 
37 class UrlExternalAccountCredentials final : public ExternalAccountCredentials {
38  public:
39   static absl::StatusOr<RefCountedPtr<UrlExternalAccountCredentials>> Create(
40       Options options, std::vector<std::string> scopes,
41       std::shared_ptr<grpc_event_engine::experimental::EventEngine>
42           event_engine = nullptr);
43 
44   UrlExternalAccountCredentials(
45       Options options, std::vector<std::string> scopes,
46       std::shared_ptr<grpc_event_engine::experimental::EventEngine>
47           event_engine,
48       grpc_error_handle* error);
49 
50   std::string debug_string() override;
51 
52   static UniqueTypeName Type();
53 
type()54   UniqueTypeName type() const override { return Type(); }
55 
56  private:
57   OrphanablePtr<FetchBody> RetrieveSubjectToken(
58       Timestamp deadline,
59       absl::AnyInvocable<void(absl::StatusOr<std::string>)> on_done) override;
60 
61   absl::string_view CredentialSourceType() override;
62 
63   // Fields of credential source
64   URI url_;
65   std::string url_full_path_;
66   std::map<std::string, std::string> headers_;
67   std::string format_type_;
68   std::string format_subject_token_field_name_;
69 };
70 
71 }  // namespace grpc_core
72 
73 #endif  // GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_EXTERNAL_URL_EXTERNAL_ACCOUNT_CREDENTIALS_H
74