Skip to content

Commit 8c4356c

Browse files
authored
feat: OpenIdConnect supports PostgreSQL (#744)
1 parent 433b3eb commit 8c4356c

28 files changed

+411
-0
lines changed

Masa.Framework.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Utils.DynamicsCrm.Core
625625
EndProject
626626
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Utils.DynamicsCrm.EntityFrameworkCore", "src\Utils\DynamicsCrm\Masa.Utils.DynamicsCrm.EntityFrameworkCore\Masa.Utils.DynamicsCrm.EntityFrameworkCore.csproj", "{8A51A2A9-FBF4-40DC-AD89-AD3B9D3A50DC}"
627627
EndProject
628+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql", "src\Contrib\Authentication\OpenIdConnect\Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql\Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql.csproj", "{F100414F-CD8D-49D4-BFE0-88D94E53E628}"
629+
EndProject
628630
Global
629631
GlobalSection(SolutionConfigurationPlatforms) = preSolution
630632
Debug|Any CPU = Debug|Any CPU
@@ -2185,6 +2187,14 @@ Global
21852187
{8A51A2A9-FBF4-40DC-AD89-AD3B9D3A50DC}.Release|Any CPU.Build.0 = Release|Any CPU
21862188
{8A51A2A9-FBF4-40DC-AD89-AD3B9D3A50DC}.Release|x64.ActiveCfg = Release|Any CPU
21872189
{8A51A2A9-FBF4-40DC-AD89-AD3B9D3A50DC}.Release|x64.Build.0 = Release|Any CPU
2190+
{F100414F-CD8D-49D4-BFE0-88D94E53E628}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2191+
{F100414F-CD8D-49D4-BFE0-88D94E53E628}.Debug|Any CPU.Build.0 = Debug|Any CPU
2192+
{F100414F-CD8D-49D4-BFE0-88D94E53E628}.Debug|x64.ActiveCfg = Debug|Any CPU
2193+
{F100414F-CD8D-49D4-BFE0-88D94E53E628}.Debug|x64.Build.0 = Debug|Any CPU
2194+
{F100414F-CD8D-49D4-BFE0-88D94E53E628}.Release|Any CPU.ActiveCfg = Release|Any CPU
2195+
{F100414F-CD8D-49D4-BFE0-88D94E53E628}.Release|Any CPU.Build.0 = Release|Any CPU
2196+
{F100414F-CD8D-49D4-BFE0-88D94E53E628}.Release|x64.ActiveCfg = Release|Any CPU
2197+
{F100414F-CD8D-49D4-BFE0-88D94E53E628}.Release|x64.Build.0 = Release|Any CPU
21882198
EndGlobalSection
21892199
GlobalSection(SolutionProperties) = preSolution
21902200
HideSolutionNode = FALSE
@@ -2493,6 +2503,7 @@ Global
24932503
{64B54122-44F1-4379-9422-953EF706A3A6} = {5944A182-13B8-4DA6-AEE2-0A01E64A9648}
24942504
{83310F46-E1C7-4438-B32A-9F6F7EA13FCF} = {64B54122-44F1-4379-9422-953EF706A3A6}
24952505
{8A51A2A9-FBF4-40DC-AD89-AD3B9D3A50DC} = {64B54122-44F1-4379-9422-953EF706A3A6}
2506+
{F100414F-CD8D-49D4-BFE0-88D94E53E628} = {41769FBF-91A8-48D1-B3BB-CAE4C814E7CD}
24962507
EndGlobalSection
24972508
GlobalSection(ExtensibilityGlobals) = postSolution
24982509
SolutionGuid = {40383055-CC50-4600-AD9A-53C14F620D03}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) MASA Stack All rights reserved.
2+
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3+
4+
namespace Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql.EntityConfigurations;
5+
6+
public class ApiResourceClaimEntityTypeConfiguration : IEntityTypeConfiguration<ApiResourceClaim>
7+
{
8+
public void Configure(EntityTypeBuilder<ApiResourceClaim> builder)
9+
{
10+
builder.HasKey(x => x.Id);
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) MASA Stack All rights reserved.
2+
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3+
4+
namespace Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql.EntityConfigurations;
5+
6+
public class ApiResourceEntityTypeConfiguration : IEntityTypeConfiguration<ApiResource>
7+
{
8+
public void Configure(EntityTypeBuilder<ApiResource> builder)
9+
{
10+
builder.Property(x => x.Name).HasMaxLength(200).IsRequired();
11+
builder.Property(x => x.DisplayName).HasMaxLength(200);
12+
builder.Property(x => x.Description).HasMaxLength(1000);
13+
builder.Property(x => x.AllowedAccessTokenSigningAlgorithms).HasMaxLength(100);
14+
builder.HasIndex(x => x.Name).IsUnique().HasFilter("NOT \"IsDeleted\"");
15+
builder.HasMany(x => x.Secrets).WithOne(x => x.ApiResource).HasForeignKey(x => x.ApiResourceId).OnDelete(DeleteBehavior.Cascade);
16+
builder.HasMany(x => x.ApiScopes).WithOne(x => x.ApiResource).HasForeignKey(x => x.ApiResourceId).IsRequired().OnDelete(DeleteBehavior.Cascade);
17+
builder.HasMany(x => x.UserClaims).WithOne(x => x.ApiResource).HasForeignKey(x => x.ApiResourceId).OnDelete(DeleteBehavior.Cascade);
18+
builder.HasMany(x => x.Properties).WithOne(x => x.ApiResource).HasForeignKey(x => x.ApiResourceId).OnDelete(DeleteBehavior.Cascade);
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) MASA Stack All rights reserved.
2+
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3+
4+
namespace Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql.EntityConfigurations;
5+
6+
public class ApiResourcePropertyEntityTypeConfiguration : IEntityTypeConfiguration<ApiResourceProperty>
7+
{
8+
public void Configure(EntityTypeBuilder<ApiResourceProperty> builder)
9+
{
10+
builder.Property(x => x.Key).HasMaxLength(250).IsRequired();
11+
builder.Property(x => x.Value).HasMaxLength(2000).IsRequired();
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) MASA Stack All rights reserved.
2+
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3+
4+
namespace Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql.EntityConfigurations;
5+
6+
public class ApiResourceScopeEntityTypeConfiguration : IEntityTypeConfiguration<ApiResourceScope>
7+
{
8+
public void Configure(EntityTypeBuilder<ApiResourceScope> builder)
9+
{
10+
builder.HasKey(apiResourceScope => apiResourceScope.Id);
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) MASA Stack All rights reserved.
2+
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3+
4+
namespace Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql.EntityConfigurations;
5+
6+
public class ApiResourceSecretEntityTypeConfiguration : IEntityTypeConfiguration<ApiResourceSecret>
7+
{
8+
public void Configure(EntityTypeBuilder<ApiResourceSecret> builder)
9+
{
10+
builder.Property(x => x.Description).HasMaxLength(1000);
11+
builder.Property(x => x.Value).HasMaxLength(4000).IsRequired();
12+
builder.Property(x => x.Type).HasMaxLength(250).IsRequired();
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) MASA Stack All rights reserved.
2+
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3+
4+
namespace Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql.EntityConfigurations;
5+
6+
public class ApiScopeClaimEntityTypeConfiguration : IEntityTypeConfiguration<ApiScopeClaim>
7+
{
8+
public void Configure(EntityTypeBuilder<ApiScopeClaim> builder)
9+
{
10+
builder.HasKey(apiScopeClaim => apiScopeClaim.Id);
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) MASA Stack All rights reserved.
2+
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3+
4+
namespace Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql.EntityConfigurations;
5+
6+
public class ApiScopeEntityTypeConfiguration : IEntityTypeConfiguration<ApiScope>
7+
{
8+
public void Configure(EntityTypeBuilder<ApiScope> builder)
9+
{
10+
builder.HasIndex(apiScope => apiScope.Name).IsUnique();
11+
12+
builder.Property(apiScope => apiScope.Name).HasMaxLength(200).IsRequired();
13+
builder.Property(apiScope => apiScope.DisplayName).HasMaxLength(200);
14+
builder.Property(apiScope => apiScope.Description).HasMaxLength(1000);
15+
16+
builder.HasMany(apiScope => apiScope.UserClaims).WithOne(apiScope => apiScope.ApiScope).HasForeignKey(apiScope => apiScope.ApiScopeId).IsRequired().OnDelete(DeleteBehavior.Cascade);
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) MASA Stack All rights reserved.
2+
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3+
4+
namespace Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql.EntityConfigurations;
5+
6+
public class ApiScopePropertyEntityTypeConfiguration : IEntityTypeConfiguration<ApiScopeProperty>
7+
{
8+
public void Configure(EntityTypeBuilder<ApiScopeProperty> builder)
9+
{
10+
builder.Property(x => x.Key).HasMaxLength(250).IsRequired();
11+
builder.Property(x => x.Value).HasMaxLength(2000).IsRequired();
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) MASA Stack All rights reserved.
2+
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3+
4+
namespace Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql.EntityConfigurations;
5+
6+
public class ClientClaimEntityTypeConfiguration : IEntityTypeConfiguration<ClientClaim>
7+
{
8+
public void Configure(EntityTypeBuilder<ClientClaim> builder)
9+
{
10+
builder.Property(x => x.Type).HasMaxLength(250).IsRequired();
11+
builder.Property(x => x.Value).HasMaxLength(250).IsRequired();
12+
}
13+
}

0 commit comments

Comments
 (0)