Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.

Commit 7a48733

Browse files
committed
beta - ASP.NET Core 3
1 parent c74fb25 commit 7a48733

9 files changed

Lines changed: 33 additions & 22 deletions

File tree

src/Backend/Jp.Application/AutoMapper/AutoMapperConfig.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ public static MapperConfiguration RegisterMappings(params Profile[] customProfil
99
{
1010
return new MapperConfiguration(cfg =>
1111
{
12+
cfg.AddProfile(new IdentityServer4.EntityFramework.Mappers.ApiResourceMapperProfile());
13+
cfg.AddProfile(new IdentityServer4.EntityFramework.Mappers.ClientMapperProfile());
14+
cfg.AddProfile(new IdentityServer4.EntityFramework.Mappers.IdentityResourceMapperProfile());
15+
cfg.AddProfile(new IdentityServer4.EntityFramework.Mappers.PersistedGrantMapperProfile());
1216
cfg.AddProfile(new DomainToViewModelMappingProfile());
1317
cfg.AddProfile(new ViewModelToDomainMappingProfile());
1418
customProfiles.ToList().ForEach(cfg.AddProfile);

src/Backend/Jp.Application/Services/ClientAppService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using AutoMapper;
62
using IdentityServer4.EntityFramework.Mappers;
73
using IdentityServer4.Models;
@@ -11,6 +7,10 @@
117
using Jp.Domain.Commands.Clients;
128
using Jp.Domain.Core.Bus;
139
using Jp.Domain.Interfaces;
10+
using System;
11+
using System.Collections.Generic;
12+
using System.Linq;
13+
using System.Threading.Tasks;
1414

1515
namespace Jp.Application.Services
1616
{
@@ -43,7 +43,7 @@ public ClientAppService(IMapper mapper,
4343

4444
public Task<IEnumerable<ClientListViewModel>> GetClients()
4545
{
46-
var resultado = _mapper.Map<IEnumerable<ClientListViewModel>>(_clientRepository.GetAll().Select(a => a.ToModel()).OrderBy(a => a.ClientName).ToList());
46+
var resultado = _mapper.Map<IEnumerable<ClientListViewModel>>(_clientRepository.GetAll().AsEnumerable().Select(a => a.ToModel()).OrderBy(a => a.ClientName).ToList());
4747
return Task.FromResult(resultado);
4848
}
4949

@@ -85,7 +85,7 @@ public Task RemoveProperty(RemovePropertyViewModel model)
8585
{
8686
var registerCommand = _mapper.Map<RemovePropertyCommand>(model);
8787
return Bus.SendCommand(registerCommand);
88-
}
88+
}
8989
public Task SaveProperty(SaveClientPropertyViewModel model)
9090
{
9191
var registerCommand = _mapper.Map<SaveClientPropertyCommand>(model);

src/Backend/Jp.Domain/Commands/Clients/SaveClientCommand.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ public SaveClientCommand(string clientId, string name, string clientUri, string
2020
ClientUri = clientUri,
2121
LogoUri = logoUri,
2222
Description = description,
23-
PostLogoutRedirectUris = new List<string>() { postLogoutUri }
2423
};
24+
25+
if (!string.IsNullOrEmpty(postLogoutUri))
26+
Client.PostLogoutRedirectUris = new List<string>() { postLogoutUri };
2527
ClientType = clientType;
2628
}
2729

src/Backend/Jp.UserManagement/Configuration/AuthenticationConfig.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ namespace Jp.Management.Configuration
99
{
1010
public static class AuthenticationConfig
1111
{
12-
public static void AddIdentityServerAuthentication(this IServiceCollection services, ILogger logger, IConfiguration configuration)
12+
public static void AddIdentityServerAuthentication(this IServiceCollection services, IConfiguration configuration)
1313
{
14-
logger.LogInformation($"Authority URI: {configuration.GetValue<string>("ApplicationSettings:Authority")}");
1514
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
1615
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
1716
services

src/Backend/Jp.UserManagement/Configuration/CorsConfig.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public static IServiceCollection ConfigureCors(this IServiceCollection services)
1212
options.AddPolicy("Development",
1313
builder => builder.AllowAnyOrigin()
1414
.AllowAnyMethod()
15-
.AllowAnyHeader()
16-
.AllowCredentials());
15+
.AllowAnyHeader());
1716
});
1817

1918
return services;

src/Backend/Jp.UserManagement/Jp.Management.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
1212
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
1313
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.8.0" />
14+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
1415
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.5" />
1516
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
1617
<PackageReference Include="Serilog.AspNetCore" Version="3.0.1-dev-00116" />

src/Backend/Jp.UserManagement/Startup.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,28 @@
99
using Microsoft.Extensions.DependencyInjection;
1010
using Microsoft.Extensions.DependencyInjection.Extensions;
1111
using Microsoft.Extensions.Hosting;
12-
using Microsoft.Extensions.Logging;
12+
using Newtonsoft.Json;
1313

1414
namespace Jp.Management
1515
{
1616
public class Startup
1717
{
1818
public IConfiguration Configuration { get; }
1919

20-
public Startup(ILogger<Startup> logger, IConfiguration configuration)
20+
public Startup(IConfiguration configuration)
2121
{
2222
Configuration = configuration;
2323
}
2424
// This method gets called by the runtime. Use this method to add services to the container.
2525
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
26-
public void ConfigureServices(IServiceCollection services, ILoggerFactory logger)
26+
public void ConfigureServices(IServiceCollection services)
2727
{
28-
services.AddMvcCore().AddApiExplorer();
28+
services
29+
.AddMvcCore()
30+
.AddNewtonsoftJson(options =>
31+
{
32+
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
33+
}).AddApiExplorer();
2934

3035
// Identity Database
3136
services.AddAuthentication(Configuration);
@@ -36,7 +41,7 @@ public void ConfigureServices(IServiceCollection services, ILoggerFactory logger
3641
services.AddPolicies();
3742

3843
// configure auth Server
39-
services.AddIdentityServerAuthentication(logger.CreateLogger<Startup>(), Configuration);
44+
services.AddIdentityServerAuthentication(Configuration);
4045

4146
// configure openapi
4247
services.AddSwagger(Configuration);
@@ -64,6 +69,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
6469
app.UseHttpsRedirection();
6570
}
6671

72+
app.UseAuthorization();
6773
app.UseAuthentication();
6874
app.UseSwagger();
6975
app.UseSwaggerUI(c =>
@@ -72,7 +78,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
7278
c.OAuthClientId("Swagger");
7379
c.OAuthAppName("User Management UI - full access");
7480
});
75-
81+
app.UseRouting();
7682
app.UseEndpoints(endpoints =>
7783
{
7884
endpoints.MapControllers();

src/Backend/Jp.UserManagement/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"ApplicationSettings": {
3535
"DatabaseType": "SqlServer",
36-
"Authority": "https://localhost:5001",
36+
"Authority": "http://localhost:5000",
3737
"Cors": "http://*.teste.work",
3838
"UserManagementURL": "http://localhost:4200",
3939
"IS4AdminUi": "http://localhost:4300"

src/Frontend/Jp.UI.SSO/appsettings.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"ConnectionStrings": {
33
// Postgre Connection
4-
"SSOConnection": "Server=localhost;Port=5432;Database=jpproject;User Id=postgres;Password=10203040;"
4+
// "SSOConnection": "Server=localhost;Port=5432;Database=jpproject;User Id=postgres;Password=10203040;"
55
// Sql Server Connection
6-
//"SSOConnection": "Server=.;Initial Catalog=JpProject;Persist Security Info=False;User ID=sa;Password=@Password1;MultipleActiveResultSets=False;Connection Timeout=30;"
6+
"SSOConnection": "Server=.;Initial Catalog=JpProject;Persist Security Info=False;User ID=sa;Password=@Password1;MultipleActiveResultSets=False;Connection Timeout=30;"
77
// MySql Connection
8-
//"SSOConnection": "server=localhost,port=3306;database=jpproject;user=bruno;password=10203040"
8+
// "SSOConnection": "server=localhost,port=3306;database=jpproject;user=bruno;password=10203040"
99
// SQLite Connection
1010
//"SSOConnection": "Data Source=jpproject.db"
1111
},
@@ -49,7 +49,7 @@
4949
"UserManagementURL": "http://localhost:4200",
5050
"IS4AdminUi": "http://localhost:4300",
5151
"ResourceServerURL": "https://localhost:5002",
52-
"DatabaseType": "PostgreSql",
52+
"DatabaseType": "SqlServer",
5353
"DefaultUser": "bruno",
5454
"DefaultPass": "Pa$$word123",
5555
"DefaultEmail": "bhdebrito@gmail.com",

0 commit comments

Comments
 (0)