public async Task <IActionResult> NewKey([FromODataUri] string clientId) { var client = await _clientService.GetClient(clientId); if (client == null) { return(NotFound($"client with id {clientId} not found.")); } var privateKey = await client.NewClientCertificate(); await _clientService.UpdateClient(client); var createdClient = new ClientWithSecrets { Id = client.Id, AllowedScopes = client.AllowedScopes, Description = client.Description, Name = client.Name, Key = privateKey, KeyType = ClientSecretType.RsaPrivateKey, }; return(Updated(createdClient)); }
public async Task <IActionResult> Post([FromBody] Client client) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } client.Id = Guid.NewGuid().ToString(); var privateKey = await client.NewClientCertificate(); await _clientService.AddClient(client); var createdClient = new ClientWithSecrets { Id = client.Id, AllowedScopes = client.AllowedScopes, Description = client.Description, Name = client.Name, Key = privateKey, KeyType = ClientSecretType.RsaPrivateKey, }; return(Created(createdClient)); }