Hello @Kamesh Thank you so much for ur reply, I really appreciate this.
About my environment, I’m using Resident Service 1.2.1.2 Java 11.
Issue Description
To explain the issue more clearly, here is the scenario I am facing:
When I request an update to my personal data, specifically contact details such as an email address or phone number, the update process triggers a call from the Resident Service to the following endpoint in the masterdata service :
${mosip.kernel.masterdata.url}/v1/masterdata/machines/search
public ResponseWrapper<PageResponseDto<MachineSearchDto>> searchMachine(
@RequestBody @Valid RequestWrapper<SearchDtoWithoutLangCode> request) {
auditUtil.auditRequest(MasterDataConstant.SEARCH_API_IS_CALLED + MachineSearchDto.class.getCanonicalName(),
MasterDataConstant.AUDIT_SYSTEM,
MasterDataConstant.SEARCH_API_IS_CALLED + MachineSearchDto.class.getCanonicalName(),"ADM-906");
ResponseWrapper<PageResponseDto<MachineSearchDto>> responseWrapper = new ResponseWrapper<>();
responseWrapper.setResponse(machineService.searchMachine(request.getRequest()));
auditUtil.auditRequest(
String.format(MasterDataConstant.SUCCESSFUL_SEARCH, MachineSearchDto.class.getCanonicalName()),
MasterDataConstant.AUDIT_SYSTEM,
String.format(MasterDataConstant.SUCCESSFUL_SEARCH_DESC, MachineSearchDto.class.getCanonicalName()),"ADM-907");
return responseWrapper;
}
So as I said, the resident_service that makes this call.
As part of this process, the request enters the following method.
public List<Zone> getSubZones(String langCode) {
String userId = ((UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername();
ZoneUser zu=zoneUserRepository.findZoneByUserIdActiveAndNonDeleted(userId);
if(zu == null) {
logger.error("User {} not mapped to any zones!!", userId);
return Collections.emptyList();
}
List<Zone> zones = getZones();
String lang = (langCode==null || langCode.equals("all")) ? languageUtils.getDefaultLanguage() : langCode;
List<Zone> langSpecificZones = zones == null ? Collections.EMPTY_LIST : zones.stream().filter(i -> lang.equals(i.getLangCode()))
.collect(Collectors.toList());
List<Node<Zone>> tree = zoneTree.createTree(langSpecificZones);
Node<Zone> node = zoneTree.findNode(tree, zu.getZoneCode());
return zoneTree.getChildHierarchy(node);
}
String userId = ((UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername();
When this line is executed, the userId holds the following value:
service-account-mosip-resident-client
So my question is about this logic:
Is this behavior correct?
If not, what is the expected scenario?
Should it userId contain the authenticated userID instead?
If it should hold the authenticated user, this user only a resident ???
Thank you so much again.