This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
c67699c
commit 3fef0b0
Showing
4 changed files
with
108 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/EntityFramework.Storage/host/ConsoleHost/ConsoleHost.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\IdentityServer4.EntityFramework.Storage.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
using IdentityServer4.EntityFramework.Storage; | ||
using Microsoft.EntityFrameworkCore; | ||
using IdentityServer4.EntityFramework; | ||
|
||
namespace ConsoleHost | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var connectionString = "server=(localdb)\\mssqllocaldb;database=IdentityServer4.EntityFramework-4.0.0;trusted_connection=yes;"; | ||
|
||
var services = new ServiceCollection(); | ||
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Trace)); | ||
services.AddOperationalDbContext(options => | ||
{ | ||
options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString); | ||
// this enables automatic token cleanup. this is optional. | ||
options.EnableTokenCleanup = false; | ||
options.TokenCleanupInterval = 5; // interval in seconds, short for testing | ||
}); | ||
|
||
var sp = services.BuildServiceProvider(); | ||
using (var scope = sp.CreateScope()) | ||
{ | ||
var svc = scope.ServiceProvider.GetRequiredService<TokenCleanupService>(); | ||
svc.RemoveExpiredGrantsAsync().GetAwaiter().GetResult(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters