private async Task <SecurityPool> GetPoolIdFromRequest(HttpContext httpContext) { var acrValues = httpContext.Request.Query["acr_values"].ToString(); SecurityPool securityPool = null; if (!String.IsNullOrEmpty(acrValues)) { var poolId = Regex.Match(acrValues, @"[tenant:][^\s]+").Value.Replace("tenant:", ""); if (!String.IsNullOrEmpty(poolId)) { securityPool = await _poolManager.GetByIdAsync(poolId); } } return(securityPool); }
public async Task <IViewComponentResult> InvokeAsync(string id = null) { var poolObject = new Identity.Models.SecurityPool(); if (!string.IsNullOrEmpty(id)) { var objectId = id.Split('_'); var resourceType = objectId[0]; var poolId = objectId[1]; var directoryId = objectId[2]; ViewData["directoryId"] = directoryId; poolObject = await _poolManager.GetByIdAsync(poolId); } return(View(poolObject)); }
public async Task <IActionResult> FetchHierarchy([DataSourceRequest] DataSourceRequest request, string id, string clientId) { object model = null; if (string.IsNullOrEmpty(id)) { // client has been switched or initial request to the page var client = await _clientManager.GetByIdAsync(clientId); // HOTFIX: Directory manager requires tenantKey, not clientId var directories = await _directoryManager.GetDirectoriesWithMapAsync(client.TenantKey); model = directories.Select(x => new { id = $"{typeof(Directory).Name.ToString()}_{x.Id}", // id = [Directory]_[directoryId] Name = x.Name, hasChildren = x.DirectoryMap.Any() }); } else { // parse the tree node's string id to determine action var nodeInfo = id.Split('_'); var nodeType = nodeInfo[0]; switch (nodeType) { case "Directory": var directoryId = nodeInfo[1]; var poolMaps = await _directoryManager.GetDirectoryPoolsAsync(directoryId); var pools = new List <Identity.Models.SecurityPool>(); foreach (var pool in poolMaps) { var poolObject = await _poolManager.GetByIdAsync(pool.PoolId); pools.Add(poolObject); } model = pools.Select(x => new { id = $"{typeof(Identity.Models.SecurityPool).Name.ToString()}_{x.PoolId}_{directoryId}", // id = [secPool]_[poolId]_[directoryId] Name = x.Name, hasChildren = (_poolManager.GetRolesQuery(x.PoolId)).Any() }); break; case "SecurityPool": var poolId = nodeInfo[1]; var roles = await _poolManager.GetRolesAsync(poolId); directoryId = nodeInfo[2]; model = roles.Select(x => new { id = $"{typeof(Role).Name.ToString()}_{x.Id}_{poolId}_{directoryId}", // id = [role]_[roleid]_[poolId]_[directoryId] Name = x.Name, hasChildren = false }); break; default: break; } } return(new JsonResult(model, new Newtonsoft.Json.JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() })); // return Json(model.ToDataSourceResult(request)); }