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

Commit d38fdb6

Browse files
committed
docker ready
1 parent ffd0ba2 commit d38fdb6

8 files changed

Lines changed: 364 additions & 35 deletions

File tree

src/Backend/Jp.UserManagement/Startup.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Threading.Tasks;
23
using IdentityServer4.AccessTokenValidation;
34
using Jp.Infra.CrossCutting.IoC;
45
using Jp.UserManagement.Configuration;
@@ -41,18 +42,27 @@ public void ConfigureServices(IServiceCollection services)
4142
services.AddIdentity(Configuration);
4243
services.ConfigureCors();
4344

45+
4446
//services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
4547
services.AddAuthentication(options =>
4648
{
4749
options.DefaultAuthenticateScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
4850
options.DefaultChallengeScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
51+
4952
})
5053
.AddIdentityServerAuthentication(options =>
5154
{
5255
options.Authority = Environment.GetEnvironmentVariable("AUTHORITY") ?? "http://localhost:5000";
5356
options.RequireHttpsMetadata = false;
5457
options.ApiSecret = "Q&tGrEQMypEk.XxPU:%bWDZMdpZeJiyMwpLv4F7d**w9x:7KuJ#fy,E8KPHpKz++";
5558
options.ApiName = "UserManagementApi";
59+
60+
61+
options.JwtBearerEvents.OnMessageReceived = (messae) =>
62+
{
63+
messae.Options.TokenValidationParameters.ValidateIssuer = bool.TryParse(Environment.GetEnvironmentVariable("VALIDATE_ISSUER") ?? "true", out _);
64+
return Task.CompletedTask;
65+
};
5666
});
5767

5868
services.AddSwagger();

src/Backend/Jp.UserManagement/jpProject_sso_log.txt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,3 +694,50 @@ WHERE [e].[Id] = @__get_Item_0
694694
2018-09-03 15:32:46.584 -03:00 [INF] Executing ObjectResult, writing value of type 'Jp.Infra.CrossCutting.Tools.Model.DefaultResponse`1[[Jp.Application.ViewModels.ProfileViewModel, Jp.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'.
695695
2018-09-03 15:32:46.594 -03:00 [INF] Executed action Jp.UserManagement.Controllers.ManagementController.UserData (Jp.UserManagement) in 1017.3105ms
696696
2018-09-03 15:32:46.607 -03:00 [INF] Request finished in 1325.4112ms 200 application/json; charset=utf-8
697+
2018-09-04 02:28:20.156 -03:00 [INF] User profile is available. Using 'C:\Users\Bruno\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
698+
2018-09-04 02:28:21.796 -03:00 [INF] Request starting HTTP/1.1 GET http://localhost:5003/swagger/index.html
699+
2018-09-04 02:28:21.833 -03:00 [DBG] AuthenticationScheme: Bearer was not authenticated.
700+
2018-09-04 02:28:21.861 -03:00 [INF] Request finished in 66.511ms 200 text/html
701+
2018-09-04 02:28:22.307 -03:00 [INF] Request starting HTTP/1.1 GET http://localhost:5003/swagger/v1/swagger.json
702+
2018-09-04 02:28:22.309 -03:00 [DBG] AuthenticationScheme: Bearer was not authenticated.
703+
2018-09-04 02:28:22.487 -03:00 [INF] Request finished in 180.1242ms 200 application/json;charset=utf-8
704+
2018-09-04 02:30:34.839 -03:00 [INF] User profile is available. Using 'C:\Users\Bruno\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
705+
2018-09-04 02:30:36.385 -03:00 [INF] Request starting HTTP/1.1 GET http://localhost:5003/swagger/index.html
706+
2018-09-04 02:30:36.429 -03:00 [DBG] AuthenticationScheme: Bearer was not authenticated.
707+
2018-09-04 02:30:36.463 -03:00 [INF] Request finished in 80.9751ms 200 text/html
708+
2018-09-04 02:30:36.913 -03:00 [INF] Request starting HTTP/1.1 GET http://localhost:5003/swagger/v1/swagger.json
709+
2018-09-04 02:30:36.915 -03:00 [DBG] AuthenticationScheme: Bearer was not authenticated.
710+
2018-09-04 02:30:37.101 -03:00 [INF] Request finished in 187.72ms 200 application/json;charset=utf-8
711+
2018-09-04 02:32:25.059 -03:00 [INF] User profile is available. Using 'C:\Users\Bruno\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
712+
2018-09-04 02:32:26.611 -03:00 [INF] Request starting HTTP/1.1 GET http://localhost:5003/swagger/index.html
713+
2018-09-04 02:32:26.641 -03:00 [DBG] AuthenticationScheme: Bearer was not authenticated.
714+
2018-09-04 02:32:26.661 -03:00 [INF] Request finished in 53.1548ms 200 text/html
715+
2018-09-04 02:32:27.148 -03:00 [INF] Request starting HTTP/1.1 GET http://localhost:5003/swagger/v1/swagger.json
716+
2018-09-04 02:32:27.150 -03:00 [DBG] AuthenticationScheme: Bearer was not authenticated.
717+
2018-09-04 02:32:27.316 -03:00 [INF] Request finished in 168.3335ms 200 application/json;charset=utf-8
718+
2018-09-04 02:33:06.603 -03:00 [INF] User profile is available. Using 'C:\Users\Bruno\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
719+
2018-09-04 02:33:08.119 -03:00 [INF] Request starting HTTP/1.1 GET http://localhost:5003/swagger/index.html
720+
2018-09-04 02:33:08.154 -03:00 [DBG] AuthenticationScheme: Bearer was not authenticated.
721+
2018-09-04 02:33:08.195 -03:00 [INF] Request finished in 79.1444ms 200 text/html
722+
2018-09-04 02:33:08.653 -03:00 [INF] Request starting HTTP/1.1 GET http://localhost:5003/swagger/v1/swagger.json
723+
2018-09-04 02:33:08.654 -03:00 [DBG] AuthenticationScheme: Bearer was not authenticated.
724+
2018-09-04 02:33:08.829 -03:00 [INF] Request finished in 176.3641ms 200 application/json;charset=utf-8
725+
2018-09-04 02:33:30.258 -03:00 [INF] Request starting HTTP/1.1 GET http://localhost:5003/swagger/oauth2-redirect.html
726+
2018-09-04 02:33:30.259 -03:00 [DBG] AuthenticationScheme: Bearer was not authenticated.
727+
2018-09-04 02:33:30.274 -03:00 [INF] Sending file. Request path: '/oauth2-redirect.html'. Physical path: 'N/A'
728+
2018-09-04 02:33:30.275 -03:00 [INF] Request finished in 17.8794ms 200 text/html
729+
2018-09-04 02:33:35.099 -03:00 [INF] Request starting HTTP/1.1 GET http://localhost:5003/Management/user-data
730+
2018-09-04 02:33:40.408 -03:00 [INF] Successfully validated the token.
731+
2018-09-04 02:33:40.415 -03:00 [DBG] AuthenticationScheme: Bearer was successfully authenticated.
732+
2018-09-04 02:33:40.449 -03:00 [INF] Route matched with {action = "UserData", controller = "Management"}. Executing action Jp.UserManagement.Controllers.ManagementController.UserData (Jp.UserManagement)
733+
2018-09-04 02:33:40.465 -03:00 [INF] Authorization was successful.
734+
2018-09-04 02:33:40.610 -03:00 [INF] Executing action method Jp.UserManagement.Controllers.ManagementController.UserData (Jp.UserManagement) - Validation state: "Valid"
735+
2018-09-04 02:33:41.155 -03:00 [INF] Entity Framework Core 2.1.2-rtm-30932 initialized 'ApplicationDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
736+
2018-09-04 02:33:41.549 -03:00 [INF] Executed DbCommand (11ms) [Parameters=[@__get_Item_0='?' (DbType = Guid)], CommandType='"Text"', CommandTimeout='30']
737+
SELECT TOP(1) [e].[Id], [e].[AccessFailedCount], [e].[Bio], [e].[Company], [e].[ConcurrencyStamp], [e].[Email], [e].[EmailConfirmed], [e].[JobTitle], [e].[LockoutEnabled], [e].[LockoutEnd], [e].[Name], [e].[NormalizedEmail], [e].[NormalizedUserName], [e].[PasswordHash], [e].[PhoneNumber], [e].[PhoneNumberConfirmed], [e].[Picture], [e].[SecurityStamp], [e].[TwoFactorEnabled], [e].[Url], [e].[UserName]
738+
FROM [Users] AS [e]
739+
WHERE [e].[Id] = @__get_Item_0
740+
2018-09-04 02:33:41.676 -03:00 [INF] Executed action method Jp.UserManagement.Controllers.ManagementController.UserData (Jp.UserManagement), returned result Microsoft.AspNetCore.Mvc.OkObjectResult in 1056.9394ms.
741+
2018-09-04 02:33:41.687 -03:00 [INF] Executing ObjectResult, writing value of type 'Jp.Infra.CrossCutting.Tools.Model.DefaultResponse`1[[Jp.Application.ViewModels.ProfileViewModel, Jp.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'.
742+
2018-09-04 02:33:41.700 -03:00 [INF] Executed action Jp.UserManagement.Controllers.ManagementController.UserData (Jp.UserManagement) in 1247.3456ms
743+
2018-09-04 02:33:41.711 -03:00 [INF] Request finished in 6612.0118ms 200 application/json; charset=utf-8

src/Frontend/Jp.UI.SSO/Configuration/IdentityServerConfig.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.Extensions.Configuration;
88
using Microsoft.Extensions.DependencyInjection;
99
using Microsoft.Extensions.Logging;
10+
using ServiceStack;
1011

1112
namespace Jp.UI.SSO.Configuration
1213
{
@@ -26,7 +27,7 @@ public static IServiceCollection AddIdentityServer(this IServiceCollection servi
2627
options.Events.RaiseInformationEvents = true;
2728
options.Events.RaiseFailureEvents = true;
2829
options.Events.RaiseSuccessEvents = true;
29-
options.IssuerUri = Environment.GetEnvironmentVariable("ISSUER_URI");
30+
options.IssuerUri = Environment.GetEnvironmentVariable("ISSUER_URI") ?? "http://localhost:5000";
3031
options.PublicOrigin = Environment.GetEnvironmentVariable("PUBLIC_URI");
3132
})
3233
.AddAspNetIdentity<UserIdentity>()
@@ -47,15 +48,15 @@ public static IServiceCollection AddIdentityServer(this IServiceCollection servi
4748
//options.TokenCleanupInterval = 15; // frequency in seconds to cleanup stale grants. 15 is useful during debugging
4849
});
4950

50-
builder.AddSigninCredentialFromConfig(configuration.GetSection("CertificateOptions"), logger);
51-
//if (environment.IsDevelopment())
52-
//{
53-
// builder.AddDeveloperSigningCredential(false);
54-
//}
55-
//else
56-
//{
57-
// builder.AddSigninCredentialFromConfig(configuration.GetSection("CertificateOptions"), logger);
58-
//}
51+
//builder.AddSigninCredentialFromConfig(configuration.GetSection("CertificateOptions"), logger);
52+
if (environment.IsDevelopment())
53+
{
54+
builder.AddDeveloperSigningCredential(false);
55+
}
56+
else
57+
{
58+
builder.AddSigninCredentialFromConfig(configuration.GetSection("CertificateOptions"), logger);
59+
}
5960

6061
return services;
6162
}

0 commit comments

Comments
 (0)