diff --git a/README.md b/README.md index edceaa317..2d26f0937 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ This is currently in **beta version** -The application is written in the **Asp.Net Core MVC - using .NET Core 2.2** +The application is written in the **Asp.Net Core MVC - using .NET Core 3.0** -**NOTE:** Works only with **IdentityServer4 version 2.3.0 and higher** 🚀 +**NOTE:** Works only with **IdentityServer4 version 3.0.0 and higher** 🚀 ## Requirements @@ -147,6 +147,13 @@ Add-Migration IdentityServerPersistedGrantsDbInit -context IdentityServerPersist Update-Database -context IdentityServerPersistedGrantDbContext ``` +#### Migrations for AuditLogging DbContext: + +```powershell +Add-Migration AuditLoggingDbInit -context AuditLoggingDbContext -output Data/Migrations/AuditLogging +Update-Database -context AuditLoggingDbContext +``` + ### Or via `dotnet CLI`: #### Migrations for Asp.Net Core Identity DbContext: @@ -177,13 +184,20 @@ dotnet ef migrations add IdentityServerPersistedGrantsDbInit -c IdentityServerPe dotnet ef database update -c IdentityServerPersistedGrantDbContext ``` +#### Migrations for AuditLogging DbContext: + +```powershell +dotnet ef migrations add AuditLoggingDbInit -c AuditLoggingDbContext -o Data/Migrations/AuditLogging +dotnet ef database update -c AuditLoggingDbContext +``` + Migrations are not a part of the repository - they are ignored in `.gitignore`. ### We suggest to use seed data: - In `Program.cs` -> `Main`, uncomment `DbMigrationHelpers.EnsureSeedData(host)` or use dotnet CLI `dotnet run /seed` -- The `Clients` and `Resources` files in `Configuration/IdentityServer` are the initial data, based on a sample from IdentityServer4 -- The `Users` file in `Configuration/Identity` contains the default admin username and password for the first login +- The `Clients` and `Resources` files in `appsettings.json` (section called: IdentityServerData) - are the initial data, based on a sample from IdentityServer4 +- The `Users` file in `appsettings.json` (section called: IdentityData) contains the default admin username and password for the first login ### Using other database engines - PostgreSQL, SQLite, MySQL etc. @@ -191,9 +205,8 @@ Migrations are not a part of the repository - they are ignored in `.gitignore`. ## Authentication and Authorization -- Change the specific URLs and names for the IdentityServer and Authentication settings in `Constants/AuthenticationConsts` or `appsettings.json` -- `Constants/AuthorizationConsts.cs` contains configuration of constants connected with authorization - definition of the default name of admin policy -- In the controllers is used the policy which name is stored in - `AuthorizationConsts.AdministrationPolicy`. In the policy - `AuthorizationConsts.AdministrationPolicy` is defined required role stored in - `AuthorizationConsts.AdministrationRole`. +- Change the specific URLs and names for the IdentityServer and Authentication settings in `appsettings.json` +- In the controllers is used the policy which name is stored in - `AuthorizationConsts.AdministrationPolicy`. In the policy - `AuthorizationConsts.AdministrationPolicy` is defined required role stored in - `appsettings.json` - `AdministrationRole`. - With the default configuration, it is necessary to configure and run instance of IdentityServer4. It is possible to use initial migration for creating the client as it mentioned above ### Login Configuration @@ -447,9 +460,7 @@ It is possible to define the configuration according the client type - by defaul - [x] IdentityServer4 - [x] Asp.Net Core Identity - [x] Add swagger support - -### 1.1.0 -- [ ] Add audit logs to track changes ([#61](https://github.com/skoruba/IdentityServer4.Admin/issues/61)) +[x] Add audit logs to track changes ([#61](https://github.com/skoruba/IdentityServer4.Admin/issues/61)) ### 2.0.0: diff --git a/src/Skoruba.IdentityServer4.Admin.Api/AuditLogging/ApiAuditSubject.cs b/src/Skoruba.IdentityServer4.Admin.Api/AuditLogging/ApiAuditSubject.cs index 87c070266..efae29aab 100644 --- a/src/Skoruba.IdentityServer4.Admin.Api/AuditLogging/ApiAuditSubject.cs +++ b/src/Skoruba.IdentityServer4.Admin.Api/AuditLogging/ApiAuditSubject.cs @@ -15,7 +15,7 @@ public ApiAuditSubject(IHttpContextAccessor accessor, AuditLoggingConfiguration var clientIdClaim = accessor.HttpContext.User.FindFirst(auditLoggingConfiguration.ClientIdClaim); SubjectIdentifier = subClaim == null ? clientIdClaim.Value : subClaim.Value; - SubjectName = subClaim == null ? clientIdClaim.Value : nameClaim.Value; + SubjectName = subClaim == null ? clientIdClaim.Value : nameClaim?.Value; SubjectType = subClaim == null ? AuditSubjectTypes.Machine : AuditSubjectTypes.User; SubjectAdditionalData = new diff --git a/src/Skoruba.IdentityServer4.Admin.Api/Configuration/Authorization/AuthorizeCheckOperationFilter.cs b/src/Skoruba.IdentityServer4.Admin.Api/Configuration/Authorization/AuthorizeCheckOperationFilter.cs index f94309e84..d927b05d1 100644 --- a/src/Skoruba.IdentityServer4.Admin.Api/Configuration/Authorization/AuthorizeCheckOperationFilter.cs +++ b/src/Skoruba.IdentityServer4.Admin.Api/Configuration/Authorization/AuthorizeCheckOperationFilter.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Authorization; -using Swashbuckle.AspNetCore.Swagger; +using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; namespace Skoruba.IdentityServer4.Admin.Api.Configuration.Authorization @@ -14,8 +14,7 @@ public AuthorizeCheckOperationFilter(AdminApiConfiguration adminApiConfiguration { _adminApiConfiguration = adminApiConfiguration; } - - public void Apply(Operation operation, OperationFilterContext context) + public void Apply(OpenApiOperation operation, OperationFilterContext context) { var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true) .Union(context.MethodInfo.GetCustomAttributes(true)) @@ -23,11 +22,20 @@ public void Apply(Operation operation, OperationFilterContext context) if (hasAuthorize) { - operation.Responses.Add("401", new Response { Description = "Unauthorized" }); - operation.Responses.Add("403", new Response { Description = "Forbidden" }); - - operation.Security = new List>> { - new Dictionary> {{"oauth2", new[] { _adminApiConfiguration.OidcApiName } }} + operation.Responses.Add("401", new OpenApiResponse { Description = "Unauthorized" }); + operation.Responses.Add("403", new OpenApiResponse { Description = "Forbidden" }); + var oAuthScheme = new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "oauth2" + } + }; + operation.Security = new List { + new OpenApiSecurityRequirement { + [oAuthScheme] = new[] { _adminApiConfiguration.OidcApiName } + } }; } } diff --git a/src/Skoruba.IdentityServer4.Admin.Api/Helpers/StartupHelpers.cs b/src/Skoruba.IdentityServer4.Admin.Api/Helpers/StartupHelpers.cs index ba8e40e6d..9127c864e 100644 --- a/src/Skoruba.IdentityServer4.Admin.Api/Helpers/StartupHelpers.cs +++ b/src/Skoruba.IdentityServer4.Admin.Api/Helpers/StartupHelpers.cs @@ -82,8 +82,7 @@ public static IServiceCollection AddAuditEventLogging), typeof(GenericControllerLocalizer<>)); - services.AddMvc(o => { o.Conventions.Add(new GenericControllerRouteConvention()); }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) + services.AddControllersWithViews(o => { o.Conventions.Add(new GenericControllerRouteConvention()); }) .AddDataAnnotationsLocalization() .ConfigureApplicationPartManager(m => { diff --git a/src/Skoruba.IdentityServer4.Admin.Api/Program.cs b/src/Skoruba.IdentityServer4.Admin.Api/Program.cs index 3112ee351..e8fd12e41 100644 --- a/src/Skoruba.IdentityServer4.Admin.Api/Program.cs +++ b/src/Skoruba.IdentityServer4.Admin.Api/Program.cs @@ -15,6 +15,7 @@ public static void Main(string[] args) public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) + .UseIISIntegration() .UseStartup(); } } diff --git a/src/Skoruba.IdentityServer4.Admin.Api/Skoruba.IdentityServer4.Admin.Api.csproj b/src/Skoruba.IdentityServer4.Admin.Api/Skoruba.IdentityServer4.Admin.Api.csproj index 73af90ce8..f24339354 100644 --- a/src/Skoruba.IdentityServer4.Admin.Api/Skoruba.IdentityServer4.Admin.Api.csproj +++ b/src/Skoruba.IdentityServer4.Admin.Api/Skoruba.IdentityServer4.Admin.Api.csproj @@ -1,44 +1,46 @@  - - netcoreapp2.2 - InProcess - 1cc472a2-4e4b-48ce-846b-5219f71fc643 - + + netcoreapp3.0 + 1cc472a2-4e4b-48ce-846b-5219f71fc643 + - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - True - True - ApiErrorResource.resx - - + + + True + True + ApiErrorResource.resx + + - - - ResXFileCodeGenerator - ApiErrorResource.Designer.cs - - + + + ResXFileCodeGenerator + ApiErrorResource.Designer.cs + + diff --git a/src/Skoruba.IdentityServer4.Admin.Api/Startup.cs b/src/Skoruba.IdentityServer4.Admin.Api/Startup.cs index 571cc7489..5503c086f 100644 --- a/src/Skoruba.IdentityServer4.Admin.Api/Startup.cs +++ b/src/Skoruba.IdentityServer4.Admin.Api/Startup.cs @@ -4,6 +4,8 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.OpenApi.Models; using Skoruba.AuditLogging.EntityFramework.Entities; using Skoruba.IdentityServer4.Admin.Api.Configuration; using Skoruba.IdentityServer4.Admin.Api.Configuration.Authorization; @@ -20,7 +22,7 @@ namespace Skoruba.IdentityServer4.Admin.Api { public class Startup { - public Startup(IHostingEnvironment env) + public Startup(IWebHostEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) @@ -40,7 +42,7 @@ public Startup(IHostingEnvironment env) public IConfiguration Configuration { get; } - public IHostingEnvironment HostingEnvironment { get; } + public IWebHostEnvironment HostingEnvironment { get; } public void ConfigureServices(IServiceCollection services) { @@ -77,24 +79,29 @@ public void ConfigureServices(IServiceCollection services) services.AddSwaggerGen(options => { - options.SwaggerDoc(adminApiConfiguration.ApiVersion, new Info { Title = adminApiConfiguration.ApiName, Version = adminApiConfiguration.ApiVersion }); + options.SwaggerDoc(adminApiConfiguration.ApiVersion, new OpenApiInfo { Title = adminApiConfiguration.ApiName, Version = adminApiConfiguration.ApiVersion }); - options.AddSecurityDefinition("oauth2", new OAuth2Scheme + options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme { - Flow = "implicit", - AuthorizationUrl = $"{adminApiConfiguration.IdentityServerBaseUrl}/connect/authorize", - Scopes = new Dictionary { - { adminApiConfiguration.OidcApiName, adminApiConfiguration.ApiName } + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows + { + Implicit = new OpenApiOAuthFlow + { + AuthorizationUrl = new Uri($"{adminApiConfiguration.IdentityServerBaseUrl}/connect/authorize"), + Scopes = new Dictionary { + { adminApiConfiguration.OidcApiName, adminApiConfiguration.ApiName } + } + } } }); - options.OperationFilter(); }); services.AddAuditEventLogging(Configuration); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env, AdminApiConfiguration adminApiConfiguration) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AdminApiConfiguration adminApiConfiguration) { app.AddLogging(Configuration); @@ -104,7 +111,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, AdminApi } app.UseAuthentication(); - app.UseSwagger(); app.UseSwaggerUI(c => { @@ -114,7 +120,9 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, AdminApi c.OAuthAppName(adminApiConfiguration.ApiName); }); - app.UseMvc(); + app.UseRouting(); + app.UseAuthorization(); + app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); }); } } } diff --git a/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity/Mappers/IdentityMapperProfile.cs b/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity/Mappers/IdentityMapperProfile.cs index 2be36e2bc..413c74dff 100644 --- a/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity/Mappers/IdentityMapperProfile.cs +++ b/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity/Mappers/IdentityMapperProfile.cs @@ -94,7 +94,8 @@ public IdentityMapperProfile() CreateMap(MemberList.Destination); // model to entity - CreateMap(MemberList.Source); + CreateMap(MemberList.Source) + .ForMember(dest => dest.Id, opt => opt.Condition(srs => srs.Id != null)); ; CreateMap(MemberList.Source); @@ -103,7 +104,8 @@ public IdentityMapperProfile() opt => opt.MapFrom(src => src.ClaimId)); // model to entity - CreateMap(MemberList.Source); + CreateMap(MemberList.Source) + .ForMember(dest => dest.Id, opt => opt.Condition(srs => srs.Id != null)); ; } } } \ No newline at end of file diff --git a/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity.csproj b/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity.csproj index 435da070b..97c7afb42 100644 --- a/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity.csproj +++ b/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity/Skoruba.IdentityServer4.Admin.BusinessLogic.Identity.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netcoreapp3.0 1.0.0-beta7 Jan Škoruba Business Logic layer for the administration of the Asp.Net Core Identity and IdentityServer4 @@ -12,8 +12,8 @@ - - + + diff --git a/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Shared/Skoruba.IdentityServer4.Admin.BusinessLogic.Shared.csproj b/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Shared/Skoruba.IdentityServer4.Admin.BusinessLogic.Shared.csproj index 858289418..1316be6fa 100644 --- a/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Shared/Skoruba.IdentityServer4.Admin.BusinessLogic.Shared.csproj +++ b/src/Skoruba.IdentityServer4.Admin.BusinessLogic.Shared/Skoruba.IdentityServer4.Admin.BusinessLogic.Shared.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netcoreapp3.0 1.0.0-beta7 Jan Škoruba IdentityServer4 Admin OpenIDConnect OAuth2 Identity diff --git a/src/Skoruba.IdentityServer4.Admin.BusinessLogic/Skoruba.IdentityServer4.Admin.BusinessLogic.csproj b/src/Skoruba.IdentityServer4.Admin.BusinessLogic/Skoruba.IdentityServer4.Admin.BusinessLogic.csproj index 9a5b8a421..ff4ea8761 100644 --- a/src/Skoruba.IdentityServer4.Admin.BusinessLogic/Skoruba.IdentityServer4.Admin.BusinessLogic.csproj +++ b/src/Skoruba.IdentityServer4.Admin.BusinessLogic/Skoruba.IdentityServer4.Admin.BusinessLogic.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netcoreapp3.0 1.0.0-beta7 Jan Škoruba Business Logic layer for the administration of the IdentityServer4 @@ -12,7 +12,7 @@ - + diff --git a/src/Skoruba.IdentityServer4.Admin.EntityFramework.Extensions/Skoruba.IdentityServer4.Admin.EntityFramework.Extensions.csproj b/src/Skoruba.IdentityServer4.Admin.EntityFramework.Extensions/Skoruba.IdentityServer4.Admin.EntityFramework.Extensions.csproj index cb54ed775..a0badf826 100644 --- a/src/Skoruba.IdentityServer4.Admin.EntityFramework.Extensions/Skoruba.IdentityServer4.Admin.EntityFramework.Extensions.csproj +++ b/src/Skoruba.IdentityServer4.Admin.EntityFramework.Extensions/Skoruba.IdentityServer4.Admin.EntityFramework.Extensions.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netcoreapp3.0 1.0.0-beta7 Jan Škoruba IdentityServer4 Admin OpenIDConnect OAuth2 Identity diff --git a/src/Skoruba.IdentityServer4.Admin.EntityFramework.Identity/Skoruba.IdentityServer4.Admin.EntityFramework.Identity.csproj b/src/Skoruba.IdentityServer4.Admin.EntityFramework.Identity/Skoruba.IdentityServer4.Admin.EntityFramework.Identity.csproj index cf7daf569..52635ce5c 100644 --- a/src/Skoruba.IdentityServer4.Admin.EntityFramework.Identity/Skoruba.IdentityServer4.Admin.EntityFramework.Identity.csproj +++ b/src/Skoruba.IdentityServer4.Admin.EntityFramework.Identity/Skoruba.IdentityServer4.Admin.EntityFramework.Identity.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netcoreapp3.0 1.0.0-beta7 Jan Škoruba Entity Framework layer for the administration of the Asp.Net Core Identity and IdentityServer4 @@ -12,8 +12,8 @@ - - + + diff --git a/src/Skoruba.IdentityServer4.Admin.EntityFramework.Shared/Skoruba.IdentityServer4.Admin.EntityFramework.Shared.csproj b/src/Skoruba.IdentityServer4.Admin.EntityFramework.Shared/Skoruba.IdentityServer4.Admin.EntityFramework.Shared.csproj index 0a1bfa6a8..9a5a248c3 100644 --- a/src/Skoruba.IdentityServer4.Admin.EntityFramework.Shared/Skoruba.IdentityServer4.Admin.EntityFramework.Shared.csproj +++ b/src/Skoruba.IdentityServer4.Admin.EntityFramework.Shared/Skoruba.IdentityServer4.Admin.EntityFramework.Shared.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netcoreapp3.0 1.0.0-beta7 Jan Škoruba IdentityServer4 Admin OpenIDConnect OAuth2 Identity @@ -12,7 +12,7 @@ - + diff --git a/src/Skoruba.IdentityServer4.Admin.EntityFramework/Repositories/AuditLogRepository.cs b/src/Skoruba.IdentityServer4.Admin.EntityFramework/Repositories/AuditLogRepository.cs index fe18dbbea..eb612fff6 100644 --- a/src/Skoruba.IdentityServer4.Admin.EntityFramework/Repositories/AuditLogRepository.cs +++ b/src/Skoruba.IdentityServer4.Admin.EntityFramework/Repositories/AuditLogRepository.cs @@ -26,13 +26,13 @@ public async Task> GetAsync(string @event, string source, s var pagedList = new PagedList(); var auditLogs = await DbContext.AuditLog - .PageBy(x => x.Id, page, pageSize) .WhereIf(!string.IsNullOrEmpty(subjectIdentifier), log => log.SubjectIdentifier.Contains(subjectIdentifier)) .WhereIf(!string.IsNullOrEmpty(subjectName), log => log.SubjectName.Contains(subjectName)) .WhereIf(!string.IsNullOrEmpty(@event), log => log.Event.Contains(@event)) .WhereIf(!string.IsNullOrEmpty(source), log => log.Source.Contains(source)) .WhereIf(!string.IsNullOrEmpty(category), log => log.Category.Contains(category)) .WhereIf(created.HasValue, log => log.Created.Date == created.Value.Date) + .PageBy(x => x.Id, page, pageSize) .ToListAsync(); pagedList.Data.AddRange(auditLogs); diff --git a/src/Skoruba.IdentityServer4.Admin.EntityFramework/Skoruba.IdentityServer4.Admin.EntityFramework.csproj b/src/Skoruba.IdentityServer4.Admin.EntityFramework/Skoruba.IdentityServer4.Admin.EntityFramework.csproj index 3a5a8fa55..fdf80efb0 100644 --- a/src/Skoruba.IdentityServer4.Admin.EntityFramework/Skoruba.IdentityServer4.Admin.EntityFramework.csproj +++ b/src/Skoruba.IdentityServer4.Admin.EntityFramework/Skoruba.IdentityServer4.Admin.EntityFramework.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netcoreapp3.0 1.0.0-beta7 Jan Škoruba IdentityServer4 Admin OpenIDConnect OAuth2 Identity @@ -12,8 +12,8 @@ - - + + diff --git a/src/Skoruba.IdentityServer4.Admin/Controllers/LogController.cs b/src/Skoruba.IdentityServer4.Admin/Controllers/LogController.cs index 2acfdd22c..4599af6a7 100644 --- a/src/Skoruba.IdentityServer4.Admin/Controllers/LogController.cs +++ b/src/Skoruba.IdentityServer4.Admin/Controllers/LogController.cs @@ -47,28 +47,28 @@ public async Task AuditLog([FromQuery]AuditLogFilterDto filters) [HttpPost] [ValidateAntiForgeryToken] - public async Task DeleteLogs(LogsDto logs) + public async Task DeleteLogs(LogsDto log) { if (!ModelState.IsValid) { - return View(nameof(ErrorsLog), logs); + return View(nameof(ErrorsLog), log); } - await _logService.DeleteLogsOlderThanAsync(logs.DeleteOlderThan.Value); + await _logService.DeleteLogsOlderThanAsync(log.DeleteOlderThan.Value); return RedirectToAction(nameof(ErrorsLog)); } [HttpPost] [ValidateAntiForgeryToken] - public async Task DeleteAuditLogs(AuditLogsDto logs) + public async Task DeleteAuditLogs(AuditLogsDto log) { if (!ModelState.IsValid) { - return View(nameof(AuditLog), logs); + return View(nameof(AuditLog), log); } - await _auditLogService.DeleteLogsOlderThanAsync(logs.DeleteOlderThan.Value); + await _auditLogService.DeleteLogsOlderThanAsync(log.DeleteOlderThan.Value); return RedirectToAction(nameof(AuditLog)); } diff --git a/src/Skoruba.IdentityServer4.Admin/Helpers/DbMigrationHelpers.cs b/src/Skoruba.IdentityServer4.Admin/Helpers/DbMigrationHelpers.cs index 9f72c78b4..c04b2a6fc 100644 --- a/src/Skoruba.IdentityServer4.Admin/Helpers/DbMigrationHelpers.cs +++ b/src/Skoruba.IdentityServer4.Admin/Helpers/DbMigrationHelpers.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Skoruba.IdentityServer4.Admin.Configuration.Interfaces; using Skoruba.IdentityServer4.Admin.EntityFramework.Interfaces; @@ -19,7 +20,7 @@ public static class DbMigrationHelpers /// https://github.com/skoruba/IdentityServer4.Admin#ef-core--data-access /// /// - public static async Task EnsureSeedData(IWebHost host) + public static async Task EnsureSeedData(IHost host) where TIdentityServerDbContext : DbContext, IAdminConfigurationDbContext where TIdentityDbContext : DbContext where TPersistedGrantDbContext : DbContext, IAdminPersistedGrantDbContext diff --git a/src/Skoruba.IdentityServer4.Admin/Helpers/PagerHelpers.cs b/src/Skoruba.IdentityServer4.Admin/Helpers/PagerHelpers.cs index c325ed5aa..d51851727 100644 --- a/src/Skoruba.IdentityServer4.Admin/Helpers/PagerHelpers.cs +++ b/src/Skoruba.IdentityServer4.Admin/Helpers/PagerHelpers.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.AspNetCore.Hosting.Internal; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; diff --git a/src/Skoruba.IdentityServer4.Admin/Helpers/StartupHelpers.cs b/src/Skoruba.IdentityServer4.Admin/Helpers/StartupHelpers.cs index 7d91f660e..cecb90094 100644 --- a/src/Skoruba.IdentityServer4.Admin/Helpers/StartupHelpers.cs +++ b/src/Skoruba.IdentityServer4.Admin/Helpers/StartupHelpers.cs @@ -2,9 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Reflection; -using System.Security.Claims; using System.Threading.Tasks; -using IdentityModel; using IdentityServer4.EntityFramework.Options; using IdentityServer4.EntityFramework.Storage; using Microsoft.AspNetCore.Authentication; @@ -44,8 +42,8 @@ using Skoruba.IdentityServer4.Admin.EntityFramework.Interfaces; using Skoruba.IdentityServer4.Admin.EntityFramework.Repositories; using Skoruba.IdentityServer4.Admin.EntityFramework.Repositories.Interfaces; -using Skoruba.IdentityServer4.Admin.EntityFramework.Shared.DbContexts; using Skoruba.IdentityServer4.Admin.Helpers.Localization; +using Microsoft.Extensions.Hosting; namespace Skoruba.IdentityServer4.Admin.Helpers { @@ -261,7 +259,7 @@ public static void UseSecurityHeaders(this IApplicationBuilder app) /// /// /// - public static void ConfigureAuthenticationServices(this IApplicationBuilder app, IHostingEnvironment env) + public static void ConfigureAuthenticationServices(this IApplicationBuilder app, IWebHostEnvironment env) { app.UseAuthentication(); @@ -301,7 +299,7 @@ public static void AddLogging(this IApplicationBuilder app, ILoggerFactory logge /// /// /// - public static void AddDbContexts(this IServiceCollection services, IHostingEnvironment hostingEnvironment, IConfigurationRoot configuration) + public static void AddDbContexts(this IServiceCollection services, IWebHostEnvironment hostingEnvironment, IConfigurationRoot configuration) where TContext : DbContext { if (hostingEnvironment.IsStaging()) @@ -325,7 +323,7 @@ public static void AddDbContexts(this IServiceCollection services, IHo /// /// /// - public static void AddDbContexts(this IServiceCollection services, IHostingEnvironment hostingEnvironment, IConfigurationRoot configuration) + public static void AddDbContexts(this IServiceCollection services, IWebHostEnvironment hostingEnvironment, IConfigurationRoot configuration) where TIdentityDbContext : DbContext where TPersistedGrantDbContext : DbContext, IAdminPersistedGrantDbContext where TConfigurationDbContext : DbContext, IAdminConfigurationDbContext @@ -399,11 +397,10 @@ public static void AddMvcExceptionFilters(this IServiceCollection services) services.TryAddTransient(typeof(IGenericControllerLocalizer<>), typeof(GenericControllerLocalizer<>)); - services.AddMvc(o => + services.AddControllersWithViews(o => { o.Conventions.Add(new GenericControllerRouteConvention()); }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddViewLocalization( LanguageViewLocationExpanderFormat.Suffix, opts => { opts.ResourcesPath = ConfigurationConsts.ResourcesPath; }) @@ -446,7 +443,7 @@ public static void AddMvcExceptionFilters(this IServiceCollection services) /// /// /// - public static void AddAuthenticationServices(this IServiceCollection services, IHostingEnvironment hostingEnvironment, IAdminConfiguration adminConfiguration) + public static void AddAuthenticationServices(this IServiceCollection services, IWebHostEnvironment hostingEnvironment, IAdminConfiguration adminConfiguration) where TContext : DbContext where TUserIdentity : class where TUserIdentityRole : class { services.AddIdentity(options => diff --git a/src/Skoruba.IdentityServer4.Admin/Program.cs b/src/Skoruba.IdentityServer4.Admin/Program.cs index 2384446c2..628047df5 100644 --- a/src/Skoruba.IdentityServer4.Admin/Program.cs +++ b/src/Skoruba.IdentityServer4.Admin/Program.cs @@ -1,7 +1,8 @@ -using System.Linq; +using System.IO; +using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Serilog; using Skoruba.IdentityServer4.Admin.EntityFramework.Shared.DbContexts; using Skoruba.IdentityServer4.Admin.EntityFramework.Shared.Entities.Identity; @@ -18,7 +19,7 @@ public static async Task Main(string[] args) var seed = args.Any(x => x == SeedArgs); if (seed) args = args.Except(new[] { SeedArgs }).ToArray(); - var host = CreateWebHostBuilder(args).Build(); + var host = CreateHostBuilder(args).Build(); // Uncomment this to seed upon startup, alternatively pass in `dotnet run /seed` to seed using CLI // await DbMigrationHelpers.EnsureSeedData(host); @@ -30,10 +31,15 @@ public static async Task Main(string[] args) host.Run(); } - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseKestrel(c => c.AddServerHeader = false) - .UseStartup() - .UseSerilog(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseContentRoot(Directory.GetCurrentDirectory()); + webBuilder.ConfigureKestrel(options => options.AddServerHeader = false); + webBuilder.UseIISIntegration(); + webBuilder.UseStartup(); + webBuilder.UseSerilog(); + }); } } \ No newline at end of file diff --git a/src/Skoruba.IdentityServer4.Admin/Skoruba.IdentityServer4.Admin.csproj b/src/Skoruba.IdentityServer4.Admin/Skoruba.IdentityServer4.Admin.csproj index 72e4ed4f5..18d31d21c 100644 --- a/src/Skoruba.IdentityServer4.Admin/Skoruba.IdentityServer4.Admin.csproj +++ b/src/Skoruba.IdentityServer4.Admin/Skoruba.IdentityServer4.Admin.csproj @@ -1,104 +1,107 @@  - - netcoreapp2.2 - latest - 8fe260ca-ef4c-4fa3-9364-029146f8d339 - + + netcoreapp3.0 + latest + 8fe260ca-ef4c-4fa3-9364-029146f8d339 + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + \ No newline at end of file diff --git a/src/Skoruba.IdentityServer4.Admin/Startup.cs b/src/Skoruba.IdentityServer4.Admin/Startup.cs index 85c92fb17..670ccdba7 100644 --- a/src/Skoruba.IdentityServer4.Admin/Startup.cs +++ b/src/Skoruba.IdentityServer4.Admin/Startup.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Skoruba.AuditLogging.EntityFramework.Entities; using Skoruba.IdentityServer4.Admin.BusinessLogic.Identity.Dtos.Identity; @@ -15,7 +16,7 @@ namespace Skoruba.IdentityServer4.Admin { public class Startup { - public Startup(IHostingEnvironment env) + public Startup(IWebHostEnvironment env) { JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); @@ -37,7 +38,7 @@ public Startup(IHostingEnvironment env) public IConfigurationRoot Configuration { get; } - public IHostingEnvironment HostingEnvironment { get; } + public IWebHostEnvironment HostingEnvironment { get; } public void ConfigureServices(IServiceCollection services) { @@ -65,7 +66,7 @@ public void ConfigureServices(IServiceCollection services) UsersDto, string>, RolesDto, string>, UserRolesDto, string, string>, UserClaimsDto, UserProviderDto, UserProvidersDto, UserChangePasswordDto, RoleClaimsDto, UserClaimDto, RoleClaimDto>(); - + // Add all dependencies for Asp.Net Core Identity in MVC - these dependencies are injected into generic Controllers // Including settings for MVC and Localization // If you want to change primary keys or use another db model for Asp.Net Core Identity: @@ -83,7 +84,7 @@ public void ConfigureServices(IServiceCollection services) services.AddAuditEventLogging(Configuration); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { app.AddLogging(loggerFactory, Configuration); @@ -107,10 +108,9 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF // Use Localization app.ConfigureLocalization(); - app.UseMvc(routes => - { - routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"); - }); + app.UseRouting(); + app.UseAuthorization(); + app.UseEndpoints(endpoint => { endpoint.MapDefaultControllerRoute(); }); } } } \ No newline at end of file diff --git a/src/Skoruba.IdentityServer4.Admin/web.config b/src/Skoruba.IdentityServer4.Admin/web.config index 3d49211e5..5e0ce7695 100644 --- a/src/Skoruba.IdentityServer4.Admin/web.config +++ b/src/Skoruba.IdentityServer4.Admin/web.config @@ -7,8 +7,11 @@ - - + + + + + \ No newline at end of file diff --git a/src/Skoruba.IdentityServer4.STS.Identity/Controllers/DiagnosticsController.cs b/src/Skoruba.IdentityServer4.STS.Identity/Controllers/DiagnosticsController.cs index 355f6fad1..e037e5450 100644 --- a/src/Skoruba.IdentityServer4.STS.Identity/Controllers/DiagnosticsController.cs +++ b/src/Skoruba.IdentityServer4.STS.Identity/Controllers/DiagnosticsController.cs @@ -20,8 +20,8 @@ public class DiagnosticsController : Controller { public async Task Index() { - var localAddresses = new string[] { "127.0.0.1", "::1", HttpContext.Connection.LocalIpAddress.ToString() }; - if (!localAddresses.Contains(HttpContext.Connection.RemoteIpAddress.ToString())) + var localAddresses = new string[] { "127.0.0.1", "::1", HttpContext.Connection?.LocalIpAddress?.ToString() }; + if (!localAddresses.Contains(HttpContext.Connection?.RemoteIpAddress?.ToString())) { return NotFound(); } diff --git a/src/Skoruba.IdentityServer4.STS.Identity/Helpers/StartupHelpers.cs b/src/Skoruba.IdentityServer4.STS.Identity/Helpers/StartupHelpers.cs index 74034a991..997f08f21 100644 --- a/src/Skoruba.IdentityServer4.STS.Identity/Helpers/StartupHelpers.cs +++ b/src/Skoruba.IdentityServer4.STS.Identity/Helpers/StartupHelpers.cs @@ -26,6 +26,7 @@ using Skoruba.IdentityServer4.STS.Identity.Helpers.Localization; using Skoruba.IdentityServer4.STS.Identity.Services; using ILogger = Microsoft.Extensions.Logging.ILogger; +using Microsoft.Extensions.Hosting; namespace Skoruba.IdentityServer4.STS.Identity.Helpers { @@ -42,12 +43,11 @@ public static void AddMvcWithLocalization(this IServiceCollection s services.AddLocalization(opts => { opts.ResourcesPath = ConfigurationConsts.ResourcesPath; }); services.TryAddTransient(typeof(IGenericControllerLocalizer<>), typeof(GenericControllerLocalizer<>)); - - services.AddMvc(o => + + services.AddControllersWithViews(o => { o.Conventions.Add(new GenericControllerRouteConvention()); }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddViewLocalization( LanguageViewLocationExpanderFormat.Suffix, opts => { opts.ResourcesPath = ConfigurationConsts.ResourcesPath; }) @@ -131,7 +131,7 @@ public static void AddEmailSenders(this IServiceCollection services, IConfigurat /// /// /// - public static void AddAuthenticationServices(this IServiceCollection services, IHostingEnvironment hostingEnvironment, IConfiguration configuration, ILogger logger) + public static void AddAuthenticationServices(this IServiceCollection services, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, ILogger logger) where TPersistedGrantDbContext : DbContext, IPersistedGrantDbContext where TConfigurationDbContext : DbContext, IConfigurationDbContext where TIdentityDbContext : DbContext @@ -231,7 +231,7 @@ public static IServiceCollection ConfigureRootConfiguration(this IServiceCollect /// private static void AddIdentityServer( IServiceCollection services, - IConfiguration configuration, ILogger logger, IHostingEnvironment hostingEnvironment) + IConfiguration configuration, ILogger logger, IWebHostEnvironment hostingEnvironment) where TUserIdentity : class where TPersistedGrantDbContext : DbContext, IPersistedGrantDbContext where TConfigurationDbContext : DbContext, IConfigurationDbContext @@ -279,7 +279,7 @@ private static void AddExternalProviders(AuthenticationBuilder authenticationBui /// /// public static void AddIdentityDbContext(this IServiceCollection services, - IConfiguration configuration, IHostingEnvironment hostingEnvironment) + IConfiguration configuration, IWebHostEnvironment hostingEnvironment) where TContext : DbContext { if (hostingEnvironment.IsStaging()) @@ -329,7 +329,7 @@ public static void AddDbContexts(this IServiceCollection services, ICo /// public static IIdentityServerBuilder AddIdentityServerStoresWithDbContexts(this IIdentityServerBuilder builder, IConfiguration configuration, - IHostingEnvironment hostingEnvironment) + IWebHostEnvironment hostingEnvironment) where TPersistedGrantDbContext : DbContext, IPersistedGrantDbContext where TConfigurationDbContext : DbContext, IConfigurationDbContext { diff --git a/src/Skoruba.IdentityServer4.STS.Identity/Program.cs b/src/Skoruba.IdentityServer4.STS.Identity/Program.cs index 2703eb948..4fe593c7f 100644 --- a/src/Skoruba.IdentityServer4.STS.Identity/Program.cs +++ b/src/Skoruba.IdentityServer4.STS.Identity/Program.cs @@ -9,12 +9,13 @@ public class Program public static void Main(string[] args) { CreateWebHostBuilder(args) - .UseSerilog() - .Build().Run(); + .UseSerilog() + .Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) + WebHost.CreateDefaultBuilder(args) + .UseIISIntegration() .UseStartup(); } } diff --git a/src/Skoruba.IdentityServer4.STS.Identity/Skoruba.IdentityServer4.STS.Identity.csproj b/src/Skoruba.IdentityServer4.STS.Identity/Skoruba.IdentityServer4.STS.Identity.csproj index 6c7a22af1..13ce1c9ba 100644 --- a/src/Skoruba.IdentityServer4.STS.Identity/Skoruba.IdentityServer4.STS.Identity.csproj +++ b/src/Skoruba.IdentityServer4.STS.Identity/Skoruba.IdentityServer4.STS.Identity.csproj @@ -1,33 +1,37 @@  - - netcoreapp2.2 - 9c91d295-54c5-4d09-9bd6-fa56fb74011b - + + netcoreapp3.0 + 9c91d295-54c5-4d09-9bd6-fa56fb74011b + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - + + + diff --git a/src/Skoruba.IdentityServer4.STS.Identity/Startup.cs b/src/Skoruba.IdentityServer4.STS.Identity/Startup.cs index 10cfff0f0..0d46bcb47 100644 --- a/src/Skoruba.IdentityServer4.STS.Identity/Startup.cs +++ b/src/Skoruba.IdentityServer4.STS.Identity/Startup.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Skoruba.IdentityServer4.Admin.EntityFramework.Shared.DbContexts; using Skoruba.IdentityServer4.Admin.EntityFramework.Shared.Entities.Identity; @@ -13,10 +14,10 @@ namespace Skoruba.IdentityServer4.STS.Identity public class Startup { public IConfiguration Configuration { get; } - public IHostingEnvironment Environment { get; } + public IWebHostEnvironment Environment { get; } public ILogger Logger { get; set; } - public Startup(IHostingEnvironment environment, ILoggerFactory loggerFactory) + public Startup(IWebHostEnvironment environment, ILoggerFactory loggerFactory) { var builder = new ConfigurationBuilder() .SetBasePath(environment.ContentRootPath) @@ -57,7 +58,7 @@ public void ConfigureServices(IServiceCollection services) services.AddAuthorizationPolicies(rootConfiguration); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { app.AddLogging(loggerFactory, Configuration); @@ -72,7 +73,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF app.UseStaticFiles(); app.UseIdentityServer(); app.UseMvcLocalizationServices(); - app.UseMvcWithDefaultRoute(); + + app.UseRouting(); + app.UseAuthorization(); + app.UseEndpoints(endpoint => { endpoint.MapDefaultControllerRoute(); }); } } } diff --git a/src/Skoruba.IdentityServer4.STS.Identity/Views/Shared/Error.cshtml b/src/Skoruba.IdentityServer4.STS.Identity/Views/Shared/Error.cshtml index 4a587e8cb..950e798d1 100644 --- a/src/Skoruba.IdentityServer4.STS.Identity/Views/Shared/Error.cshtml +++ b/src/Skoruba.IdentityServer4.STS.Identity/Views/Shared/Error.cshtml @@ -1,12 +1,13 @@ @using Microsoft.AspNetCore.Mvc.Localization @inject IViewLocalizer Localizer @using Microsoft.AspNetCore.Hosting +@using Microsoft.Extensions.Hosting @model Skoruba.IdentityServer4.STS.Identity.ViewModels.Home.ErrorViewModel -@inject IHostingEnvironment host +@inject IWebHostEnvironment Host @{ var error = Model?.Error?.Error; - var errorDescription = host.IsDevelopment() ? Model?.Error?.ErrorDescription : null; + var errorDescription = Host.IsDevelopment() ? Model?.Error?.ErrorDescription : null; var request_id = Model?.Error?.RequestId; } diff --git a/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Common/WebApplicationFactoryExtensions.cs b/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Common/WebApplicationFactoryExtensions.cs index 76ad9fe6b..e7f21379e 100644 --- a/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Common/WebApplicationFactoryExtensions.cs +++ b/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Common/WebApplicationFactoryExtensions.cs @@ -16,7 +16,7 @@ public static HttpClient SetupClient(this WebApplicationFactory fixture return fixture.WithWebHostBuilder( builder => builder - .UseEnvironment(EnvironmentName.Staging) + .UseEnvironment(Microsoft.Extensions.Hosting.Environments.Staging) .ConfigureTestServices(services => { }) ).CreateClient(options); } diff --git a/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Skoruba.IdentityServer4.Admin.IntegrationTests.csproj b/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Skoruba.IdentityServer4.Admin.IntegrationTests.csproj index 74883d67a..b091e502a 100644 --- a/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Skoruba.IdentityServer4.Admin.IntegrationTests.csproj +++ b/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Skoruba.IdentityServer4.Admin.IntegrationTests.csproj @@ -1,27 +1,26 @@  - netcoreapp2.2 + netcoreapp3.0 true false Full - + all runtime; build; native; contentfiles; analyzers - - - - + + + + all runtime; build; native; contentfiles; analyzers - diff --git a/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Tests/Base/BaseClassFixture.cs b/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Tests/Base/BaseClassFixture.cs index cb2ccc03f..a01e750f7 100644 --- a/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Tests/Base/BaseClassFixture.cs +++ b/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Tests/Base/BaseClassFixture.cs @@ -21,7 +21,7 @@ public BaseClassFixture(WebApplicationFactory factory) protected virtual void SetupAdminClaimsViaHeaders() { - using (var scope = Factory.Server.Host.Services.CreateScope()) + using (var scope = Factory.Services.CreateScope()) { var configuration = scope.ServiceProvider.GetRequiredService(); Client.SetAdminClaimsViaHeaders(configuration.AdminConfiguration); diff --git a/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Tests/ConfigurationControllerTests.cs b/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Tests/ConfigurationControllerTests.cs index edff1b0c1..64d57c475 100644 --- a/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Tests/ConfigurationControllerTests.cs +++ b/tests/Skoruba.IdentityServer4.Admin.IntegrationTests/Tests/ConfigurationControllerTests.cs @@ -41,7 +41,7 @@ public async Task ReturnRedirectWithoutAdminRole() { //Remove Client.DefaultRequestHeaders.Clear(); - + foreach (var route in RoutesConstants.GetConfigureRoutes()) { // Act diff --git a/tests/Skoruba.IdentityServer4.Admin.UnitTests/Controllers/ConfigurationControllerTests.cs b/tests/Skoruba.IdentityServer4.Admin.UnitTests/Controllers/ConfigurationControllerTests.cs index a31a77b5a..51cb4ba73 100644 --- a/tests/Skoruba.IdentityServer4.Admin.UnitTests/Controllers/ConfigurationControllerTests.cs +++ b/tests/Skoruba.IdentityServer4.Admin.UnitTests/Controllers/ConfigurationControllerTests.cs @@ -822,7 +822,6 @@ private IServiceProvider GetServices() services.AddSession(); services.AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddViewLocalization( LanguageViewLocationExpanderFormat.Suffix, opts => { opts.ResourcesPath = "Resources"; }) diff --git a/tests/Skoruba.IdentityServer4.Admin.UnitTests/Controllers/IdentityControllerTests.cs b/tests/Skoruba.IdentityServer4.Admin.UnitTests/Controllers/IdentityControllerTests.cs index 5b0690c03..93fba21d1 100644 --- a/tests/Skoruba.IdentityServer4.Admin.UnitTests/Controllers/IdentityControllerTests.cs +++ b/tests/Skoruba.IdentityServer4.Admin.UnitTests/Controllers/IdentityControllerTests.cs @@ -614,8 +614,7 @@ private IServiceProvider GetServices() services.TryAddTransient(typeof(IGenericControllerLocalizer<>), typeof(GenericControllerLocalizer<>)); - services.AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) + services.AddControllersWithViews() .AddViewLocalization( LanguageViewLocationExpanderFormat.Suffix, opts => { opts.ResourcesPath = "Resources"; }) diff --git a/tests/Skoruba.IdentityServer4.Admin.UnitTests/Skoruba.IdentityServer4.Admin.UnitTests.csproj b/tests/Skoruba.IdentityServer4.Admin.UnitTests/Skoruba.IdentityServer4.Admin.UnitTests.csproj index 7db71b7cf..55de22551 100644 --- a/tests/Skoruba.IdentityServer4.Admin.UnitTests/Skoruba.IdentityServer4.Admin.UnitTests.csproj +++ b/tests/Skoruba.IdentityServer4.Admin.UnitTests/Skoruba.IdentityServer4.Admin.UnitTests.csproj @@ -1,13 +1,13 @@  - netcoreapp2.2 + netcoreapp3.0 Full false - + all runtime; build; native; contentfiles; analyzers @@ -17,11 +17,10 @@ runtime; build; native; contentfiles; analyzers - + - - - + + diff --git a/tests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests/Common/WebApplicationFactoryExtensions.cs b/tests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests/Common/WebApplicationFactoryExtensions.cs index 9b962e782..38fa03348 100644 --- a/tests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests/Common/WebApplicationFactoryExtensions.cs +++ b/tests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests/Common/WebApplicationFactoryExtensions.cs @@ -18,7 +18,7 @@ public static HttpClient SetupClient(this WebApplicationFactory fixture return fixture.WithWebHostBuilder( builder => builder - .UseEnvironment(EnvironmentName.Staging) + .UseEnvironment(Microsoft.Extensions.Hosting.Environments.Staging) .ConfigureTestServices(services => { }) ).CreateClient(options); } diff --git a/tests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests.csproj b/tests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests.csproj index 157b57337..52d9fa187 100644 --- a/tests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests.csproj +++ b/tests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests/Skoruba.IdentityServer4.STS.Identity.IntegrationTests.csproj @@ -1,25 +1,24 @@  - netcoreapp2.2 + netcoreapp3.0 true false Full - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers -