Skip to content

Commit fe93901

Browse files
committed
identity service
1 parent 756142d commit fe93901

File tree

6 files changed

+60
-73
lines changed

6 files changed

+60
-73
lines changed

src/Services/Catalog/Catalog.API/Startup.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
7575
app.UsePathBase(pathBase);
7676
}
7777

78-
app.UseHealthChecks("/hc", new HealthCheckOptions()
79-
{
80-
Predicate = _ => true,
81-
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
82-
});
83-
84-
app.UseHealthChecks("/liveness", new HealthCheckOptions
85-
{
86-
Predicate = r => r.Name.Contains("self")
87-
});
88-
8978
app.UseCors("CorsPolicy");
9079

9180
app.UseRouting();

src/Services/Identity/Identity.API/Identity.API.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,26 @@
1616
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="$(AspNetCore_HealthChecks_SqlServer)" />
1717
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="$(AspNetCore_HealthChecks_UI_Client)" />
1818
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="$(Autofac_Extensions_DependencyInjection)" />
19-
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="2.1.0" />
20-
<PackageReference Include="IdentityServer4.EntityFramework" Version="2.1.1" />
19+
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="$(IdentityServer4_AspNetIdentity)" />
20+
<PackageReference Include="IdentityServer4.EntityFramework" Version="$(IdentityServer4_EntityFramework)" />
2121
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="$(Microsoft_ApplicationInsights_AspNetCore)" />
2222
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="$(Microsoft_ApplicationInsights_DependencyCollector)" />
2323
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="$(Microsoft_ApplicationInsights_Kubernetes)" />
24-
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="2.2.0-preview2-35157" />
24+
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="$(Microsoft_AspNetCore_DataProtection_Redis)" />
2525
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="$(Microsoft_AspNetCore_Diagnostics_HealthChecks)" />
2626
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="$(Microsoft_AspNetCore_HealthChecks)" />
2727
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="$(Microsoft_Extensions_Configuration_AzureKeyVault)" />
2828
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="$(Microsoft_Extensions_Logging_AzureAppServices)" />
29-
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="1.0.172" />
29+
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="$(Microsoft_Web_LibraryManager_Build)" />
3030
<PackageReference Include="Serilog.AspNetCore" Version="$(Serilog_AspNetCore)" />
3131
<PackageReference Include="Serilog.Enrichers.Environment" Version="$(Serilog_Enrichers_Environment)" />
3232
<PackageReference Include="Serilog.Settings.Configuration" Version="$(Serilog_Settings_Configuration)" />
3333
<PackageReference Include="Serilog.Sinks.Console" Version="$(Serilog_Sinks_Console)" />
3434
<PackageReference Include="Serilog.Sinks.Seq" Version="$(Serilog_Sinks_Seq)" />
3535
<PackageReference Include="Serilog.Sinks.Http" Version="$(Serilog_Sinks_Http)" />
3636
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(Swashbuckle_AspNetCore)" />
37+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="$(Microsoft_AspNetCore_Identity_EntityFrameworkCore)" />
38+
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="$(Microsoft_AspNetCore_Diagnostics_EntityFrameworkCore)" />
3739
</ItemGroup>
3840

3941
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">

src/Services/Identity/Identity.API/Startup.cs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
5555
services.Configure<AppSettings>(Configuration);
5656

5757
services.AddMvc()
58-
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
58+
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
5959

6060
if (Configuration.GetValue<string>("IsClusterEnv") == bool.TrueString)
6161
{
@@ -140,20 +140,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
140140
app.UsePathBase(pathBase);
141141
}
142142

143-
app.UseHealthChecks("/hc", new HealthCheckOptions()
144-
{
145-
Predicate = _ => true,
146-
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
147-
});
148-
149-
app.UseHealthChecks("/liveness", new HealthCheckOptions
150-
{
151-
Predicate = r => r.Name.Contains("self")
152-
});
153-
154143
app.UseStaticFiles();
155144

156-
157145
// Make work identity server redirections in Edge and lastest versions of browers. WARN: Not valid in a production environment.
158146
app.Use(async (context, next) =>
159147
{
@@ -164,13 +152,20 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
164152
app.UseForwardedHeaders();
165153
// Adds IdentityServer
166154
app.UseIdentityServer();
167-
168155
app.UseHttpsRedirection();
169-
app.UseMvc(routes =>
156+
app.UseRouting();
157+
app.UseEndpoints(endpoints =>
170158
{
171-
routes.MapRoute(
172-
name: "default",
173-
template: "{controller=Home}/{action=Index}/{id?}");
159+
endpoints.MapHealthChecks("/hc", new HealthCheckOptions()
160+
{
161+
Predicate = _ => true,
162+
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
163+
});
164+
endpoints.MapHealthChecks("/liveness", new HealthCheckOptions
165+
{
166+
Predicate = r => r.Name.Contains("self")
167+
});
168+
endpoints.MapDefaultControllerRoute();
174169
});
175170
}
176171

src/Services/Identity/Identity.API/Views/Account/Login.cshtml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
@using System.Collections.Generic
2-
@using Microsoft.AspNetCore.Http
3-
@using Microsoft.AspNetCore.Http.Authentication
4-
@model Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels.LoginViewModel
1+
@model Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels.LoginViewModel
52

63

74
@{

src/Web/WebMVC/Startup.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -234,29 +234,29 @@ public static IServiceCollection AddCustomAuthentication(this IServiceCollection
234234
.AddCookie(setup => setup.ExpireTimeSpan = TimeSpan.FromMinutes(sessionCookieLifetime))
235235
.AddJwtBearer(options =>
236236
{
237-
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
237+
//options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
238+
//options.Authority = identityUrl.ToString();
239+
//options.SignedOutRedirectUri = callBackUrl.ToString();
240+
//options.ClientId = useLoadTest ? "mvctest" : "mvc";
241+
//options.ClientSecret = "secret";
242+
//options.ResponseType = useLoadTest ? "code id_token token" : "code id_token";
243+
//options.SaveTokens = true;
244+
//options.GetClaimsFromUserInfoEndpoint = true;
245+
//options.RequireHttpsMetadata = false;
246+
//options.Scope.Add("openid");
247+
//options.Scope.Add("profile");
248+
//options.Scope.Add("orders");
249+
//options.Scope.Add("basket");
250+
//options.Scope.Add("marketing");
251+
//options.Scope.Add("locations");
252+
//options.Scope.Add("webshoppingagg");
253+
//options.Scope.Add("orders.signalrhub");
254+
255+
//options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
238256
options.Authority = identityUrl.ToString();
239-
options.SignedOutRedirectUri = callBackUrl.ToString();
240-
options.ClientId = useLoadTest ? "mvctest" : "mvc";
241-
options.ClientSecret = "secret";
242-
options.ResponseType = useLoadTest ? "code id_token token" : "code id_token";
243-
options.SaveTokens = true;
244-
options.GetClaimsFromUserInfoEndpoint = true;
245-
options.RequireHttpsMetadata = false;
246-
options.Scope.Add("openid");
247-
options.Scope.Add("profile");
248-
options.Scope.Add("orders");
249-
options.Scope.Add("basket");
250-
options.Scope.Add("marketing");
251-
options.Scope.Add("locations");
252-
options.Scope.Add("webshoppingagg");
253-
options.Scope.Add("orders.signalrhub");
254-
255-
/*options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
256-
options.Authority = identityUrl.ToString();
257-
options.SignedOutRedirectUri = callBackUrl.ToString();
258-
options.ClientId = useLoadTest ? "mvctest" : "mvc";
259-
options.ClientSecret = "secret";
257+
options.ForwardSignOut = callBackUrl.ToString();
258+
//options.ClientId = useLoadTest ? "mvctest" : "mvc";
259+
//options.ClientSecret = "secret";
260260

261261
if (useLoadTest)
262262
{
@@ -268,7 +268,7 @@ public static IServiceCollection AddCustomAuthentication(this IServiceCollection
268268
}
269269

270270
options.SaveToken = true;
271-
options.GetClaimsFromUserInfoEndpoint = true;
271+
//options.GetClaimsFromUserInfoEndpoint = true;
272272
options.RequireHttpsMetadata = false;
273273
options.Configuration.ScopesSupported.Add("openid");
274274
options.Configuration.ScopesSupported.Add("profile");
@@ -277,7 +277,7 @@ public static IServiceCollection AddCustomAuthentication(this IServiceCollection
277277
options.Configuration.ScopesSupported.Add("marketing");
278278
options.Configuration.ScopesSupported.Add("locations");
279279
options.Configuration.ScopesSupported.Add("webshoppingagg");
280-
options.Configuration.ScopesSupported.Add("orders.signalrhub");*/
280+
options.Configuration.ScopesSupported.Add("orders.signalrhub");
281281
});
282282

283283
return services;

src/_build/dependencies.props

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<BundlerMinifier_Core>2.9.406</BundlerMinifier_Core>
1616
</PropertyGroup>
1717

18-
<PropertyGroup Label="Package Versions">
18+
<PropertyGroup Label="Package Versions">
1919
<Grpc_AspNetCore_Server>0.1.22-pre1</Grpc_AspNetCore_Server>
2020
<Google_Protobuf>3.9.0-rc1</Google_Protobuf>
2121
<Grpc_Tools>1.22.0</Grpc_Tools>
@@ -32,36 +32,38 @@
3232
<Autofac>4.9.2</Autofac>
3333
<Autofac_Extensions_DependencyInjection>4.2.1</Autofac_Extensions_DependencyInjection>
3434
<Dapper>1.50.7</Dapper>
35-
<Microsoft_AspNetCore_Razor_Design>3.0.0-alpha1-10670</Microsoft_AspNetCore_Razor_Design>
36-
<Microsoft_VisualStudio_Azure_Containers_Tools_Targets>1.0.2105168</Microsoft_VisualStudio_Azure_Containers_Tools_Targets>
37-
<Microsoft_VisualStudio_Web_CodeGeneration_Design>3.0.0-preview6-19319-03</Microsoft_VisualStudio_Web_CodeGeneration_Design>
38-
<Microsoft_AspNetCore_Authentication_OpenIdConnect>3.0.0-preview6-19253-01</Microsoft_AspNetCore_Authentication_OpenIdConnect>
39-
<System_Reflection>4.3.0</System_Reflection>
35+
<System_Reflection>4.3.0</System_Reflection>
4036
<System_Reflection_TypeExtensions>4.5.1</System_Reflection_TypeExtensions>
4137
<System_ValueTuple>4.5.0</System_ValueTuple>
4238
<MediatR>5.1.0</MediatR>
4339
<BuildBundlerMinifier>2.6.375</BuildBundlerMinifier>
44-
<Microsoft_AspNetCore_DataProtection_Redis>2.2.0-preview2-35157</Microsoft_AspNetCore_DataProtection_Redis>
45-
<Microsoft_AspNet_WebApi_Client>5.2.7</Microsoft_AspNet_WebApi_Client>
40+
<Microsoft_AspNet_WebApi_Client>5.2.7</Microsoft_AspNet_WebApi_Client>
4641
<Microsoft_Build_Utilities_Core>15.9.20</Microsoft_Build_Utilities_Core>
4742
<Microsoft_Web_LibraryManager_Build>1.0.172</Microsoft_Web_LibraryManager_Build>
48-
<Microsoft_AspNetCore_SignalR_Redis>3.0.0-alpha1-34847</Microsoft_AspNetCore_SignalR_Redis>
43+
<Microsoft_VisualStudio_Azure_Containers_Tools_Targets>1.0.2105168</Microsoft_VisualStudio_Azure_Containers_Tools_Targets>
44+
<Microsoft_VisualStudio_Web_CodeGeneration_Design>3.0.0-preview6-19319-03</Microsoft_VisualStudio_Web_CodeGeneration_Design>
4945
<MediatR_Extensions_Microsoft_DependencyInjection>5.1.0</MediatR_Extensions_Microsoft_DependencyInjection>
5046
<Microsoft_ApplicationInsights_AspNetCore>2.2.1</Microsoft_ApplicationInsights_AspNetCore>
5147
<Microsoft_ApplicationInsights_DependencyCollector>2.6.1</Microsoft_ApplicationInsights_DependencyCollector>
5248
<Microsoft_ApplicationInsights_Kubernetes>1.0.2</Microsoft_ApplicationInsights_Kubernetes>
49+
<Microsoft_AspNetCore_Razor_Design>3.0.0-alpha1-10670</Microsoft_AspNetCore_Razor_Design>
50+
<Microsoft_AspNetCore_Authentication_OpenIdConnect>3.0.0-preview6-19253-01</Microsoft_AspNetCore_Authentication_OpenIdConnect>
51+
<Microsoft_AspNetCore_DataProtection_Redis>2.2.0-preview2-35157</Microsoft_AspNetCore_DataProtection_Redis>
52+
<Microsoft_AspNetCore_SignalR_Redis>3.0.0-alpha1-34847</Microsoft_AspNetCore_SignalR_Redis>
5353
<Microsoft_AspNetCore_Authentication_JwtBearer>3.0.0-preview6.19307.2</Microsoft_AspNetCore_Authentication_JwtBearer>
5454
<Microsoft_AspNetCore_Authentication_OpenIdConnect>3.0.0-preview6.19307.2</Microsoft_AspNetCore_Authentication_OpenIdConnect>
5555
<Microsoft_AspNetCore_Diagnostics_HealthChecks>2.2.0</Microsoft_AspNetCore_Diagnostics_HealthChecks>
5656
<Microsoft_AspNetCore_HealthChecks>1.0.0</Microsoft_AspNetCore_HealthChecks>
5757
<Microsoft_AspNetCore_Http_Abstractions>2.2.0</Microsoft_AspNetCore_Http_Abstractions>
5858
<Microsoft_AspNetCore_Mvc_Testing>3.0.0-preview6.19307.2</Microsoft_AspNetCore_Mvc_Testing>
5959
<Microsoft_AspNetCore_TestHost>3.0.0-preview6.19307.2</Microsoft_AspNetCore_TestHost>
60+
<Microsoft_AspNetCore_Identity_EntityFrameworkCore>3.0.0-preview6.19307.2</Microsoft_AspNetCore_Identity_EntityFrameworkCore>
61+
<Microsoft_AspNetCore_Diagnostics_EntityFrameworkCore>3.0.0-preview6-19253-01</Microsoft_AspNetCore_Diagnostics_EntityFrameworkCore>
62+
<Microsoft_AspNetCore_Hosting_Abstractions>3.0.0-preview4-19123-01</Microsoft_AspNetCore_Hosting_Abstractions>
63+
<FluentValidation_AspNetCore>7.5.0</FluentValidation_AspNetCore>
6064
<Microsoft_Azure_ServiceBus>3.0.0</Microsoft_Azure_ServiceBus>
6165
<Microsoft_CSharp>4.5.0</Microsoft_CSharp>
62-
<Microsoft_AspNetCore_Hosting_Abstractions>3.0.0-preview4-19123-01</Microsoft_AspNetCore_Hosting_Abstractions>
6366
<System_Data_SqlClient>4.7.0-preview6.19303.8</System_Data_SqlClient>
64-
<FluentValidation_AspNetCore>7.5.0</FluentValidation_AspNetCore>
6567
<Microsoft_EntityFrameworkCore>3.0.0-preview6.19304.10</Microsoft_EntityFrameworkCore>
6668
<Microsoft_EntityFrameworkCore_Design>3.0.0-preview6.19304.10</Microsoft_EntityFrameworkCore_Design>
6769
<Microsoft_EntityFrameworkCore_Relational>3.0.0-preview6.19304.10</Microsoft_EntityFrameworkCore_Relational>
@@ -82,6 +84,8 @@
8284
<Newtonsoft_Json>12.0.2</Newtonsoft_Json>
8385
<Ocelot>12.0.1</Ocelot>
8486
<Polly>6.0.1</Polly>
87+
<IdentityServer4_AspNetIdentity>3.0.0-preview3.4</IdentityServer4_AspNetIdentity>
88+
<IdentityServer4_EntityFramework>3.0.0-preview3.4</IdentityServer4_EntityFramework>
8589
<RabbitMQ_Client>5.0.1</RabbitMQ_Client>
8690
<Serilog_AspNetCore>3.0.0-dev-00053</Serilog_AspNetCore>
8791
<Serilog_Enrichers_Environment>2.1.3 </Serilog_Enrichers_Environment>
@@ -94,7 +98,7 @@
9498
<System_IO_Compression_ZipFile>4.3.0</System_IO_Compression_ZipFile>
9599
<xunit>2.4.0</xunit>
96100
<xunit_runner_visualstudio>2.4.0</xunit_runner_visualstudio>
97-
</PropertyGroup>
101+
</PropertyGroup>
98102

99103
<PropertyGroup Label="Package information">
100104
<PackageLicenseUrl>https://github.com/dotnet-architecture/eShopOnContainers/blob/master/LICENSE</PackageLicenseUrl>

0 commit comments

Comments
 (0)