comparison Plugin/AuthorizationWebService.cpp @ 113:43154740ea2e

wip: checking labels
author Alain Mazy <am@osimis.io>
date Tue, 05 Sep 2023 12:48:20 +0200
parents 572955904411
children 0eed78c1e177
comparison
equal deleted inserted replaced
112:572955904411 113:43154740ea2e
387 } 387 }
388 388
389 validity = jsonProfile[VALIDITY].asUInt(); 389 validity = jsonProfile[VALIDITY].asUInt();
390 390
391 profile.name = jsonProfile[USER_NAME].asString(); 391 profile.name = jsonProfile[USER_NAME].asString();
392 392 profile.tokenKey = token->GetKey();
393 profile.tokenType = token->GetType();
394 profile.tokenValue = tokenValue;
395
393 for (Json::ArrayIndex i = 0; i < jsonProfile[PERMISSIONS].size(); ++i) 396 for (Json::ArrayIndex i = 0; i < jsonProfile[PERMISSIONS].size(); ++i)
394 { 397 {
395 profile.permissions.insert(jsonProfile[PERMISSIONS][i].asString()); 398 profile.permissions.insert(jsonProfile[PERMISSIONS][i].asString());
396 } 399 }
397 for (Json::ArrayIndex i = 0; i < jsonProfile[AUTHORIZED_LABELS].size(); ++i) 400 for (Json::ArrayIndex i = 0; i < jsonProfile[AUTHORIZED_LABELS].size(); ++i)
412 } 415 }
413 } 416 }
414 417
415 bool AuthorizationWebService::HasUserPermissionInternal(unsigned int& validity, 418 bool AuthorizationWebService::HasUserPermissionInternal(unsigned int& validity,
416 const std::string& permission, 419 const std::string& permission,
417 const Token* token, 420 const UserProfile& profile)
418 const std::string& tokenValue) 421 {
419 { 422 const std::set<std::string>& permissions = profile.permissions;
420 UserProfile profile; 423 for (std::set<std::string>::const_iterator it = permissions.begin(); it != permissions.end(); ++it)
421 424 {
422 425 if (permission == *it)
423 if (GetUserProfileInternal(validity, profile, token, tokenValue)) 426 {
424 { 427 return true;
425 std::set<std::string>& permissions = profile.permissions;
426 for (std::set<std::string>::const_iterator it = permissions.begin(); it != permissions.end(); ++it)
427 {
428 if (permission == *it)
429 {
430 return true;
431 }
432 } 428 }
433 } 429 }
434 430
435 return false; 431 return false;
436 } 432 }