Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit886660e

Browse files
committed
添加OpenIddict相关项目
1 parent9a1aa20 commit886660e

File tree

89 files changed

+45050
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+45050
-9
lines changed

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,6 @@ src/Destiny.Core.Flow.API/DestinyCoreMongoDb.txt
382382
/src/Destiny.Core.Flow.AuthenticationCenter/DestinyCoreMongoDb.txt
383383
/src/Destiny.Core.Flow.AuthenticationCenter/DestinyCoreRedis.txt
384384
/src/Destiny.Core.Flow.AuthenticationCenter/Logs
385+
Destiny.Core.Flow.OpenIddictServer/DestinyCoreDb.txt
386+
Destiny.Core.Flow.OpenIddictServer/DestinyCoreMongoDb.txt
387+
Destiny.Core.Flow.OpenIddictServer/DestinyCoreRedis.txt
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<ProjectSdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReferenceInclude="OpenIddict.EntityFrameworkCore.Models"Version="3.0.4" />
9+
<PackageReferenceInclude="DestinyCore"Version="1.0.1" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+

2+
usingOpenIddict.EntityFrameworkCore.Models;
3+
usingSystem;
4+
5+
namespaceDestiny.Core.Flow.OpenIddict.Entities
6+
{
7+
publicclassOpenIddictApplication:OpenIddictEntityFrameworkCoreApplication<Guid,OpenIddictAuthorization,OpenIddictToken>,DestinyCore.Entity.IEntity<Guid>{}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
usingDestinyCore.Entity;
2+
usingOpenIddict.EntityFrameworkCore.Models;
3+
usingSystem;
4+
5+
namespaceDestiny.Core.Flow.OpenIddict.Entities
6+
{
7+
publicclassOpenIddictAuthorization:OpenIddictEntityFrameworkCoreAuthorization<Guid,OpenIddictApplication,OpenIddictToken>,IEntity<Guid>{}
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
usingDestinyCore.Entity;
2+
usingOpenIddict.EntityFrameworkCore.Models;
3+
usingSystem;
4+
5+
namespaceDestiny.Core.Flow.OpenIddict.Entities
6+
{
7+
publicclassOpenIddictScope:OpenIddictEntityFrameworkCoreScope<Guid>,IEntity<Guid>
8+
{
9+
}
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
usingDestinyCore.Entity;
2+
usingOpenIddict.EntityFrameworkCore.Models;
3+
usingSystem;
4+
5+
namespaceDestiny.Core.Flow.OpenIddict.Entities
6+
{
7+
publicclassOpenIddictToken:OpenIddictEntityFrameworkCoreToken<Guid,OpenIddictApplication,OpenIddictAuthorization>,IEntity<Guid>{}
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<ProjectSdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<Nullable>disable</Nullable>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReferenceInclude="OpenIddict.EntityFrameworkCore"Version="3.0.4" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<ProjectReferenceInclude="..\Destiny.Core.Flow.OpenIddict.Entities\Destiny.Core.Flow.OpenIddict.Entities.csproj" />
14+
<ProjectReferenceInclude="..\Destiny.Core.Flow.OpenIddict\Destiny.Core.Flow.OpenIddict.csproj" />
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
usingMicrosoft.EntityFrameworkCore;
2+
usingSystem;
3+
usingSystem.Collections.Generic;
4+
usingSystem.Linq;
5+
usingSystem.Runtime.CompilerServices;
6+
usingSystem.Threading;
7+
8+
namespaceDestiny.Core.Flow.OpenIddict.EntityFrameworkCore
9+
{
10+
publicstaticclassEntityFrameworkCoreHelpers
11+
{
12+
publicstaticIAsyncEnumerable<T>AsAsyncEnumerable<T>(thisIQueryable<T>source,CancellationTokencancellationToken)
13+
{
14+
if(sourceisnull)
15+
{
16+
thrownewArgumentNullException(nameof(source));
17+
}
18+
19+
returnExecuteAsync(source,cancellationToken);
20+
21+
staticasyncIAsyncEnumerable<T>ExecuteAsync(IQueryable<T>source,[EnumeratorCancellation]CancellationTokencancellationToken)
22+
{
23+
#ifSUPPORTS_BCL_ASYNC_ENUMERABLE
24+
awaitforeach(varelementinsource.AsAsyncEnumerable().WithCancellation(cancellationToken))
25+
{
26+
yieldreturnelement;
27+
}
28+
#else
29+
foreach(varelementinawaitsource.ToListAsync(cancellationToken))
30+
{
31+
yieldreturnelement;
32+
}
33+
#endif
34+
}
35+
}
36+
}
37+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
usingDestinyCore.EntityFrameworkCore;
2+
usingMicrosoft.EntityFrameworkCore;
3+
usingSystem;
4+
5+
namespaceDestiny.Core.Flow.OpenIddict.EntityFrameworkCore
6+
{
7+
publicclassOpenIddictEntityDefaultDbContext:DbContextBase
8+
{
9+
publicOpenIddictEntityDefaultDbContext(DbContextOptionsoptions,IServiceProviderserviceProvider):base(options,serviceProvider)
10+
{
11+
}
12+
}
13+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
usingDestiny.Core.Flow.Model.Entities.OpenIddict;
2+
usingDestiny.Core.Flow.OpenIddict.EntityFrameworkCore.Store;
3+
usingMicrosoft.Extensions.DependencyInjection;
4+
usingMicrosoft.Extensions.DependencyInjection.Extensions;
5+
usingOpenIddict.EntityFrameworkCore;
6+
usingSystem;
7+
usingSystem.Collections.Generic;
8+
usingSystem.Linq;
9+
usingSystem.Text;
10+
usingSystem.Threading.Tasks;
11+
12+
namespaceDestiny.Core.Flow.OpenIddict.EntityFrameworkCore
13+
{
14+
publicstaticclassOpenIddictEntityFrameworkCoreExtensions
15+
{
16+
/// <summary>
17+
/// 注册efcore store服务
18+
/// 配置 OpenIddict 实体
19+
/// </summary>
20+
/// <returns>The <see cref="OpenIddictEntityFrameworkCoreBuilder"/>.</returns>
21+
publicstaticOpenIddictEntityFrameworkCoreBuilderUseEntityFrameworkCore(thisOpenIddictCoreBuilderbuilder)
22+
{
23+
if(builderisnull)
24+
{
25+
thrownewArgumentNullException(nameof(builder));
26+
}
27+
28+
// Since Entity Framework Core may be used with databases performing case-insensitive
29+
// or culture-sensitive comparisons, ensure the additional filtering logic is enforced
30+
// in case case-sensitive stores were registered before this extension was called.
31+
builder.Configure(options=>options.DisableAdditionalFiltering=false);
32+
33+
//builder.SetDefaultApplicationEntity<Application>()
34+
// .SetDefaultAuthorizationEntity<Authorization>()
35+
// .SetDefaultScopeEntity<Scope>()
36+
// .SetDefaultTokenEntity<Token>();
37+
38+
builder.ReplaceApplicationStoreResolver<OpenIddictEntityFrameworkCoreApplicationStoreResolver>()
39+
.ReplaceAuthorizationStoreResolver<OpenIddictEntityFrameworkCoreAuthorizationStoreResolver>()
40+
.ReplaceScopeStoreResolver<OpenIddictEntityFrameworkCoreScopeStoreResolver>()
41+
.ReplaceTokenStoreResolver<OpenIddictEntityFrameworkCoreTokenStoreResolver>();
42+
43+
builder.Services.TryAddSingleton<OpenIddictEntityFrameworkCoreApplicationStoreResolver.TypeResolutionCache>();
44+
builder.Services.TryAddSingleton<OpenIddictEntityFrameworkCoreAuthorizationStoreResolver.TypeResolutionCache>();
45+
builder.Services.TryAddSingleton<OpenIddictEntityFrameworkCoreScopeStoreResolver.TypeResolutionCache>();
46+
builder.Services.TryAddSingleton<OpenIddictEntityFrameworkCoreTokenStoreResolver.TypeResolutionCache>();
47+
48+
builder.Services.TryAddScoped(typeof(Store.OpenIddictEntityFrameworkCoreApplicationStore<,,,,>));
49+
builder.Services.TryAddScoped(typeof(Store.OpenIddictEntityFrameworkCoreAuthorizationStore<,,,,>));
50+
builder.Services.TryAddScoped(typeof(Store.OpenIddictEntityFrameworkCoreScopeStore<,,>));
51+
builder.Services.TryAddScoped(typeof(Store.OpenIddictEntityFrameworkCoreTokenStore<,,,,>));
52+
53+
returnnewOpenIddictEntityFrameworkCoreBuilder(builder.Services);
54+
}
55+
56+
/// <summary>
57+
/// 注册efcore store服务
58+
/// 配置 OpenIddict 实体
59+
/// </summary>
60+
/// <remarks>此扩展方法可多次调用</remarks>
61+
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
62+
publicstaticOpenIddictCoreBuilderUseEntityFrameworkCore(
63+
thisOpenIddictCoreBuilderbuilder,Action<OpenIddictEntityFrameworkCoreBuilder>configuration)
64+
{
65+
if(builderisnull)
66+
{
67+
thrownewArgumentNullException(nameof(builder));
68+
}
69+
70+
if(configurationisnull)
71+
{
72+
thrownewArgumentNullException(nameof(configuration));
73+
}
74+
75+
configuration(builder.UseEntityFrameworkCore());
76+
77+
returnbuilder;
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp