1 #include "authenticate.h"
3 #include "logging/logging.h"
9 switch (creds.GetMethod()) {
10 case AuthMethod::kBasic: {
11 treehub.SetAuthBasic(creds.GetAuthUser(), creds.GetAuthPassword());
14 case AuthMethod::kOauth2: {
15 OAuth2 oauth2(creds.GetAuthServer(), creds.GetClientId(), creds.GetClientSecret(), creds.GetScope(), cacerts);
17 if (!creds.GetClientId().empty()) {
18 if (oauth2.Authenticate() != AuthenticationResult::kSuccess) {
19 LOG_FATAL <<
"Authentication with oauth2 failed";
22 LOG_INFO <<
"Using oauth2 authentication token";
23 treehub.SetToken(oauth2.token());
26 LOG_INFO <<
"Skipping Authentication";
30 case AuthMethod::kTls: {
31 treehub.SetCerts(creds.GetClientP12());
34 case AuthMethod::kNone:
37 LOG_FATAL <<
"Unexpected authentication method value " <<
static_cast<int>(creds.GetMethod());
45 treehub.ca_certs(cacerts);
46 treehub.root_url(creds.GetOSTreeServer());
47 treehub.repo_url(creds.GetRepoUrl());