public async Task<IActionResult> AddClientSecret([FromRoute]string clientId, [FromBody]CreateSecretRequest request) { var client = await _configurationDbContext.Clients.SingleOrDefaultAsync(x => x.ClientId == clientId); if (client == null) { return NotFound(); } var secretToAdd = new ClientSecret { Description = request.Description, Value = request.Value.ToSha256(), Expiration = request.Expiration, Type = $"{request.Type}", ClientId = client.Id }; client.ClientSecrets = new List<ClientSecret> { secretToAdd }; await _configurationDbContext.SaveChangesAsync(); return CreatedAtAction(string.Empty, new SecretInfo { Id = secretToAdd.Id, Description = secretToAdd.Description, Expiration = secretToAdd.Expiration, Type = secretToAdd.Type, Value = "*****" }); }
public async Task <IActionResult> AddClientSecret([FromRoute] string clientId, [FromBody] CreateSecretRequest request) { var client = await _configurationDbContext.Clients.SingleOrDefaultAsync(x => x.ClientId == clientId); if (client == null) { return(NotFound()); } var newSecret = new ClientSecret { Description = request.Description, Value = request.Value.ToSha256(), Expiration = request.Expiration, Type = IdentityServerConstants.SecretTypes.SharedSecret, ClientId = client.Id }; client.ClientSecrets = new List <ClientSecret> { newSecret }; await _configurationDbContext.SaveChangesAsync(); return(CreatedAtAction(string.Empty, new SecretInfo { Id = newSecret.Id, Description = newSecret.Description, Expiration = newSecret.Expiration, Type = newSecret.Type, Value = GetClientSecretValue(newSecret) })); }