This repository has been archived by the owner on Aug 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from akselarzuman/master
Sqlite support added and vulnerabilities fixed
- Loading branch information
Showing
21 changed files
with
3,551 additions
and
343 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,4 +253,5 @@ docs/_build | |
docs/.vscode | ||
|
||
# Log files | ||
**/*log*.txt | ||
**/*log*.txt | ||
*.db |
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
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
34 changes: 34 additions & 0 deletions
34
src/Backend/Jp.Infra.Data.Sqlite/Configuration/IdentityConfig.cs
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,34 @@ | ||
using IdentityServer4.EntityFramework.Options; | ||
using Jp.Infra.CrossCutting.Identity.Context; | ||
using Jp.Infra.CrossCutting.Identity.Entities.Identity; | ||
using Jp.Infra.Data.Context; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System.Reflection; | ||
|
||
namespace Jp.Infra.Data.Sqlite.Configuration | ||
{ | ||
public static class IdentityConfig | ||
{ | ||
public static IServiceCollection AddIdentitySqlite(this IServiceCollection services, string connectionString) | ||
{ | ||
var migrationsAssembly = typeof(IdentityConfig).GetTypeInfo().Assembly.GetName().Name; | ||
|
||
var operationalStoreOptions = new OperationalStoreOptions(); | ||
services.AddSingleton(operationalStoreOptions); | ||
|
||
var storeOptions = new ConfigurationStoreOptions(); | ||
services.AddSingleton(storeOptions); | ||
|
||
services.AddEntityFrameworkSqlite().AddDbContext<ApplicationIdentityContext>(options => options.UseSqlite(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly))); | ||
services.AddDbContext<JpContext>(options => options.UseSqlite(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly))); | ||
services.AddDbContext<EventStoreContext>(options => options.UseSqlite(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly))); | ||
|
||
services.AddIdentity<UserIdentity, UserIdentityRole>() | ||
.AddEntityFrameworkStores<ApplicationIdentityContext>() | ||
.AddDefaultTokenProviders(); | ||
return services; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/Backend/Jp.Infra.Data.Sqlite/Configuration/IdentityServerConfig.cs
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,34 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System.Reflection; | ||
|
||
namespace Jp.Infra.Data.Sqlite.Configuration | ||
{ | ||
public static class IdentityServerConfig | ||
{ | ||
public static IIdentityServerBuilder UseIdentityServerSqlite(this IIdentityServerBuilder builder, string connectionString) | ||
{ | ||
var migrationsAssembly = typeof(IdentityServerConfig).GetTypeInfo().Assembly.GetName().Name; | ||
|
||
// this adds the config data from DB (clients, resources) | ||
builder.AddConfigurationStore(options => | ||
{ | ||
options.ConfigureDbContext = b => | ||
b.UseSqlite(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly)); | ||
}) | ||
// this adds the operational data from DB (codes, tokens, consents) | ||
.AddOperationalStore(options => | ||
{ | ||
options.ConfigureDbContext = b => | ||
b.UseSqlite(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly)); | ||
// this enables automatic token cleanup. this is optional. | ||
options.EnableTokenCleanup = true; | ||
options.TokenCleanupInterval = 15; // frequency in seconds to cleanup stale grants. 15 is useful during debugging | ||
}); | ||
|
||
return builder; | ||
} | ||
|
||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Backend/Jp.Infra.Data.Sqlite/Jp.Infra.Data.Sqlite.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,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Jp.Infra.CrossCutting.Identity\Jp.Infra.CrossCutting.Identity.csproj" /> | ||
<ProjectReference Include="..\Jp.Infra.Data\Jp.Infra.Data.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Migrations\" /> | ||
</ItemGroup> | ||
</Project> |
46 changes: 46 additions & 0 deletions
46
src/Backend/Jp.Infra.Data.Sqlite/Migrations/EventStore/20190828141939_Initial.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
src/Backend/Jp.Infra.Data.Sqlite/Migrations/EventStore/20190828141939_Initial.cs
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,33 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
namespace Jp.Infra.Data.Sqlite.Migrations.EventStore | ||
{ | ||
public partial class Initial : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "StoredEvent", | ||
columns: table => new | ||
{ | ||
Id = table.Column<Guid>(nullable: false), | ||
Action = table.Column<string>(type: "varchar(100)", nullable: true), | ||
AggregateId = table.Column<string>(nullable: true), | ||
CreationDate = table.Column<DateTime>(nullable: false), | ||
Data = table.Column<string>(nullable: true), | ||
User = table.Column<string>(nullable: true) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_StoredEvent", x => x.Id); | ||
}); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "StoredEvent"); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/Backend/Jp.Infra.Data.Sqlite/Migrations/EventStore/EventStoreContextModelSnapshot.cs
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,44 @@ | ||
// <auto-generated /> | ||
using System; | ||
using Jp.Infra.Data.Context; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
namespace Jp.Infra.Data.Sqlite.Migrations.EventStore | ||
{ | ||
[DbContext(typeof(EventStoreContext))] | ||
partial class EventStoreContextModelSnapshot : ModelSnapshot | ||
{ | ||
protected override void BuildModel(ModelBuilder modelBuilder) | ||
{ | ||
#pragma warning disable 612, 618 | ||
modelBuilder | ||
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079"); | ||
|
||
modelBuilder.Entity("Jp.Domain.Core.Events.StoredEvent", b => | ||
{ | ||
b.Property<Guid>("Id") | ||
.ValueGeneratedOnAdd(); | ||
b.Property<string>("AggregateId"); | ||
b.Property<string>("Data"); | ||
b.Property<string>("MessageType") | ||
.HasColumnName("Action") | ||
.HasColumnType("varchar(100)"); | ||
b.Property<DateTime>("Timestamp") | ||
.HasColumnName("CreationDate"); | ||
b.Property<string>("User"); | ||
b.HasKey("Id"); | ||
b.ToTable("StoredEvent"); | ||
}); | ||
#pragma warning restore 612, 618 | ||
} | ||
} | ||
} |
Oops, something went wrong.