patbef-ServiceOutside/ServiceOutside/Controllers/ExchangeController.cs

37 lines
1.2 KiB
C#
Raw Permalink Normal View History

2024-01-29 16:27:34 +01:00
using Microsoft.AspNetCore.Mvc;
using ServiceShared.Database;
using ServiceShared.Crypto;
using ServiceShared.Models.Response;
using ServiceShared.Models.Response.Exception;
namespace ServiceOutside.Controllers
{
[ApiController]
[Route("[controller]")]
public class ExchangeController : BaseController
{
/// <summary>
/// Constructor of ExchangeController, that getting instance of configuration, dbcontext and KeyPair
/// </summary>
/// <param name="configuration">Configuration from appsettings.json</param>
/// <param name="dbContext">DbContext</param>
/// <param name="keyPair">Server Curve25519 KeyPair</param>
public ExchangeController(IConfiguration configuration, DbContext dbContext, KeyPair keyPair) : base(configuration, dbContext, keyPair)
{
}
/// <summary>
/// Returns Public Key of outside service as json
/// </summary>
/// <returns>Json Response</returns>
[Route("key")]
[HttpPost]
public JsonResult key()
{
PublicKey response = new PublicKey() { key = this._KeyPair.PublicKey };
this.Debug(response, "RESPONSE");
return new JsonResult(response);
}
}
}