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

Function getBearerAuthParam

src/uri/fetchers/docker.cpp:485–516  ·  view source on GitHub ↗

Validates that the response contains WWW-Authenticate header with a scheme BEARER and, if so, extracts parameters from the header. Otherwise, returns Error.

Source from the content-addressed store, hash-verified

483// a scheme BEARER and, if so, extracts parameters from the header.
484// Otherwise, returns Error.
485static Try<hashmap<string, string>> getBearerAuthParam(
486 const URI& uri,
487 const http::Response& response)
488{
489 Result<http::header::WWWAuthenticate> header =
490 response.headers.get<http::header::WWWAuthenticate>();
491
492 if (header.isError()) {
493 return Error(
494 "Failed to get WWW-Authenticate header from " + stringify(uri) +
495 ": " + header.error());
496 } else if (header.isNone()) {
497 return Error(
498 "Got unexpected empty WWW-Authenticate header from " + stringify(uri));
499 }
500
501 // According to RFC, auth scheme should be case insensitive.
502 const string authScheme = strings::upper(header->authScheme());
503 if (authScheme == "BASIC"){
504 return Error(
505 "Got unexpected BASIC Authorization response status: " +
506 response.status + " from " + stringify(uri));
507 }
508
509 if (authScheme != "BEARER") {
510 return Error(
511 "Got unsupported auth-scheme: " + authScheme +
512 " from " + stringify(uri));
513 }
514
515 return header->authParam();
516}
517
518
519//-------------------------------------------------------------------

Callers 1

getAuthServiceUriMethod · 0.85

Calls 8

upperFunction · 0.85
authSchemeMethod · 0.80
authParamMethod · 0.80
errorMethod · 0.65
ErrorFunction · 0.50
stringifyFunction · 0.50
isErrorMethod · 0.45
isNoneMethod · 0.45

Tested by

no test coverage detected