diff --git a/aspnetcore/src/Interface/ApiConstants.cs b/aspnetcore/src/Interface/ApiConstants.cs index 118c753..b572fee 100644 --- a/aspnetcore/src/Interface/ApiConstants.cs +++ b/aspnetcore/src/Interface/ApiConstants.cs @@ -14,4 +14,5 @@ public static class ApiConstants public const string LogResourceType_Organization = "organization"; public const string LogResourceType_Publication = "publication"; public const string LogResourceType_ResearchDataset = "research_dataset"; + public const string LogResourceType_Funder = "funder"; } \ No newline at end of file diff --git a/aspnetcore/src/Interface/Controllers/FunderController.cs b/aspnetcore/src/Interface/Controllers/FunderController.cs index c823789..35d281c 100644 --- a/aspnetcore/src/Interface/Controllers/FunderController.cs +++ b/aspnetcore/src/Interface/Controllers/FunderController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Serilog; using ImpLinkGrantedFundingToPublication = CSC.PublicApi.Interface.Models.ImportDb.Entities.ImpLinkGrantedFundingToPublication; namespace CSC.PublicApi.Interface.Controllers; @@ -13,11 +14,14 @@ public class FunderController : ControllerBase { private readonly ImportDbContext _importDbContext; private readonly ILogger _logger; + private readonly IDiagnosticContext _diagnosticContext; - public FunderController(ImportDbContext importDbContext, ILogger logger) + public FunderController(ImportDbContext importDbContext, ILogger logger, IDiagnosticContext diagnosticContext) { _importDbContext = importDbContext; _logger = logger; + _diagnosticContext = diagnosticContext; + _diagnosticContext.Set(ApiConstants.LogResourceType_PropertyName, ApiConstants.LogResourceType_Publication); } /// @@ -28,6 +32,8 @@ public FunderController(ImportDbContext importDbContext, ILoggerCollection of [HttpGet("{grantedFundingId}/publications/{organizationId}", Name = "GetGrantedFundingToPublications")] [Authorize(Policy = ApiPolicies.Funder.Read)] + [Produces(ApiConstants.ContentTypeJson)] + [Consumes(ApiConstants.ContentTypeJson)] [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] public async IAsyncEnumerable GetGrantedFundingPublications(string grantedFundingId, string organizationId) @@ -67,6 +73,8 @@ public async IAsyncEnumerable GetGrantedFundingPubl /// [HttpPost("{grantedFundingId}/publications/{organizationId}", Name = "PostGrantedFundingToPublication")] [Authorize(Policy = ApiPolicies.Funder.Write)] + [Produces(ApiConstants.ContentTypeJson)] + [Consumes(ApiConstants.ContentTypeJson)] [ProducesResponseType(StatusCodes.Status201Created)] [ProducesResponseType(StatusCodes.Status409Conflict)] public async Task PostGrantedFundingToPublication(string grantedFundingId, string organizationId, [FromBody] PostGrantedFundingToPublication postGrantedFundingToPublicationModel) @@ -128,6 +136,8 @@ await _importDbContext.ImpLinkGrantedFundingToPublications /// [HttpGet("{grantedFundingId}/publications/{organizationId}/{publicationIdentifier}", Name = "GetGrantedFundingToPublication")] [Authorize(Policy = ApiPolicies.Funder.Read)] + [Produces(ApiConstants.ContentTypeJson)] + [Consumes(ApiConstants.ContentTypeJson)] [ProducesResponseType(typeof(GrantedFundingToPublication), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task GetGrantedFundingToPublication(string grantedFundingId, string organizationId, string publicationIdentifier) @@ -163,6 +173,8 @@ public async Task GetGrantedFundingToPublication(string grantedFu /// [HttpPut("{grantedFundingId}/publications/{organizationId}/{publicationIdentifier}", Name = "PutGrantedFundingToPublication")] [Authorize(Policy = ApiPolicies.Funder.Write)] + [Produces(ApiConstants.ContentTypeJson)] + [Consumes(ApiConstants.ContentTypeJson)] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task PutGrantedFundingToPublication(string grantedFundingId, string organizationId, string publicationIdentifier, [FromBody] GrantedFundingToPublication grantedFundingToPublicationModel) @@ -199,6 +211,8 @@ public async Task PutGrantedFundingToPublication(string grantedFu /// Publication identifier. [HttpDelete("{grantedFundingId}/publications/{organizationId}/{publicationIdentifier}", Name = "DeleteGrantedFundingToPublication")] [Authorize(Policy = ApiPolicies.Funder.Write)] + [Produces(ApiConstants.ContentTypeJson)] + [Consumes(ApiConstants.ContentTypeJson)] [ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task DeleteGrantedFundingToPublication(string grantedFundingId, string organizationId, string publicationIdentifier) diff --git a/aspnetcore/src/Interface/Program.cs b/aspnetcore/src/Interface/Program.cs index 7d47331..288c353 100644 --- a/aspnetcore/src/Interface/Program.cs +++ b/aspnetcore/src/Interface/Program.cs @@ -15,7 +15,10 @@ builder.Services.Configure(options => { options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; -}); + // The following two lines are added to trust the headers from the OpenShift router. + options.KnownNetworks.Clear(); + options.KnownProxies.Clear(); +}); // Register settings. builder.Services.AddSettings(builder.Configuration);