public async Task <ActionResult> Update(string clientId) { ClientUpdateModel model = new ClientUpdateModel(); GetClientByClientIdDto getClientByClientIdDto = await Mediator.Send(new GetClientByClientIdQuery { ClientId = clientId }); if (getClientByClientIdDto != null && getClientByClientIdDto.Id > 0) { model = getClientByClientIdDto.ToClientUpdateModel(); model.AvailableScopes = await GetScopes(); model.AvailableClaims = await GetClaims(); return(View(model)); } return(RedirectToAction("List")); }
public async Task <Client> FindClientByIdAsync(string clientId) { List <Client> defaultClients = new List <Client>(); object section = ConfigurationManager.GetSection("defaultClientsSection"); if (clientId == "dtwinauthclient") { return(new Client { ClientId = "dtwinauthclient", ClientName = "Duy Tan Windown Authenticate client", Enabled = true, Flow = Flows.Custom, AllowedCustomGrantTypes = new List <string> { "windows" }, AllowedScopes = new List <string> { "openid", "profile", "roles", "admindocumentmvc", "admindocumentapi", "documentmvc", "documentapi", "masterdataapi" }, ClientSecrets = new List <Secret> { new Secret("secret".Sha256()), }, RequireConsent = false, AccessTokenType = AccessTokenType.Jwt }); } if (section != null) { DefaultClientSettings clients = (section as DefaultClientsSection).DefaultClientSettings; if (clients != null && clients.Count > 0) { defaultClients.AddRange(clients.Cast <DefaultClientSetting>() .Select(c => { if (c.Flow == Flows.ClientCredentials) { return(new Client { ClientId = c.ClientId, ClientName = c.ClientName, Flow = c.Flow, RequireConsent = c.RequireConsent, ClientSecrets = new List <Secret> { new Secret("967ef861-1b5f-4ea1-9fd9-b66c24a8335c".Sha256()) }, AllowedScopes = c.AllowedScopes.Split(';').ToList() }); } return(new Client { ClientId = c.ClientId, ClientName = c.ClientName, Flow = c.Flow, RequireConsent = c.RequireConsent, RedirectUris = c.RedirectUris.Split(';').ToList(), PostLogoutRedirectUris = c.PostLogoutRedirectUris.Split(';').ToList(), AllowedScopes = c.AllowedScopes.Split(';').ToList(), AllowedCorsOrigins = c.RedirectUris.Split(';').ToList() }); }) ); } } Client client = defaultClients.FirstOrDefault(c => c.ClientId == clientId); if (client == null) { GetClientByClientIdDto dtClient = await _mediator.Send(new GetClientByClientIdQuery { ClientId = clientId, }); if (dtClient != null && !string.IsNullOrEmpty(dtClient.ClientId)) { client = new Client { ClientId = dtClient.ClientId, ClientName = dtClient.ClientName, Flow = dtClient.Flow, RequireConsent = dtClient.RequireConsent, RedirectUris = dtClient.RedirectUris.Split(';').ToList(), AllowedCorsOrigins = dtClient.RedirectUris.Split(';').ToList(), PostLogoutRedirectUris = dtClient.PostLogoutRedirectUris.Split(';').ToList(), AllowedScopes = dtClient.Scopes.Split(';').ToList()/*new List<string> { * "openid", * "profile", * "roles", * "documentmvc", * "documentapi", * "masterdataapi" * }*/ }; } } return(client); }
public static ClientUpdateModel ToClientUpdateModel(this GetClientByClientIdDto dto) { return(dto.MapTo <GetClientByClientIdDto, ClientUpdateModel>()); }