Android-cuttlefish cvd tool
cuttlefish
host
libs
web
credential_source
gce_metadata_credential_source.h
Go to the documentation of this file.
1
//
2
// Copyright (C) 2019 The Android Open Source Project
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
#pragma once
17
18
#include <chrono>
19
#include <memory>
20
#include <string>
21
#include <utility>
22
23
#include "
cuttlefish/host/libs/web/credential_source/credential_source.h
"
24
#include "
cuttlefish/host/libs/web/credential_source/refreshing_credential_source.h
"
25
#include "
cuttlefish/host/libs/web/http_client/http_client.h
"
26
#include "
cuttlefish/result/result_type.h
"
27
28
namespace
cuttlefish
{
29
30
// OAuth2 credentials from the GCE metadata server.
31
//
32
// -
33
// https://cloud.google.com/compute/docs/access/authenticate-workloads#applications
34
// - https://cloud.google.com/compute/docs/metadata/overview
35
class
GceMetadataCredentialSource
:
public
RefreshingCredentialSource
{
36
public
:
37
static
std::unique_ptr<CredentialSource>
Make
(
HttpClient
&);
38
39
private
:
40
GceMetadataCredentialSource
(
HttpClient
&);
41
42
Result<std::pair<std::string, std::chrono::seconds>
>
Refresh
()
override
;
43
44
HttpClient
&
http_client_
;
45
};
46
47
}
// namespace cuttlefish
cuttlefish::GceMetadataCredentialSource
Definition:
gce_metadata_credential_source.h:35
cuttlefish::GceMetadataCredentialSource::Make
static std::unique_ptr< CredentialSource > Make(HttpClient &)
Definition:
gce_metadata_credential_source.cc:62
cuttlefish::GceMetadataCredentialSource::Refresh
Result< std::pair< std::string, std::chrono::seconds > > Refresh() override
Definition:
gce_metadata_credential_source.cc:40
cuttlefish::GceMetadataCredentialSource::http_client_
HttpClient & http_client_
Definition:
gce_metadata_credential_source.h:44
cuttlefish::GceMetadataCredentialSource::GceMetadataCredentialSource
GceMetadataCredentialSource(HttpClient &)
Definition:
gce_metadata_credential_source.cc:35
cuttlefish::HttpClient
Definition:
http_client.h:100
cuttlefish::RefreshingCredentialSource
Definition:
refreshing_credential_source.h:30
credential_source.h
http_client.h
cuttlefish
Definition:
alloc_driver.h:21
cuttlefish::Result
tl::expected< T, StackTraceError< E > > Result
Definition:
result_type.h:30
refreshing_credential_source.h
result_type.h
Generated by
1.9.4