Fix issue #118 Token lifetime handling
This commit is contained in:
parent
e4474127f9
commit
ba71b192a9
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
|
namespace Identity.API.Certificate
|
||||||
|
{
|
||||||
|
static class Certificate
|
||||||
|
{
|
||||||
|
public static X509Certificate2 Get()
|
||||||
|
{
|
||||||
|
var assembly = typeof(Certificate).GetTypeInfo().Assembly;
|
||||||
|
var names = assembly.GetManifestResourceNames();
|
||||||
|
using (var stream = assembly.GetManifestResourceStream("Identity.API.Certificate.idsrv3test.pfx"))
|
||||||
|
{
|
||||||
|
return new X509Certificate2(ReadStream(stream), "idsrv3test");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] ReadStream(Stream input)
|
||||||
|
{
|
||||||
|
byte[] buffer = new byte[16 * 1024];
|
||||||
|
using (MemoryStream ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
int read;
|
||||||
|
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
|
{
|
||||||
|
ms.Write(buffer, 0, read);
|
||||||
|
}
|
||||||
|
return ms.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
src/Services/Identity/Identity.API/Certificate/idsrv3test.pfx
Normal file
BIN
src/Services/Identity/Identity.API/Certificate/idsrv3test.pfx
Normal file
Binary file not shown.
@ -12,7 +12,7 @@
|
|||||||
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
|
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
|
||||||
<DockerComposeProjectPath>..\..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
|
<DockerComposeProjectPath>..\..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
|
||||||
@ -57,6 +57,10 @@
|
|||||||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
|
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Certificate\idsrv3test.pfx" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.Data\Microsoft.Extensions.HealthChecks.Data.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.Data\Microsoft.Extensions.HealthChecks.Data.csproj" />
|
||||||
|
@ -18,6 +18,7 @@ using System.Threading;
|
|||||||
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.Extensions.HealthChecks;
|
using Microsoft.Extensions.HealthChecks;
|
||||||
|
using Identity.API.Certificate;
|
||||||
|
|
||||||
namespace eShopOnContainers.Identity
|
namespace eShopOnContainers.Identity
|
||||||
{
|
{
|
||||||
@ -75,7 +76,7 @@ namespace eShopOnContainers.Identity
|
|||||||
|
|
||||||
// Adds IdentityServer
|
// Adds IdentityServer
|
||||||
services.AddIdentityServer(x => x.IssuerUri = "null")
|
services.AddIdentityServer(x => x.IssuerUri = "null")
|
||||||
.AddTemporarySigningCredential()
|
.AddSigningCredential(Certificate.Get())
|
||||||
.AddInMemoryScopes(Config.GetScopes())
|
.AddInMemoryScopes(Config.GetScopes())
|
||||||
.AddInMemoryClients(Config.GetClients(clientUrls))
|
.AddInMemoryClients(Config.GetClients(clientUrls))
|
||||||
.AddAspNetIdentity<ApplicationUser>()
|
.AddAspNetIdentity<ApplicationUser>()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user