Mercurial > hg > orthanc
comparison Core/HttpServer/MongooseServer.cpp @ 1203:e85e668d2147 db-changes
integration mainline->db-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 27 Oct 2014 13:46:03 +0100 |
parents | 476a17cfdf42 |
children | 787059de6b9a |
comparison
equal
deleted
inserted
replaced
1201:09aa7c126be9 | 1203:e85e668d2147 |
---|---|
407 | 407 |
408 return PostDataStatus_Pending; | 408 return PostDataStatus_Pending; |
409 } | 409 } |
410 | 410 |
411 | 411 |
412 static bool Authorize(const MongooseServer& that, | 412 static bool IsAccessGranted(const MongooseServer& that, |
413 const HttpHandler::Arguments& headers, | 413 const HttpHandler::Arguments& headers) |
414 HttpOutput& output) | |
415 { | 414 { |
416 bool granted = false; | 415 bool granted = false; |
417 | 416 |
418 HttpHandler::Arguments::const_iterator auth = headers.find("authorization"); | 417 HttpHandler::Arguments::const_iterator auth = headers.find("authorization"); |
419 if (auth != headers.end()) | 418 if (auth != headers.end()) |
424 std::string b64 = s.substr(6); | 423 std::string b64 = s.substr(6); |
425 granted = that.IsValidBasicHttpAuthentication(b64); | 424 granted = that.IsValidBasicHttpAuthentication(b64); |
426 } | 425 } |
427 } | 426 } |
428 | 427 |
429 if (!granted) | 428 return granted; |
430 { | |
431 output.SendUnauthorized(ORTHANC_REALM); | |
432 return false; | |
433 } | |
434 else | |
435 { | |
436 return true; | |
437 } | |
438 } | 429 } |
439 | 430 |
440 | 431 |
441 static std::string GetAuthenticatedUsername(const HttpHandler::Arguments& headers) | 432 static std::string GetAuthenticatedUsername(const HttpHandler::Arguments& headers) |
442 { | 433 { |
589 return; | 580 return; |
590 } | 581 } |
591 | 582 |
592 | 583 |
593 // Authenticate this connection | 584 // Authenticate this connection |
594 if (that->IsAuthenticationEnabled() && | 585 if (that->IsAuthenticationEnabled() && !IsAccessGranted(*that, headers)) |
595 !Authorize(*that, headers, output)) | |
596 { | 586 { |
597 output.SendUnauthorized(ORTHANC_REALM); | 587 output.SendUnauthorized(ORTHANC_REALM); |
598 return; | 588 return; |
599 } | 589 } |
600 | 590 |