@@ -8,30 +8,29 @@ namespace LearningHub.NHS.OpenAPI
88 using System . Collections . Generic ;
99 using System . IO ;
1010 using AspNetCore . Authentication . ApiKey ;
11+ using LearningHub . Nhs . Api . Authentication ;
1112 using LearningHub . Nhs . Caching ;
1213 using LearningHub . Nhs . Models . Enums ;
1314 using LearningHub . Nhs . Models . Extensions ;
1415 using LearningHub . NHS . OpenAPI . Auth ;
16+ using LearningHub . NHS . OpenAPI . Authentication ;
1517 using LearningHub . NHS . OpenAPI . Configuration ;
1618 using LearningHub . NHS . OpenAPI . Middleware ;
1719 using LearningHub . Nhs . OpenApi . Repositories ;
1820 using LearningHub . Nhs . OpenApi . Repositories . EntityFramework ;
1921 using LearningHub . Nhs . OpenApi . Services ;
2022 using Microsoft . AspNetCore . Authentication ;
2123 using Microsoft . AspNetCore . Authentication . JwtBearer ;
24+ using Microsoft . AspNetCore . Authorization ;
2225 using Microsoft . AspNetCore . Builder ;
2326 using Microsoft . AspNetCore . Hosting ;
24- using Microsoft . AspNetCore . Mvc . Authorization ;
2527 using Microsoft . EntityFrameworkCore ;
2628 using Microsoft . Extensions . Configuration ;
2729 using Microsoft . Extensions . DependencyInjection ;
2830 using Microsoft . Extensions . FileProviders ;
2931 using Microsoft . Extensions . Hosting ;
3032 using Microsoft . IdentityModel . Tokens ;
3133 using Microsoft . OpenApi . Models ;
32- using Microsoft . AspNetCore . Authorization ;
33- using LearningHub . NHS . OpenAPI . Authentication ;
34- using LearningHub . Nhs . Api . Authentication ;
3534
3635 /// <summary>
3736 /// The Startup class.
@@ -62,8 +61,12 @@ public void ConfigureServices(IServiceCollection services)
6261
6362 services . AddApiKeyAuth ( ) ;
6463
65- services . AddAuthentication ( )
66- . AddJwtBearer ( options =>
64+ services . AddAuthentication ( options =>
65+ {
66+ options . DefaultAuthenticateScheme = JwtBearerDefaults . AuthenticationScheme ;
67+ options . DefaultChallengeScheme = JwtBearerDefaults . AuthenticationScheme ;
68+ } )
69+ . AddJwtBearer ( options =>
6770 {
6871 options . Authority = this . Configuration . GetValue < string > ( "LearningHUbAuthServiceConfig:Authority" ) ;
6972 options . TokenValidationParameters = new TokenValidationParameters ( )
@@ -76,7 +79,7 @@ public void ConfigureServices(IServiceCollection services)
7679 } ) ;
7780
7881 services . AddCustomMiddleware ( ) ;
79- services . AddSingleton < IAuthorizationHandler , ReadWriteHandler > ( ) ;
82+ services . AddSingleton < IAuthorizationHandler , ReadWriteHandler > ( ) ;
8083 services . AddSingleton < IAuthorizationHandler , AuthorizeOrCallFromLHHandler > ( ) ;
8184
8285 services . AddRepositories ( this . Configuration ) ;
@@ -89,7 +92,6 @@ public void ConfigureServices(IServiceCollection services)
8992 services . AddControllers ( options =>
9093 {
9194 options . Filters . Add ( new HttpResponseExceptionFilter ( ) ) ;
92- options . Filters . Add ( new AuthorizeFilter ( ) ) ;
9395 } ) ;
9496
9597 services . AddMvc ( )
0 commit comments