Skip to content

Commit

Permalink
Merge pull request #1 from walidsaoudi/AS_AddedSqlite_Support
Browse files Browse the repository at this point in the history
Added Sqlite support
  • Loading branch information
walidsaoudi authored Jul 6, 2022
2 parents f993f64 + 7c28f11 commit ae304b7
Show file tree
Hide file tree
Showing 36 changed files with 4,526 additions and 158 deletions.
13 changes: 10 additions & 3 deletions Skoruba.IdentityServer4.Admin.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.452
# Visual Studio Version 17
VisualStudioVersion = 17.3.32519.111
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "admin", "admin", "{588205D4-3A30-4DA4-849D-C7422C396DAA}"
EndProject
Expand Down Expand Up @@ -55,7 +55,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Skoruba.IdentityServer4.Adm
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Skoruba.IdentityServer4.Admin.EntityFramework.Configuration", "src\Skoruba.IdentityServer4.Admin.EntityFramework.Configuration\Skoruba.IdentityServer4.Admin.EntityFramework.Configuration.csproj", "{45FB23BE-A7F9-4172-8868-B5E387007644}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Skoruba.IdentityServer4.Shared.Configuration", "src\Skoruba.IdentityServer4.Shared.Configuration\Skoruba.IdentityServer4.Shared.Configuration.csproj", "{D49A2D61-AEEB-457C-B3BA-D1322EB2F4EC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Skoruba.IdentityServer4.Shared.Configuration", "src\Skoruba.IdentityServer4.Shared.Configuration\Skoruba.IdentityServer4.Shared.Configuration.csproj", "{D49A2D61-AEEB-457C-B3BA-D1322EB2F4EC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Skoruba.IdentityServer4.Admin.EntityFramework.Sqlite", "src\Skoruba.IdentityServer4.Admin.EntityFramework.Sqlite\Skoruba.IdentityServer4.Admin.EntityFramework.Sqlite.csproj", "{EDFB9D5A-BF86-4C0F-A91C-0E443FEC9A72}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -151,6 +153,10 @@ Global
{D49A2D61-AEEB-457C-B3BA-D1322EB2F4EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D49A2D61-AEEB-457C-B3BA-D1322EB2F4EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D49A2D61-AEEB-457C-B3BA-D1322EB2F4EC}.Release|Any CPU.Build.0 = Release|Any CPU
{EDFB9D5A-BF86-4C0F-A91C-0E443FEC9A72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDFB9D5A-BF86-4C0F-A91C-0E443FEC9A72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDFB9D5A-BF86-4C0F-A91C-0E443FEC9A72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EDFB9D5A-BF86-4C0F-A91C-0E443FEC9A72}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -177,6 +183,7 @@ Global
{6DD24C2C-0FB5-4C37-8B42-5DACA0FDE4EC} = {588205D4-3A30-4DA4-849D-C7422C396DAA}
{45FB23BE-A7F9-4172-8868-B5E387007644} = {2A514C8F-6A53-41CA-AB41-B644E7BC92A7}
{D49A2D61-AEEB-457C-B3BA-D1322EB2F4EC} = {EE588CE5-51D0-4E98-A2B3-40EC8E655931}
{EDFB9D5A-BF86-4C0F-A91C-0E443FEC9A72} = {2A514C8F-6A53-41CA-AB41-B644E7BC92A7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B3166EDE-037B-4C68-BEBA-5DE9C5E3DB82}
Expand Down
15 changes: 15 additions & 0 deletions src/Skoruba.IdentityServer4.Admin.Api/Helpers/StartupHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
using Skoruba.IdentityServer4.Admin.EntityFramework.Configuration.Configuration;
using Skoruba.IdentityServer4.Admin.EntityFramework.Configuration.MySql;
using Skoruba.IdentityServer4.Admin.EntityFramework.Configuration.PostgreSQL;
using Skoruba.IdentityServer4.Admin.EntityFramework.Configuration.Sqlite;
using Skoruba.IdentityServer4.Admin.EntityFramework.Configuration.SqlServer;
using Skoruba.IdentityServer4.Admin.EntityFramework.Helpers;
using Skoruba.IdentityServer4.Admin.EntityFramework.Interfaces;

using Skoruba.IdentityServer4.Admin.EntityFramework.Sqlite.Helpers;

namespace Skoruba.IdentityServer4.Admin.Api.Helpers
{
public static class StartupHelpers
Expand Down Expand Up @@ -159,6 +162,9 @@ public static IServiceCollection AddAdminApiCors(this IServiceCollection service
case DatabaseProviderType.MySql:
services.RegisterMySqlDbContexts<TIdentityDbContext, TConfigurationDbContext, TPersistedGrantDbContext, TLogDbContext, TAuditLoggingDbContext, TDataProtectionDbContext, TAuditLog>(connectionStrings, databaseMigrations);
break;
case DatabaseProviderType.Sqlite:
services.RegisterSqliteDbContexts<TIdentityDbContext, TConfigurationDbContext, TPersistedGrantDbContext, TLogDbContext, TAuditLoggingDbContext, TDataProtectionDbContext, TAuditLog>(connectionStrings, databaseMigrations);
break;
default:
throw new ArgumentOutOfRangeException(nameof(databaseProvider.ProviderType), $@"The value needs to be one of {string.Join(", ", Enum.GetNames(typeof(DatabaseProviderType)))}.");
}
Expand Down Expand Up @@ -335,6 +341,15 @@ public static void AddIdSHealthChecks<TConfigurationDbContext, TPersistedGrantDb
.AddMySql(auditLogDbConnectionString, name: "AuditLogDb")
.AddMySql(dataProtectionDbConnectionString, name: "DataProtectionDb");
break;
case DatabaseProviderType.Sqlite:
healthChecksBuilder
.AddSqlite(configurationDbConnectionString, name: "ConfigurationDb")
.AddSqlite(persistedGrantsDbConnectionString, name: "PersistentGrantsDb")
.AddSqlite(identityDbConnectionString, name: "IdentityDb")
.AddSqlite(logDbConnectionString, name: "LogDb")
.AddSqlite(auditLogDbConnectionString, name: "AuditLogDb")
.AddSqlite(dataProtectionDbConnectionString, name: "DataProtectionDb");
break;
default:
throw new NotImplementedException($"Health checks not defined for database provider {databaseProvider.ProviderType}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.MySql" Version="6.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Sqlite" Version="6.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.MySql" Version="6.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="6.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.OpenIdConnectServer" Version="6.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="6.0.1" />
Expand Down Expand Up @@ -47,6 +48,7 @@
<ProjectReference Include="..\Skoruba.IdentityServer4.Admin.BusinessLogic\Skoruba.IdentityServer4.Admin.BusinessLogic.csproj" />
<ProjectReference Include="..\Skoruba.IdentityServer4.Admin.EntityFramework.MySql\Skoruba.IdentityServer4.Admin.EntityFramework.MySql.csproj" />
<ProjectReference Include="..\Skoruba.IdentityServer4.Admin.EntityFramework.PostgreSQL\Skoruba.IdentityServer4.Admin.EntityFramework.PostgreSQL.csproj" />
<ProjectReference Include="..\Skoruba.IdentityServer4.Admin.EntityFramework.Sqlite\Skoruba.IdentityServer4.Admin.EntityFramework.Sqlite.csproj" />
<ProjectReference Include="..\Skoruba.IdentityServer4.Admin.EntityFramework.SqlServer\Skoruba.IdentityServer4.Admin.EntityFramework.SqlServer.csproj" />
<ProjectReference Include="..\Skoruba.IdentityServer4.Shared.Configuration\Skoruba.IdentityServer4.Shared.Configuration.csproj" />
<ProjectReference Include="..\Skoruba.IdentityServer4.Shared\Skoruba.IdentityServer4.Shared.csproj" />
Expand Down
126 changes: 67 additions & 59 deletions src/Skoruba.IdentityServer4.Admin.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,72 @@
{
"ConnectionStrings": {
"ConfigurationDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true",
"PersistedGrantDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true",
"IdentityDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true",
"AdminLogDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true",
"AdminAuditLogDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true",
"DataProtectionDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true"
"ConnectionStringsOld": {
"ConfigurationDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true",
"PersistedGrantDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true",
"IdentityDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true",
"AdminLogDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true",
"AdminAuditLogDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true",
"DataProtectionDbConnection": "Server=(localdb)\\mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"ConnectionStrings": {
"ConfigurationDbConnection": "Data Source=E:\\SSO\\IdentityServer4Admin.db3",
"PersistedGrantDbConnection": "Data Source=E:\\SSO\\IdentityServer4Admin.db3",
"IdentityDbConnection": "Data Source=E:\\SSO\\IdentityServer4Admin.db3",
"AdminLogDbConnection": "Data Source=E:\\SSO\\IdentityServer4Admin.db3",
"AdminAuditLogDbConnection": "Data Source=E:\\SSO\\IdentityServer4Admin.db3",
"DataProtectionDbConnection": "Data Source=E:\\SSO\\IdentityServer4Admin.db3"
},
"AdminApiConfiguration": {
"ApiName": "Skoruba IdentityServer4 Admin Api",
"ApiVersion": "v1",
"ApiBaseUrl": "https://localhost:44302",
"IdentityServerBaseUrl": "https://localhost:44310",
"OidcSwaggerUIClientId": "skoruba_identity_admin_api_swaggerui",
"OidcApiName": "skoruba_identity_admin_api",
"AdministrationRole": "SkorubaIdentityAdminAdministrator",
"RequireHttpsMetadata": false,
"CorsAllowAnyOrigin": true,
"CorsAllowOrigins": []
},
"SmtpConfiguration": {
"Host": "",
"Login": "",
"Password": ""
},
"SendGridConfiguration": {
"ApiKey": "",
"SourceEmail": "",
"SourceName": ""
},
"DatabaseProviderConfiguration": {
"ProviderType": "Sqlite"
},
"AuditLoggingConfiguration": {
"Source": "IdentityServer.Admin.Api",
"SubjectIdentifierClaim": "sub",
"SubjectNameClaim": "name",
"ClientIdClaim": "client_id"
},
"IdentityOptions": {
"Password": {
"RequiredLength": 8
},
"AdminApiConfiguration": {
"ApiName": "Skoruba IdentityServer4 Admin Api",
"ApiVersion": "v1",
"ApiBaseUrl": "https://localhost:44302",
"IdentityServerBaseUrl": "https://localhost:44310",
"OidcSwaggerUIClientId": "skoruba_identity_admin_api_swaggerui",
"OidcApiName": "skoruba_identity_admin_api",
"AdministrationRole": "SkorubaIdentityAdminAdministrator",
"RequireHttpsMetadata": false,
"CorsAllowAnyOrigin": true,
"CorsAllowOrigins": []
"User": {
"RequireUniqueEmail": true
},
"SmtpConfiguration": {
"Host": "",
"Login": "",
"Password": ""
},
"SendGridConfiguration": {
"ApiKey": "",
"SourceEmail": "",
"SourceName": ""
},
"DatabaseProviderConfiguration": {
"ProviderType": "SqlServer"
},
"AuditLoggingConfiguration": {
"Source": "IdentityServer.Admin.Api",
"SubjectIdentifierClaim": "sub",
"SubjectNameClaim": "name",
"ClientIdClaim": "client_id"
},
"IdentityOptions": {
"Password": {
"RequiredLength": 8
},
"User": {
"RequireUniqueEmail": true
},
"SignIn": {
"RequireConfirmedAccount": false
}
},
"DataProtectionConfiguration": {
"ProtectKeysWithAzureKeyVault": false
},
"AzureKeyVaultConfiguration": {
"AzureKeyVaultEndpoint": "",
"ClientId": "",
"ClientSecret": "",
"TenantId": "",
"UseClientCredentials": true,
"DataProtectionKeyIdentifier": "",
"ReadConfigurationFromKeyVault": false
"SignIn": {
"RequireConfirmedAccount": false
}
},
"DataProtectionConfiguration": {
"ProtectKeysWithAzureKeyVault": false
},
"AzureKeyVaultConfiguration": {
"AzureKeyVaultEndpoint": "",
"ClientId": "",
"ClientSecret": "",
"TenantId": "",
"UseClientCredentials": true,
"DataProtectionKeyIdentifier": "",
"ReadConfigurationFromKeyVault": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public enum DatabaseProviderType
{
SqlServer,
PostgreSQL,
MySql
MySql,
Sqlite
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.6" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.2" />
<PackageReference Include="Skoruba.AuditLogging.EntityFramework" Version="1.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
Expand Down
Loading

0 comments on commit ae304b7

Please sign in to comment.