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
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Bookmark;
using LearningHub.Nhs.OpenApi.Services.Interface.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

/// <summary>
/// Learning Hub Bookmark controller.
/// </summary>
[Route("Bookmark")]
[ApiController]
[Authorize]
public class BookmarkController : OpenApiControllerBase
{
private readonly IBookmarkService bookmarkService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/// </summary>
[Route("Catalogue")]
[Authorize]
[ApiController]
public class CatalogueController : OpenApiControllerBase
{
private readonly ICatalogueService catalogueService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace LearningHub.NHS.OpenAPI.Controllers
/// </summary>
[Route("Resource")]
[Authorize]
[ApiController]
public class ResourceController : OpenApiControllerBase
{
private const int MaxNumberOfReferenceIds = 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
using LearningHub.Nhs.OpenApi.Models.Configuration;
using LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories;
using LearningHub.Nhs.OpenApi.Services.Interface.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

/// <summary>
/// Search operations.
/// </summary>
[Authorize]
[Route("Search")]
[ApiController]
public class SearchController : OpenApiControllerBase
Expand Down
18 changes: 10 additions & 8 deletions OpenAPI/LearningHub.Nhs.OpenApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,29 @@ namespace LearningHub.NHS.OpenAPI
using System.Collections.Generic;
using System.IO;
using AspNetCore.Authentication.ApiKey;
using LearningHub.Nhs.Api.Authentication;
using LearningHub.Nhs.Caching;
using LearningHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.Extensions;
using LearningHub.NHS.OpenAPI.Auth;
using LearningHub.NHS.OpenAPI.Authentication;
using LearningHub.NHS.OpenAPI.Configuration;
using LearningHub.NHS.OpenAPI.Middleware;
using LearningHub.Nhs.OpenApi.Repositories;
using LearningHub.Nhs.OpenApi.Repositories.EntityFramework;
using LearningHub.Nhs.OpenApi.Services;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using Microsoft.AspNetCore.Authorization;
using LearningHub.NHS.OpenAPI.Authentication;
using LearningHub.Nhs.Api.Authentication;

/// <summary>
/// The Startup class.
Expand Down Expand Up @@ -62,8 +61,12 @@ public void ConfigureServices(IServiceCollection services)

services.AddApiKeyAuth();

services.AddAuthentication()
.AddJwtBearer(options =>
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.Authority = this.Configuration.GetValue<string>("LearningHUbAuthServiceConfig:Authority");
options.TokenValidationParameters = new TokenValidationParameters()
Expand All @@ -76,7 +79,7 @@ public void ConfigureServices(IServiceCollection services)
});

services.AddCustomMiddleware();
services.AddSingleton<IAuthorizationHandler, ReadWriteHandler>();
services.AddSingleton<IAuthorizationHandler, ReadWriteHandler>();
services.AddSingleton<IAuthorizationHandler, AuthorizeOrCallFromLHHandler>();

services.AddRepositories(this.Configuration);
Expand All @@ -89,7 +92,6 @@ public void ConfigureServices(IServiceCollection services)
services.AddControllers(options =>
{
options.Filters.Add(new HttpResponseExceptionFilter());
options.Filters.Add(new AuthorizeFilter());
});

services.AddMvc()
Expand Down
Loading