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

Method authorize

src/files/files.cpp:352–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350
351
352Future<bool> FilesProcess::authorize(
353 string requestedPath,
354 const Option<Principal>& principal)
355{
356 // The path may contain a trailing forward slash. Since we store the
357 // authorization callbacks without the trailing slash, we must remove it here,
358 // if present.
359 const string trimmedPath =
360 strings::remove(requestedPath,
361 stringify(os::PATH_SEPARATOR), strings::SUFFIX);
362
363 if (authorizations.count(trimmedPath) > 0) {
364 return authorizations[trimmedPath](principal);
365 }
366
367 do {
368 requestedPath = Path(requestedPath).dirname();
369
370 if (authorizations.count(requestedPath) > 0) {
371 return authorizations[requestedPath](principal);
372 }
373 } while (Path(requestedPath).dirname() != requestedPath);
374
375 // requestedPath does not require authorization.
376 return true;
377}
378
379
380Future<http::Response> FilesProcess::_browse(

Callers

nothing calls this directly

Calls 5

PathClass · 0.85
dirnameMethod · 0.80
removeFunction · 0.50
stringifyFunction · 0.50
countMethod · 0.45

Tested by

no test coverage detected