MCPcopy Create free account
hub / github.com/apache/mesos / initializeHttpAuthenticators

Function initializeHttpAuthenticators

src/common/http.cpp:1349–1428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1347} // namespace {
1348
1349Try<Nothing> initializeHttpAuthenticators(
1350 const string& realm,
1351 const vector<string>& authenticatorNames,
1352 const Option<Credentials>& credentials,
1353 const Option<string>& jwtSecretKey)
1354{
1355 if (authenticatorNames.empty()) {
1356 return Error(
1357 "No HTTP authenticators specified for realm '" + realm + "'");
1358 }
1359
1360 Option<process::http::authentication::Authenticator*> authenticator;
1361
1362 if (authenticatorNames.size() == 1) {
1363 Result<process::http::authentication::Authenticator*> authenticator_ =
1364 None();
1365
1366 if (authenticatorNames[0] == internal::DEFAULT_BASIC_HTTP_AUTHENTICATOR) {
1367 authenticator_ =
1368 createBasicAuthenticator(realm, authenticatorNames[0], credentials);
1369#ifdef USE_SSL_SOCKET
1370 } else if (
1371 authenticatorNames[0] == internal::DEFAULT_JWT_HTTP_AUTHENTICATOR) {
1372 authenticator_ =
1373 createJWTAuthenticator(realm, authenticatorNames[0], jwtSecretKey);
1374#endif // USE_SSL_SOCKET
1375 } else {
1376 authenticator_ = createCustomAuthenticator(realm, authenticatorNames[0]);
1377 }
1378
1379 if (authenticator_.isError()) {
1380 return Error(
1381 "Failed to create HTTP authenticator module '" +
1382 authenticatorNames[0] + "': " + authenticator_.error());
1383 }
1384
1385 CHECK_SOME(authenticator_);
1386 authenticator = authenticator_.get();
1387 } else {
1388 // There are multiple authenticators loaded for this realm,
1389 // so construct a `CombinedAuthenticator` to handle them.
1390 vector<Owned<process::http::authentication::Authenticator>> authenticators;
1391 foreach (const string& name, authenticatorNames) {
1392 Result<process::http::authentication::Authenticator*> authenticator_ =
1393 None();
1394
1395 if (name == internal::DEFAULT_BASIC_HTTP_AUTHENTICATOR) {
1396 authenticator_ = createBasicAuthenticator(realm, name, credentials);
1397#ifdef USE_SSL_SOCKET
1398 } else if (name == internal::DEFAULT_JWT_HTTP_AUTHENTICATOR) {
1399 authenticator_ = createJWTAuthenticator(realm, name, jwtSecretKey);
1400#endif // USE_SSL_SOCKET
1401 } else {
1402 authenticator_ = createCustomAuthenticator(realm, name);
1403 }
1404
1405 if (authenticator_.isError()) {
1406 return Error(

Callers 2

initializeMethod · 0.85
initializeMethod · 0.85

Calls 13

NoneClass · 0.85
createBasicAuthenticatorFunction · 0.85
createJWTAuthenticatorFunction · 0.85
setAuthenticatorFunction · 0.85
NothingClass · 0.85
errorMethod · 0.65
ErrorFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
isErrorMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected