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

Commit 2d7b090

Browse files
committed
App Insights
1 parent 3d2421a commit 2d7b090

22 files changed

Lines changed: 8779 additions & 54 deletions

File tree

keys/cert.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
param (
22
[Parameter(Mandatory=$true)][string]$certificatename,
3-
[Parameter(Mandatory=$true)][SecureString]$certificatepassword
3+
[Parameter(Mandatory=$true)][SecureString]$certificatepassword,
4+
[Parameter(Mandatory=$true)][string]$path
45
)
56
# setup certificate properties including the commonName (DNSName) property for Chrome 58+
67
$certificate = New-SelfSignedCertificate `
@@ -17,7 +18,7 @@ $certificate = New-SelfSignedCertificate `
1718
-TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1")
1819
$certificatePath = 'Cert:\CurrentUser\My\' + ($certificate.ThumbPrint)
1920
# create temporary certificate path
20-
$tmpPath = $MyInvocation.MyCommand.Path
21+
$tmpPath = $path
2122
If(!(test-path $tmpPath))
2223
{
2324
New-Item -ItemType Directory -Force -Path $tmpPath

keys/jpproject.cer

786 Bytes
Binary file not shown.

src/.dockerignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Backend/Jp.Infra.CrossCutting.Identity/Services/UserService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public UserService(
9292
//await _userManager.AddClaimAsync(newUser, new Claim("User", "Write"));
9393

9494
var code = await _userManager.GenerateEmailConfirmationTokenAsync(newUser);
95-
var callbackUrl = $"{_config.GetSection("ApplicationSettings").GetSection("UserManagementURL").Value}/confirm-email?user={user.Email.UrlEncode()}&code={code.UrlEncode()}";
95+
var callbackUrl = Environment.GetEnvironmentVariable("USER_MANAGEMENT_URI") ?? $"{_config.GetSection("ApplicationSettings").GetSection("UserManagementURL").Value}/confirm-email?user={user.Email.UrlEncode()}&code={code.UrlEncode()}";
9696
await _emailSender.SendEmailConfirmationAsync(user.Email, callbackUrl);
9797

9898

src/Backend/Jp.Infra.CrossCutting.IdentityServer/Configuration/SigninCredentialExtension.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ private static void AddCertificateFromFile(IIdentityServerBuilder builder,
9494
{
9595
var keyFileName = options.GetValue<string>(FileName);
9696
var keyFilePassword = options.GetValue<string>(FilePassword);
97+
var file = Path.Combine(env.ContentRootPath, keyFileName);
9798

98-
if (System.IO.File.Exists(Path.Combine(env.ContentRootPath, keyFileName)))
99+
if (System.IO.File.Exists(file))
99100
{
100101
logger.LogInformation($"SigninCredentialExtension adding key from file {keyFileName}");
101-
builder.AddSigningCredential(new X509Certificate2(Path.Combine(env.ContentRootPath, keyFileName), keyFilePassword, X509KeyStorageFlags.MachineKeySet));
102+
builder.AddSigningCredential(new X509Certificate2(file, keyFilePassword));
102103
}
103104
else
104105
{
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ProviderId": "Microsoft.ApplicationInsights.ConnectedService.ConnectedServiceProvider",
3+
"Version": "8.13.10627.1",
4+
"GettingStartedDocument": {
5+
"Uri": "https://go.microsoft.com/fwlink/?LinkID=798432"
6+
}
7+
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@
44
<TargetFramework>netcoreapp2.1</TargetFramework>
55
<UserSecretsId>9c91d295-54c5-4d09-9bd6-fa56fb74011b</UserSecretsId>
66
<DockerTargetOS>Linux</DockerTargetOS>
7+
<ApplicationInsightsResourceId>/subscriptions/ce40329b-ac99-4c5f-ab72-539cc648b3c1/resourcegroups/NewNasa/providers/microsoft.insights/components/Allto-SSO</ApplicationInsightsResourceId>
8+
<ApplicationInsightsAnnotationResourceId>/subscriptions/ce40329b-ac99-4c5f-ab72-539cc648b3c1/resourcegroups/NewNasa/providers/microsoft.insights/components/Allto-SSO</ApplicationInsightsAnnotationResourceId>
79
</PropertyGroup>
810

911
<ItemGroup>
1012
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="3.2.0" />
1113
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.6.0" />
1214
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="4.1.0" />
15+
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.4.1" />
1316
<PackageReference Include="Microsoft.AspNetCore.App" />
1417
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.0.1916590" />
1518
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.1" />
1619
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
20+
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="2.6.0" />
1721
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
1822
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
1923
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
@@ -25,14 +29,11 @@
2529
<ProjectReference Include="..\Jp.Infra.CrossCutting.Identity\Jp.Infra.CrossCutting.Identity.csproj" />
2630
<ProjectReference Include="..\Jp.Infra.CrossCutting.IoC\Jp.Infra.CrossCutting.IoC.csproj" />
2731
<ProjectReference Include="..\Jp.Infra.Data\Jp.Infra.Data.csproj" />
28-
<ProjectReference Include="..\Jp.Infra.Migrations.MySql.Identity\Jp.Infra.Migrations.MySql.Identity.csproj" />
32+
<ProjectReference Include="..\Jp.Infra.Migrations.Sql.Identity\Jp.Infra.Migrations.Sql.Identity.csproj" />
2933
</ItemGroup>
3034

3135
<ItemGroup>
32-
<Content Update="appsettings.json">
33-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
34-
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
35-
</Content>
36+
<WCFMetadata Include="Connected Services" />
3637
</ItemGroup>
3738

3839
</Project>

src/Backend/Jp.UserManagement/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static void Main(string[] args)
1919
.MinimumLevel.Override("System", LogEventLevel.Information)
2020
.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
2121
.Enrich.FromLogContext()
22+
.WriteTo.ApplicationInsightsEvents(Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY"))
2223
.WriteTo.File(@"jpProject_sso_log.txt")
2324
.WriteTo.Console()
2425
.CreateLogger();
@@ -30,6 +31,7 @@ public static void Main(string[] args)
3031

3132
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
3233
WebHost.CreateDefaultBuilder(args)
34+
.UseApplicationInsights(Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY"))
3335
.UseStartup<Startup>()
3436
.UseSerilog();
3537
}

src/Backend/Jp.UserManagement/Properties/launchSettings.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@
2020
"launchBrowser": false,
2121
"launchUrl": "swagger/index.html",
2222
"environmentVariables": {
23-
"SQLSERVER_CONNECTION": "Server=.,1433;Initial Catalog=JpProject;Persist Security Info=False;User ID=sa;Password=@Password1;MultipleActiveResultSets=False;Connection Timeout=30;",
2423
"ASPNETCORE_ENVIRONMENT": "Development",
2524
"AUTHORITY": "https://localhost:5000",
25+
"USER_MANAGEMENT_URI": "http://localhost:4200",
26+
"ASPNETCORE_URLS": "https://+:5003;http://+:5002"
27+
28+
// For Docker certificate
29+
// "DATABASE_CONNECTION": "Server=.,1433;Initial Catalog=JpProject;Persist Security Info=False;User ID=sa;Password=@Password1;MultipleActiveResultSets=False;Connection Timeout=30;"
2630
// "ASPNETCORE_Kestrel__Certificates__Default__Password": ".pxCpE]yttwC&b&hriw#,7K^_}A7xezRH3=EisJKn3]8.H}^Unzd+ebw]zzv_=d3",
2731
// "ASPNETCORE_Kestrel__Certificates__Default__Path": "/root/.dotnet/https/jpproject.pfx",
28-
"ASPNETCORE_URLS": "https://+:5003;http://+:5002"
2932
},
3033
"applicationUrl": "https://localhost:5003;http://localhost:5002"
3134
}

src/Backend/Jp.UserManagement/Startup.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Threading.Tasks;
33
using IdentityServer4.AccessTokenValidation;
44
using Jp.Infra.CrossCutting.IoC;
5-
using Jp.Infra.Migrations.MySql.Identity.Configuration;
5+
using Jp.Infra.Migrations.Sql.Identity.Configuration;
66
using Jp.UserManagement.Configuration;
77
using MediatR;
88
using Microsoft.AspNetCore.Builder;
@@ -43,7 +43,7 @@ public void ConfigureServices(IServiceCollection services)
4343
{
4444
services.AddMvc();
4545

46-
services.AddIdentityMySql(Configuration);
46+
services.AddIdentitySqlServer(Configuration);
4747
services.ConfigureCors();
4848

4949
var authorityUri = Environment.GetEnvironmentVariable("AUTHORITY") ?? "https://localhost:5000";
@@ -64,7 +64,6 @@ public void ConfigureServices(IServiceCollection services)
6464
messae.Options.TokenValidationParameters.ValidateIssuer = bool.Parse(Environment.GetEnvironmentVariable("VALIDATE_ISSUER") ?? "true");
6565
return Task.CompletedTask;
6666
};
67-
6867
});
6968

7069
services.AddSwagger();

0 commit comments

Comments
 (0)