Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aspnetcore/src/Interface/ApiConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
16 changes: 15 additions & 1 deletion aspnetcore/src/Interface/Controllers/FunderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,11 +14,14 @@ public class FunderController : ControllerBase
{
private readonly ImportDbContext _importDbContext;
private readonly ILogger<FunderController> _logger;
private readonly IDiagnosticContext _diagnosticContext;

public FunderController(ImportDbContext importDbContext, ILogger<FunderController> logger)
public FunderController(ImportDbContext importDbContext, ILogger<FunderController> logger, IDiagnosticContext diagnosticContext)
{
_importDbContext = importDbContext;
_logger = logger;
_diagnosticContext = diagnosticContext;
_diagnosticContext.Set(ApiConstants.LogResourceType_PropertyName, ApiConstants.LogResourceType_Publication);
}

/// <summary>
Expand All @@ -28,6 +32,8 @@ public FunderController(ImportDbContext importDbContext, ILogger<FunderControlle
/// <returns>Collection of <see cref="GrantedFundingToPublication"/></returns>
[HttpGet("{grantedFundingId}/publications/{organizationId}", Name = "GetGrantedFundingToPublications")]
[Authorize(Policy = ApiPolicies.Funder.Read)]
[Produces(ApiConstants.ContentTypeJson)]
[Consumes(ApiConstants.ContentTypeJson)]
[ProducesResponseType(typeof(IEnumerable<GrantedFundingToPublication>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async IAsyncEnumerable<GrantedFundingToPublication> GetGrantedFundingPublications(string grantedFundingId, string organizationId)
Expand Down Expand Up @@ -67,6 +73,8 @@ public async IAsyncEnumerable<GrantedFundingToPublication> GetGrantedFundingPubl
/// <returns><see cref="GrantedFundingPublication"/></returns>
[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<IActionResult> PostGrantedFundingToPublication(string grantedFundingId, string organizationId, [FromBody] PostGrantedFundingToPublication postGrantedFundingToPublicationModel)
Expand Down Expand Up @@ -128,6 +136,8 @@ await _importDbContext.ImpLinkGrantedFundingToPublications
/// <returns><see cref="GrantedFundingToPublication"/></returns>
[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<IActionResult> GetGrantedFundingToPublication(string grantedFundingId, string organizationId, string publicationIdentifier)
Expand Down Expand Up @@ -163,6 +173,8 @@ public async Task<IActionResult> GetGrantedFundingToPublication(string grantedFu
/// <returns><see cref="GrantedFunding"/></returns>
[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<IActionResult> PutGrantedFundingToPublication(string grantedFundingId, string organizationId, string publicationIdentifier, [FromBody] GrantedFundingToPublication grantedFundingToPublicationModel)
Expand Down Expand Up @@ -199,6 +211,8 @@ public async Task<IActionResult> PutGrantedFundingToPublication(string grantedFu
/// <param name="publicationIdentifier">Publication identifier.</param>
[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<IActionResult> DeleteGrantedFundingToPublication(string grantedFundingId, string organizationId, string publicationIdentifier)
Expand Down
5 changes: 4 additions & 1 deletion aspnetcore/src/Interface/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
builder.Services.Configure<ForwardedHeadersOptions>(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);
Expand Down
Loading