diff --git a/.github/workflows/identity-module.yml b/.github/workflows/identity-module.yml
index c863eee9..a3960937 100644
--- a/.github/workflows/identity-module.yml
+++ b/.github/workflows/identity-module.yml
@@ -16,13 +16,13 @@ jobs:
- name: Set up .NET Core
uses: actions/setup-dotnet@v2
with:
- dotnet-version: 8.0.x
+ dotnet-version: 9.0.x
- name: Install dependencies
- run: dotnet restore 'AspNetCore v8.0/Calabonga.Microservice.IdentityModule.Template/Calabonga.Microservice.IdentityModule.Template.csproj'
+ run: dotnet restore 'AspNetCore v9.0/Calabonga.Microservice.IdentityModule.Template/Calabonga.Microservice.IdentityModule.Template.csproj'
- name: Build the NuGet package
- run: dotnet pack 'AspNetCore v8.0/Calabonga.Microservice.IdentityModule.Template/Calabonga.Microservice.IdentityModule.Template.csproj' --configuration Release --output ${{env.DOTNET_ROOT}}\Package
+ run: dotnet pack 'AspNetCore v9.0/Calabonga.Microservice.IdentityModule.Template/Calabonga.Microservice.IdentityModule.Template.csproj' --configuration Release --output ${{env.DOTNET_ROOT}}\Package
- name: Publish NuGet Package Calabonga.Microservice.Module
run: dotnet nuget push ${{env.DOTNET_ROOT}}\Package\*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
diff --git a/.github/workflows/module.yml b/.github/workflows/module.yml
index 5db1451d..e41df35c 100644
--- a/.github/workflows/module.yml
+++ b/.github/workflows/module.yml
@@ -16,13 +16,13 @@ jobs:
- name: Set up .NET Core
uses: actions/setup-dotnet@v2
with:
- dotnet-version: 8.0.x
+ dotnet-version: 9.0.x
- name: Install dependencies
- run: dotnet restore 'AspNetCore v8.0/Calabonga.Microservice.Module.Template/Calabonga.Microservice.Module.Template.csproj'
+ run: dotnet restore 'AspNetCore v9.0/Calabonga.Microservice.Module.Template/Calabonga.Microservice.Module.Template.csproj'
- name: Build the NuGet package
- run: dotnet pack 'AspNetCore v8.0/Calabonga.Microservice.Module.Template/Calabonga.Microservice.Module.Template.csproj' --configuration Release --output ${{env.DOTNET_ROOT}}\Package
+ run: dotnet pack 'AspNetCore v9.0/Calabonga.Microservice.Module.Template/Calabonga.Microservice.Module.Template.csproj' --configuration Release --output ${{env.DOTNET_ROOT}}\Package
- name: Publish NuGet Package
run: dotnet nuget push ${{env.DOTNET_ROOT}}\Package\*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/AppData.Common.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/AppData.Common.cs
deleted file mode 100644
index d9aa740f..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/AppData.Common.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace Calabonga.Microservice.IdentityModule.Core
-{
- ///
- /// Static data container
- ///
- public static partial class AppData
- {
- ///
- /// Current service name
- ///
- public const string ServiceName = "IdentityModule";
-
- ///
- /// "SystemAdministrator"
- ///
- public const string SystemAdministratorRoleName = "Administrator";
-
- ///
- /// "BusinessOwner"
- ///
- public const string ManagerRoleName = "Manager";
-
- ///
- /// Roles
- ///
- public static IEnumerable Roles
- {
- get
- {
- yield return SystemAdministratorRoleName;
- yield return ManagerRoleName;
- }
- }
-
- ///
- /// IdentityServer4 path
- ///
- public const string AuthUrl = "/auth";
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/AppData.Exceptions.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/AppData.Exceptions.cs
deleted file mode 100644
index b1f593f3..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/AppData.Exceptions.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-namespace Calabonga.Microservice.IdentityModule.Core
-{
- public static partial class AppData
- {
- ///
- /// Exception messages
- ///
- public static class Exceptions
- {
- ///
- /// "An exception was thrown"
- ///
- public static string ThrownException => "An exception was thrown";
-
- ///
- /// "Invalid cast exception"
- ///
- public static string TypeConverterException => "Invalid cast exception";
-
- ///
- /// "User not registered in the system"
- ///
- public static string UserNotFoundException => "User not registered in the system";
-
- ///
- /// "Object not found"
- ///
- public static string NotFoundException => "Object not found";
-
- ///
- /// "Unauthorized access denied"
- ///
- public static string UnauthorizedException => "Unauthorized access denied";
-
- ///
- /// "Argument null exception"
- ///
- public static string ArgumentNullException => "Argument null exception";
-
- ///
- /// "File already exists"
- ///
- public static string FileAlreadyExists => "File already exists";
-
- ///
- /// "Some errors occurred while checking the entity"
- ///
- public static string EntityValidationException => "Some errors occurred while checking the entity";
-
- ///
- /// "Invalid operation exception was thrown"
- ///
- public static string InvalidOperationException => "Invalid operation exception was thrown";
-
- ///
- /// "Argument out of range"
- ///
- public static string ArgumentOutOfRangeException => "Argument out of range";
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/AppData.Messages.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/AppData.Messages.cs
deleted file mode 100644
index a06fde08..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/AppData.Messages.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace Calabonga.Microservice.IdentityModule.Core
-{
- public static partial class AppData
- {
- ///
- /// Common messages
- ///
- public static class Messages
- {
- ///
- /// "User successfully registered"
- ///
- public static string UserSuccessfullyRegistered => "User successfully registered";
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/Calabonga.Microservice.IdentityModule.Core.csproj b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/Calabonga.Microservice.IdentityModule.Core.csproj
deleted file mode 100644
index cb631906..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Core/Calabonga.Microservice.IdentityModule.Core.csproj
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
- netcoreapp3.1
-
-
-
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationDbContext.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationDbContext.cs
deleted file mode 100644
index 83b19f26..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationDbContext.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using Calabonga.Microservice.IdentityModule.Data.Base;
-using Calabonga.Microservice.IdentityModule.Entities;
-using Microsoft.EntityFrameworkCore;
-
-namespace Calabonga.Microservice.IdentityModule.Data
-{
- ///
- /// Database context for current application
- ///
- public class ApplicationDbContext : DbContextBase, IApplicationDbContext
- {
- public ApplicationDbContext(DbContextOptions options)
- : base(options) { }
-
- #region System
-
- public DbSet Logs { get; set; }
-
- public DbSet Profiles { get; set; }
-
- ///
- public DbSet Permissions { get; set; }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationRole.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationRole.cs
deleted file mode 100644
index 0f155d16..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationRole.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using Microsoft.AspNetCore.Identity;
-
-namespace Calabonga.Microservice.IdentityModule.Data
-{
- ///
- /// Application role
- ///
- public class ApplicationRole : IdentityRole
- {
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationUser.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationUser.cs
deleted file mode 100644
index dac4180d..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationUser.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using Microsoft.AspNetCore.Identity;
-
-namespace Calabonga.Microservice.IdentityModule.Data
-{
- ///
- /// Default user for application.
- /// Add profile data for application users by adding properties to the ApplicationUser class
- ///
- public class ApplicationUser : IdentityUser
- {
- ///
- /// FirstName
- ///
- public string FirstName { get; set; }
-
- ///
- /// LastName
- ///
- public string LastName { get; set; }
-
- ///
- /// Profile identity
- ///
- public Guid? ApplicationUserProfileId { get; set; }
-
- ///
- /// User Profile
- ///
- public virtual ApplicationUserProfile ApplicationUserProfile { get; set; }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationUserProfile.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationUserProfile.cs
deleted file mode 100644
index 3b6d451d..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationUserProfile.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System.Collections.Generic;
-using Calabonga.EntityFrameworkCore.Entities.Base;
-
-namespace Calabonga.Microservice.IdentityModule.Data
-{
- ///
- /// Represent person with login information (ApplicationUser)
- ///
- public class ApplicationUserProfile: Auditable
- {
- ///
- /// Account
- ///
- public virtual ApplicationUser ApplicationUser { get; set; }
-
- ///
- /// Microservice permission for policy-based authorization
- ///
- public ICollection Permissions { get; set; }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationUserStore.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationUserStore.cs
deleted file mode 100644
index 74986cf8..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ApplicationUserStore.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore;
-
-namespace Calabonga.Microservice.IdentityModule.Data
-{
- ///
- /// Application store for user
- ///
- public class ApplicationUserStore : UserStore
- {
- public ApplicationUserStore(ApplicationDbContext context, IdentityErrorDescriber describer = null)
- : base(context, describer)
- {
-
- }
-
- ///
- public override Task FindByIdAsync(string userId, CancellationToken cancellationToken = new CancellationToken())
- {
- return Users
- .Include(x => x.ApplicationUserProfile)
- .ThenInclude(x => x.Permissions)
- .FirstOrDefaultAsync(u => u.Id.ToString() == userId, cancellationToken: cancellationToken);
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/Base/DbContextBase.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/Base/DbContextBase.cs
deleted file mode 100644
index 9fc8b1d6..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/Base/DbContextBase.cs
+++ /dev/null
@@ -1,264 +0,0 @@
-using System;
-using System.Linq;
-using System.Reflection;
-using System.Threading;
-using System.Threading.Tasks;
-using Calabonga.EntityFrameworkCore.Entities.Base;
-using Calabonga.UnitOfWork;
-using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore;
-
-namespace Calabonga.Microservice.IdentityModule.Data.Base
-{
- ///
- /// Base DbContext with predefined configuration
- ///
- public abstract class DbContextBase : IdentityDbContext
- {
- private const string DefaultUserName = "Anonymous";
-
- protected DbContextBase(DbContextOptions options) : base(options)
- {
- LastSaveChangesResult = new SaveChangesResult();
- }
-
- public SaveChangesResult LastSaveChangesResult { get; }
-
-
- ///
- /// Asynchronously saves all changes made in this context to the database.
- ///
- ///
- /// Indicates whether is called after the changes have
- /// been sent successfully to the database.
- ///
- ///
- ///
- /// This method will automatically call to discover any
- /// changes to entity instances before saving to the underlying database. This can be disabled via
- /// .
- ///
- ///
- /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
- /// that any asynchronous operations have completed before calling another method on this context.
- ///
- ///
- /// A to observe while waiting for the task to complete.
- ///
- /// A task that represents the asynchronous save operation. The task result contains the
- /// number of state entries written to the database.
- ///
- ///
- /// An error is encountered while saving to the database.
- ///
- ///
- /// A concurrency violation is encountered while saving to the database.
- /// A concurrency violation occurs when an unexpected number of rows are affected during save.
- /// This is usually because the data in the database has been modified since it was loaded into memory.
- ///
- public override Task SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = new CancellationToken())
- {
- try
- {
- DbSaveChanges();
- return base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken);
- }
- catch (Exception exception)
- {
- LastSaveChangesResult.Exception = exception;
- return Task.FromResult(0);
- }
- }
-
- ///
- /// Saves all changes made in this context to the database.
- ///
- ///
- /// Indicates whether is called after the changes have
- /// been sent successfully to the database.
- ///
- ///
- /// This method will automatically call to discover any
- /// changes to entity instances before saving to the underlying database. This can be disabled via
- /// .
- ///
- ///
- /// The number of state entries written to the database.
- ///
- ///
- /// An error is encountered while saving to the database.
- ///
- ///
- /// A concurrency violation is encountered while saving to the database.
- /// A concurrency violation occurs when an unexpected number of rows are affected during save.
- /// This is usually because the data in the database has been modified since it was loaded into memory.
- ///
- public override int SaveChanges(bool acceptAllChangesOnSuccess)
- {
- try
- {
- DbSaveChanges();
- return base.SaveChanges(acceptAllChangesOnSuccess);
- }
- catch (Exception exception)
- {
- LastSaveChangesResult.Exception = exception;
- return 0;
- }
- }
-
- public override int SaveChanges()
- {
- try
- {
- DbSaveChanges();
- return base.SaveChanges();
- }
- catch (Exception exception)
- {
- LastSaveChangesResult.Exception = exception;
- return 0;
- }
- }
-
- ///
- /// Asynchronously saves all changes made in this context to the database.
- ///
- ///
- ///
- /// This method will automatically call to discover any
- /// changes to entity instances before saving to the underlying database. This can be disabled via
- /// .
- ///
- ///
- /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
- /// that any asynchronous operations have completed before calling another method on this context.
- ///
- ///
- /// A to observe while waiting for the task to complete.
- ///
- /// A task that represents the asynchronous save operation. The task result contains the
- /// number of state entries written to the database.
- ///
- ///
- /// An error is encountered while saving to the database.
- ///
- ///
- /// A concurrency violation is encountered while saving to the database.
- /// A concurrency violation occurs when an unexpected number of rows are affected during save.
- /// This is usually because the data in the database has been modified since it was loaded into memory.
- ///
- public override Task SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
- {
- try
- {
- DbSaveChanges();
- return base.SaveChangesAsync(cancellationToken);
- }
- catch (Exception exception)
- {
- LastSaveChangesResult.Exception = exception;
- return Task.FromResult(0);
- }
- }
-
- private void DbSaveChanges()
- {
- var createdEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Added);
- foreach (var entry in createdEntries)
- {
- if (!(entry.Entity is IAuditable))
- {
- continue;
- }
-
- var creationDate = DateTime.Now.ToUniversalTime();
- var userName = entry.Property("CreatedBy").CurrentValue == null
- ? DefaultUserName
- : entry.Property("CreatedBy").CurrentValue;
- var updatedAt = entry.Property("UpdatedAt").CurrentValue;
- var createdAt = entry.Property("CreatedAt").CurrentValue;
- if (createdAt != null)
- {
- if (DateTime.Parse(createdAt.ToString()).Year > 1970)
- {
- entry.Property("CreatedAt").CurrentValue = ((DateTime)createdAt).ToUniversalTime();
- }
- else
- {
- entry.Property("CreatedAt").CurrentValue = creationDate;
- }
- }
- else
- {
- entry.Property("CreatedAt").CurrentValue = creationDate;
- }
-
- if (updatedAt != null)
- {
- if (DateTime.Parse(updatedAt.ToString()).Year > 1970)
- {
- entry.Property("UpdatedAt").CurrentValue = ((DateTime)updatedAt).ToUniversalTime();
- }
- else
- {
- entry.Property("UpdatedAt").CurrentValue = creationDate;
- }
- }
- else
- {
- entry.Property("UpdatedAt").CurrentValue = creationDate;
- }
-
- entry.Property("CreatedBy").CurrentValue = userName;
- entry.Property("UpdatedBy").CurrentValue = userName;
-
- LastSaveChangesResult.AddMessage($"ChangeTracker has new entities: {entry.Entity.GetType()}");
- }
-
- var updatedEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Modified);
- foreach (var entry in updatedEntries)
- {
- if (entry.Entity is IAuditable)
- {
- var userName = entry.Property("UpdatedBy").CurrentValue == null
- ? DefaultUserName
- : entry.Property("UpdatedBy").CurrentValue;
- entry.Property("UpdatedAt").CurrentValue = DateTime.Now.ToUniversalTime();
- entry.Property("UpdatedBy").CurrentValue = userName;
- }
-
- LastSaveChangesResult.AddMessage($"ChangeTracker has modified entities: {entry.Entity.GetType()}");
- }
- }
-
- ///
- /// Configures the schema needed for the identity framework.
- ///
- ///
- /// The builder being used to construct the model for this context.
- ///
- protected override void OnModelCreating(ModelBuilder builder)
- {
- base.OnModelCreating(builder);
-
- var applyGenericMethod = typeof(ModelBuilder).GetMethods(BindingFlags.Instance | BindingFlags.Public).First(x => x.Name == "ApplyConfiguration");
- foreach (var type in Assembly.GetExecutingAssembly().GetTypes().Where(c => c.IsClass && !c.IsAbstract && !c.ContainsGenericParameters))
- {
- foreach (var item in type.GetInterfaces())
- {
- if (!item.IsConstructedGenericType || item.GetGenericTypeDefinition() != typeof(IEntityTypeConfiguration<>))
- {
- continue;
- }
-
- var applyConcreteMethod = applyGenericMethod.MakeGenericMethod(item.GenericTypeArguments[0]);
- applyConcreteMethod.Invoke(builder, new[] { Activator.CreateInstance(type) });
- break;
- }
- }
-
- builder.EnableAutoHistory(2048);
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/Calabonga.Microservice.IdentityModule.Data.csproj b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/Calabonga.Microservice.IdentityModule.Data.csproj
deleted file mode 100644
index 59d98c48..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/Calabonga.Microservice.IdentityModule.Data.csproj
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- netcoreapp3.1
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
-
-
-
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/DatabaseInitialization/DatabaseInitializer.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/DatabaseInitialization/DatabaseInitializer.cs
deleted file mode 100644
index 0a16619b..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/DatabaseInitialization/DatabaseInitializer.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Calabonga.Microservice.IdentityModule.Core;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Calabonga.Microservice.IdentityModule.Data.DatabaseInitialization
-{
- ///
- /// Database Initializer
- ///
- public static class DatabaseInitializer
- {
- public static async void Seed(IServiceProvider serviceProvider)
- {
- using var scope = serviceProvider.CreateScope();
- await using var context = scope.ServiceProvider.GetService();
-
- // Should be uncomment when using UseSqlServer() settings or any other provider.
- // This is should not be used when UseInMemoryDatabase()
- // context.Database.Migrate();
-
- var roles = AppData.Roles.ToArray();
-
- foreach (var role in roles)
- {
- var roleManager = scope.ServiceProvider.GetRequiredService>();
- if (!context.Roles.Any(r => r.Name == role))
- {
- await roleManager.CreateAsync(new ApplicationRole { Name = role, NormalizedName = role.ToUpper() });
- }
- }
-
- #region developer
-
- var developer1 = new ApplicationUser
- {
- Email = "microservice@yopmail.com",
- NormalizedEmail = "MICROSERVICE@YOPMAIL.COM",
- UserName = "microservice@yopmail.com",
- FirstName = "Microservice",
- LastName = "Administrator",
- NormalizedUserName = "MICROSERVICE@YOPMAIL.COM",
- PhoneNumber = "+79000000000",
- EmailConfirmed = true,
- PhoneNumberConfirmed = true,
- SecurityStamp = Guid.NewGuid().ToString("D"),
- ApplicationUserProfile = new ApplicationUserProfile
- {
- CreatedAt = DateTime.Now,
- CreatedBy = "SEED",
- Permissions = new List
- {
- new MicroservicePermission
- {
- CreatedAt = DateTime.Now,
- CreatedBy = "SEED",
- PolicyName = "Logs:UserRoles:View",
- Description = "Access policy for Logs controller user view"
- }
- }
- }
- };
-
- if (!context.Users.Any(u => u.UserName == developer1.UserName))
- {
- var password = new PasswordHasher();
- var hashed = password.HashPassword(developer1, "123qwe!@#");
- developer1.PasswordHash = hashed;
- var userStore = scope.ServiceProvider.GetService();
- var result = await userStore.CreateAsync(developer1);
- if (!result.Succeeded)
- {
- throw new InvalidOperationException("Cannot create account");
- }
-
- var userManager = scope.ServiceProvider.GetService>();
- foreach (var role in roles)
- {
- var roleAdded = await userManager.AddToRoleAsync(developer1, role);
- if (roleAdded.Succeeded)
- {
- await context.SaveChangesAsync();
- }
- }
- }
- #endregion
-
- await context.SaveChangesAsync();
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/IApplicaitonDbContext.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/IApplicaitonDbContext.cs
deleted file mode 100644
index 4fc2f735..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/IApplicaitonDbContext.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using Calabonga.Microservice.IdentityModule.Entities;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.ChangeTracking;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-namespace Calabonga.Microservice.IdentityModule.Data
-{
- ///
- /// Abstraction for Database (EntityFramework)
- ///
- public interface IApplicationDbContext
- {
- #region System
-
- DbSet Logs { get; set; }
-
- DbSet Users { get; set; }
-
- DbSet Profiles { get; set; }
-
- DbSet Permissions { get; set; }
-
- DatabaseFacade Database { get; }
-
- ChangeTracker ChangeTracker { get; }
-
- DbSet Set() where TEntity : class;
-
- int SaveChanges();
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/MicroservicePermission.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/MicroservicePermission.cs
deleted file mode 100644
index ec2e42dc..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/MicroservicePermission.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using Calabonga.EntityFrameworkCore.Entities.Base;
-
-namespace Calabonga.Microservice.IdentityModule.Data
-{
- ///
- /// User permission for microservice
- ///
- public class MicroservicePermission: Auditable
- {
- ///
- /// Application User profile identifier
- ///
- public Guid ApplicationUserProfileId { get; set; }
-
- ///
- /// Application User Profile
- ///
- public virtual ApplicationUserProfile ApplicationUserProfile { get; set; }
-
- ///
- /// Authorize attribute policy name
- ///
- public string PolicyName { get; set; }
-
- ///
- /// Description for current permission
- ///
- public string Description { get; set; }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/ApplicationUserModelConfiguration.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/ApplicationUserModelConfiguration.cs
deleted file mode 100644
index 753c6dcb..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/ApplicationUserModelConfiguration.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace Calabonga.Microservice.IdentityModule.Data.ModelConfigurations
-{
- ///
- /// Entity Type Configuration for entity
- ///
-
- public class ApplicationUserModelConfiguration : IEntityTypeConfiguration
- {
-
- ///
- /// Configures the entity of type .
- ///
- /// The builder to be used to configure the entity type.
- public void Configure(EntityTypeBuilder builder)
- {
- builder.Property(x => x.LastName).HasMaxLength(128).IsRequired();
- builder.Property(x => x.FirstName).HasMaxLength(128).IsRequired();
- builder.Property(x => x.ApplicationUserProfileId).IsRequired(false);
-
- builder.HasOne(x => x.ApplicationUserProfile);
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/ApplicationUserProfileModelConfiguration.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/ApplicationUserProfileModelConfiguration.cs
deleted file mode 100644
index 8332a9a5..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/ApplicationUserProfileModelConfiguration.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using Calabonga.Microservice.IdentityModule.Data.ModelConfigurations.Base;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace Calabonga.Microservice.IdentityModule.Data.ModelConfigurations
-{
- ///
- /// Entity Type Configuration for entity
- ///
-
- public class ApplicationUserProfileModelConfiguration : AuditableModelConfigurationBase
- {
- protected override void AddBuilder(EntityTypeBuilder builder)
- {
- builder.HasMany(x => x.Permissions);
-
- builder.HasOne(x => x.ApplicationUser)
- .WithOne(x => x.ApplicationUserProfile)
- .HasForeignKey(x => x.ApplicationUserProfileId);
- }
-
- protected override string TableName()
- {
- return "ApplicationUserProfiles";
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/Base/AuditableModelConfigurationBase.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/Base/AuditableModelConfigurationBase.cs
deleted file mode 100644
index 3c78e4a9..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/Base/AuditableModelConfigurationBase.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using Calabonga.EntityFrameworkCore.Entities.Base;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace Calabonga.Microservice.IdentityModule.Data.ModelConfigurations.Base
-{
- ///
- /// Audit-able Model Configuration base
- ///
- ///
- public abstract class AuditableModelConfigurationBase : IEntityTypeConfiguration where T : Auditable
- {
- public void Configure(EntityTypeBuilder builder)
- {
- builder.ToTable(TableName());
- builder.HasKey(x => x.Id);
- builder.Property(x => x.Id).IsRequired();
-
- // audit
- builder.Property(x => x.CreatedAt).IsRequired().HasConversion(v => v, v => DateTime.SpecifyKind(v, DateTimeKind.Utc)).IsRequired();
- builder.Property(x => x.CreatedBy).HasMaxLength(256).IsRequired();
- builder.Property(x => x.UpdatedAt).HasConversion(v => v.Value, v => DateTime.SpecifyKind(v, DateTimeKind.Utc));
- builder.Property(x => x.UpdatedBy).HasMaxLength(256);
-
- AddBuilder(builder);
- }
-
- ///
- /// Add custom properties for your entity
- ///
- ///
- protected abstract void AddBuilder(EntityTypeBuilder builder);
-
- ///
- /// Table name
- ///
- ///
- protected abstract string TableName();
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/Base/IdentityModelConfigurationBase.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/Base/IdentityModelConfigurationBase.cs
deleted file mode 100644
index 203b24cb..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/Base/IdentityModelConfigurationBase.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using Calabonga.EntityFrameworkCore.Entities.Base;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace Calabonga.Microservice.IdentityModule.Data.ModelConfigurations.Base
-{
- ///
- /// Audit-able Model Configuration base
- ///
- ///
- public abstract class IdentityModelConfigurationBase : IEntityTypeConfiguration where T : Identity
- {
- public void Configure(EntityTypeBuilder builder)
- {
- builder.ToTable(TableName());
- builder.HasKey(x => x.Id);
- builder.Property(x => x.Id).IsRequired();
-
- AddBuilder(builder);
- }
-
- ///
- /// Add custom properties for your entity
- ///
- ///
- protected abstract void AddBuilder(EntityTypeBuilder builder);
-
- ///
- /// Table name
- ///
- ///
- protected abstract string TableName();
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/LogModelConfiguration.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/LogModelConfiguration.cs
deleted file mode 100644
index eefdfe52..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/LogModelConfiguration.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using Calabonga.Microservice.IdentityModule.Data.ModelConfigurations.Base;
-using Calabonga.Microservice.IdentityModule.Entities;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace Calabonga.Microservice.IdentityModule.Data.ModelConfigurations
-{
- ///
- /// Entity Type Configuration for entity
- ///
- public class LogModelConfiguration: IdentityModelConfigurationBase
- {
- protected override void AddBuilder(EntityTypeBuilder builder)
- {
- builder.Property(x => x.Logger).HasMaxLength(255).IsRequired();
- builder.Property(x => x.Level).HasMaxLength(50).IsRequired();
- builder.Property(x => x.Message).HasMaxLength(4000).IsRequired();
- builder.Property(x => x.CreatedAt).HasConversion(v => v, v => DateTime.SpecifyKind(v, DateTimeKind.Utc)).IsRequired();
- builder.Property(x => x.ThreadId).HasMaxLength(255);
- builder.Property(x => x.ExceptionMessage).HasMaxLength(2000);
- }
-
- protected override string TableName()
- {
- return "Logs";
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/MicroservicePermissionModelConfiguration.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/MicroservicePermissionModelConfiguration.cs
deleted file mode 100644
index a3d3e032..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Data/ModelConfigurations/MicroservicePermissionModelConfiguration.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using Calabonga.Microservice.IdentityModule.Data.ModelConfigurations.Base;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-
-namespace Calabonga.Microservice.IdentityModule.Data.ModelConfigurations
-{
- ///
- /// Entity Type Configuration for entity
- ///
-
- public class MicroservicePermissionModelConfiguration : AuditableModelConfigurationBase
- {
- protected override void AddBuilder(EntityTypeBuilder builder)
- {
- builder.Property(x => x.PolicyName).HasMaxLength(64).IsRequired();
- builder.Property(x => x.Description).HasMaxLength(1024);
- builder.Property(x => x.ApplicationUserProfileId).IsRequired();
-
- builder.HasOne(x => x.ApplicationUserProfile).WithMany(x => x.Permissions);
- }
-
- protected override string TableName()
- {
- return "MicroservicePermissions";
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Models/Calabonga.Microservice.IdentityModule.Entities.csproj b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Models/Calabonga.Microservice.IdentityModule.Entities.csproj
deleted file mode 100644
index f0c983a0..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Models/Calabonga.Microservice.IdentityModule.Entities.csproj
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- netcoreapp3.1
-
-
-
-
-
-
-
-
-
-
-
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Models/Log.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Models/Log.cs
deleted file mode 100644
index c97abef1..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Models/Log.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using Calabonga.EntityFrameworkCore.Entities.Base;
-
-namespace Calabonga.Microservice.IdentityModule.Entities
-{
- ///
- /// Log entity for demo purposes only
- ///
- public class Log: Identity
- {
- public DateTime CreatedAt { get; set; }
-
- public string Logger { get; set; }
-
- public string Level { get; set; }
-
- public string Message { get; set; }
-
- public string ThreadId { get; set; }
-
- public string ExceptionMessage { get; set; }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesAuthentication.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesAuthentication.cs
deleted file mode 100644
index 4b2d245f..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesAuthentication.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using Calabonga.Microservice.IdentityModule.Core;
-using Calabonga.Microservice.IdentityModule.Data;
-using Calabonga.Microservice.IdentityModule.Web.Infrastructure.Services;
-using IdentityServer4.AccessTokenValidation;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart.ConfigureServices
-{
- ///
- /// ASP.NET Core services registration and configurations
- /// Authentication path
- ///
- public static class ConfigureServicesAuthentication
- {
- ///
- /// Configure Authentication & Authorization
- ///
- ///
- ///
- public static void ConfigureServices(IServiceCollection services, IConfiguration configuration)
- {
- var url = configuration.GetSection("IdentityServer").GetValue("Url");
- services.AddAuthentication(options =>
- {
- options.DefaultScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
- options.DefaultAuthenticateScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
- options.DefaultChallengeScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
- options.DefaultSignInScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
- options.DefaultSignOutScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
- })
- .AddIdentityServerAuthentication(options =>
- {
- options.SupportedTokens = SupportedTokens.Jwt;
- options.Authority = $"{url}{AppData.AuthUrl}";
- options.EnableCaching = true;
- options.RequireHttpsMetadata = false;
- });
-
- services.AddIdentityServer(options =>
- {
- options.Authentication.CookieSlidingExpiration = true;
- options.IssuerUri = $"{url}{AppData.AuthUrl}";
- options.Events.RaiseErrorEvents = true;
- options.Events.RaiseInformationEvents = true;
- options.Events.RaiseFailureEvents = true;
- options.Events.RaiseSuccessEvents = true;
- })
- .AddInMemoryPersistedGrants()
- .AddDeveloperSigningCredential()
- .AddInMemoryIdentityResources(IdentityServerConfig.GetIdentityResources())
- .AddInMemoryApiResources(IdentityServerConfig.GetApiResources())
- .AddInMemoryClients(IdentityServerConfig.GetClients())
- .AddInMemoryApiScopes(IdentityServerConfig.GetAPiScopes())
- .AddAspNetIdentity()
- .AddJwtBearerClientAuthentication()
- .AddProfileService();
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesBase.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesBase.cs
deleted file mode 100644
index f6ca437c..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesBase.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System;
-using AutoMapper;
-using Calabonga.Microservice.IdentityModule.Data;
-using Calabonga.Microservice.IdentityModule.Web.Extensions;
-using Calabonga.Microservice.IdentityModule.Web.Infrastructure.Settings;
-using Calabonga.UnitOfWork;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart.ConfigureServices
-{
- ///
- /// ASP.NET Core services registration and configurations
- ///
- public static class ConfigureServicesBase
- {
- ///
- /// ConfigureServices Services
- ///
- ///
- ///
- public static void ConfigureServices(IServiceCollection services, IConfiguration configuration)
- {
- services
- .AddIdentity()
- .AddUserStore()
- .AddEntityFrameworkStores()
- .AddDefaultTokenProviders();
-
- services.AddDbContextPool(config =>
- {
- // UseInMemoryDatabase - This for demo purposes only!
- // Should uninstall package "Microsoft.EntityFrameworkCore.InMemory" and install what you need.
- // For example: "Microsoft.EntityFrameworkCore.SqlServer"
- // uncomment line below to use UseSqlServer(). Don't forget setup connection string in appSettings.json
- config.UseInMemoryDatabase("DEMO_PURPOSES_ONLY");
- // config.UseSqlServer(configuration.GetConnectionString(nameof(ApplicationDbContext)));
- });
-
- services.AddAutoMapper(typeof(Startup));
-
- services.AddUnitOfWork();
-
- services.AddMemoryCache();
-
- services.AddRouting(options => options.LowercaseUrls = true);
-
- services.Configure(options => { options.SuppressModelStateInvalidFilter = true; });
-
- services.Configure(options =>
- {
- // Password settings.
- options.Password.RequireDigit = false;
- options.Password.RequireLowercase = false;
- options.Password.RequireNonAlphanumeric = false;
- options.Password.RequireUppercase = false;
- options.Password.RequiredLength = 6;
- options.Password.RequiredUniqueChars = 0;
-
- // Lockout settings.
- options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
- options.Lockout.MaxFailedAccessAttempts = 10;
- options.Lockout.AllowedForNewUsers = true;
-
- // User settings.
- options.User.AllowedUserNameCharacters = null;
- options.User.RequireUniqueEmail = true;
- });
-
- services.AddOptions();
- services.Configure(configuration.GetSection(nameof(CurrentAppSettings)));
- services.Configure(options => options.UseRouteSlugify());
- services.AddLocalization();
- services.AddHttpContextAccessor();
- services.AddResponseCaching();
- services.AddAuthorization();
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesControllers.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesControllers.cs
deleted file mode 100644
index 8202217c..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesControllers.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart.ConfigureServices
-{
- ///
- /// Configure controllers
- ///
- public static class ConfigureServicesControllers
- {
- ///
- /// Configure services
- ///
- ///
- public static void ConfigureServices(IServiceCollection services)
- {
- services.AddControllers();
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesCors.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesCors.cs
deleted file mode 100644
index 30f79846..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesCors.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System.Linq;
-using Calabonga.Microservices.Web.Core;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart.ConfigureServices
-{
- ///
- /// Cors configurations
- ///
- public class ConfigureServicesCors
- {
- ///
- /// ConfigureServices
- ///
- ///
- ///
- public static void ConfigureServices(IServiceCollection services, IConfiguration configuration)
- {
- var origins = configuration.GetSection("Cors")?.GetSection("Origins")?.Value?.Split(',');
- services.AddCors(options =>
- {
- options.AddPolicy("CorsPolicy", builder =>
- {
- builder.AllowAnyHeader();
- builder.AllowAnyMethod();
- if (origins != null && origins.Length > 0)
- {
- if (origins.Contains("*"))
- {
- builder.AllowAnyHeader();
- builder.AllowAnyMethod();
- builder.SetIsOriginAllowed(host => true);
- builder.AllowCredentials();
- }
- else
- {
- foreach (var origin in origins)
- {
- builder.WithOrigins(origin);
- }
- }
- }
- });
- });
-
- services.UseMicroserviceAuthorizationPolicy();
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesMediator.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesMediator.cs
deleted file mode 100644
index e3e43995..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesMediator.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using AutoMapper;
-using Calabonga.AspNetCore.Controllers.Extensions;
-using Calabonga.Microservice.IdentityModule.Data;
-using Calabonga.Microservice.IdentityModule.Web.Extensions;
-using Calabonga.Microservice.IdentityModule.Web.Infrastructure.Settings;
-using Calabonga.Microservice.IdentityModule.Web.Mediator.Behaviors;
-using Calabonga.UnitOfWork;
-using MediatR;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart.ConfigureServices
-{
- ///
- /// ASP.NET Core services registration and configurations
- ///
- public static class ConfigureServicesMediator
- {
- ///
- /// ConfigureServices Services
- ///
- ///
- public static void ConfigureServices(IServiceCollection services)
- {
- services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidatorBehavior<,>));
- services.AddCommandAndQueries(typeof(Startup).Assembly);
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesSwagger.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesSwagger.cs
deleted file mode 100644
index 12c2b464..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesSwagger.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Calabonga.Microservice.IdentityModule.Web.AppStart.SwaggerFilters;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.OpenApi.Models;
-using Swashbuckle.AspNetCore.SwaggerUI;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart.ConfigureServices
-{
- ///
- /// Swagger configuration
- ///
- public static class ConfigureServicesSwagger
- {
- private const string AppTitle = "Microservice API (with IdentityServer4)";
- private static readonly string AppVersion = $"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}";
- private const string SwaggerConfig = "/swagger/v1/swagger.json";
- private const string SwaggerUrl = "api/manual";
-
- ///
- /// ConfigureServices Swagger services
- ///
- ///
- ///
- public static void ConfigureServices(IServiceCollection services, IConfiguration configuration)
- {
- services.AddSwaggerGen(options =>
- {
- options.SwaggerDoc("v1", new OpenApiInfo
- {
- Title = AppTitle,
- Version = AppVersion,
- Description = "Microservice API (with IdentityServer4) module API documentation. This template based on ASP.NET Core 3.1."
- });
- options.ResolveConflictingActions(x => x.First());
-
- var url = configuration.GetSection("IdentityServer").GetValue("Url");
-
- options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
- {
- Type = SecuritySchemeType.OAuth2,
- Flows = new OpenApiOAuthFlows
- {
- Password = new OpenApiOAuthFlow
- {
- TokenUrl = new Uri($"{url}/auth/connect/token", UriKind.Absolute),
- Scopes = new Dictionary
- {
- { "api1", "Default scope" }
- }
- }
- }
- });
-
- options.AddSecurityRequirement(new OpenApiSecurityRequirement
- {
- {
- new OpenApiSecurityScheme
- {
- Reference = new OpenApiReference
- {
- Type = ReferenceType.SecurityScheme,
- Id = "oauth2"
- },
- Scheme = "oauth2",
- Name = "Bearer",
- In = ParameterLocation.Header,
-
- },
- new List()
- }
- });
-
- options.OperationFilter();
- });
- }
-
- ///
- /// Set up some properties for swagger UI
- ///
- ///
- public static void SwaggerSettings(SwaggerUIOptions settings)
- {
- settings.SwaggerEndpoint(SwaggerConfig, $"{AppTitle} v.{AppVersion}");
- settings.RoutePrefix = SwaggerUrl;
- settings.DocumentTitle = "Microservice API";
- settings.DefaultModelExpandDepth(0);
- settings.DefaultModelRendering(ModelRendering.Model);
- settings.DefaultModelsExpandDepth(0);
- settings.DocExpansion(DocExpansion.None);
- settings.OAuthClientId("microservice1");
- settings.OAuthScopeSeparator(" ");
- settings.OAuthClientSecret("secret");
- settings.DisplayRequestDuration();
- settings.OAuthAppName("Microservice API (with IdentityServer4) module API documentation");
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesValidators.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesValidators.cs
deleted file mode 100644
index 2a873e78..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/ConfigureServices/ConfigureServicesValidators.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using Calabonga.Microservice.IdentityModule.Web.ViewModels.AccountViewModels;
-using FluentValidation;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart.ConfigureServices
-{
- ///
- /// ASP.NET Core services registration and configurations
- ///
- public static class ConfigureServicesValidators
- {
- ///
- /// ConfigureServices Services
- ///
- ///
- public static void ConfigureServices(IServiceCollection services)
- {
- services.AddValidatorsFromAssembly(typeof(Startup).Assembly);
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/Configures/ConfigureCommon.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/Configures/ConfigureCommon.cs
deleted file mode 100644
index 836317fc..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/Configures/ConfigureCommon.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using Calabonga.Microservice.IdentityModule.Core;
-using Calabonga.Microservice.IdentityModule.Web.AppStart.ConfigureServices;
-using Calabonga.Microservice.IdentityModule.Web.Infrastructure.Auth;
-using Calabonga.Microservice.IdentityModule.Web.Middlewares;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Http;
-using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart.Configures
-{
- ///
- /// Pipeline configuration
- ///
- public static class ConfigureCommon
- {
- ///
- /// Configure pipeline
- ///
- ///
- ///
- ///
- public static void Configure(IApplicationBuilder app, IWebHostEnvironment env, AutoMapper.IConfigurationProvider mapper)
- {
- if (env.IsDevelopment())
- {
- mapper.AssertConfigurationIsValid();
- app.UseDeveloperExceptionPage();
- }
- else
- {
- mapper.CompileMappings();
- }
-
- app.UseDefaultFiles();
- app.UseStaticFiles(new StaticFileOptions
- {
- OnPrepareResponse = ctx =>
- {
- ctx.Context.Response.Headers.Append("Cache-Control", "public,max-age=600");
- }
- });
-
- app.UseResponseCaching();
-
- app.UseETagger();
-
- app.Map($"{AppData.AuthUrl}", authServer => { authServer.UseIdentityServer(); });
-
- app.UseMiddleware(typeof(ErrorHandlingMiddleware));
-
- app.UseSwaggerUI(ConfigureServicesSwagger.SwaggerSettings);
-
- app.UseSwagger();
-
- // Singleton setup for User Identity
- UserIdentity.Instance.Configure(app.ApplicationServices.GetService());
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/Configures/ConfigureEndpoints.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/Configures/ConfigureEndpoints.cs
deleted file mode 100644
index 103bc489..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/Configures/ConfigureEndpoints.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using Microsoft.AspNetCore.Builder;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart.Configures
-{
- ///
- /// Configure pipeline
- ///
- public static class ConfigureEndpoints
- {
- ///
- /// Configure Routing
- ///
- ///
- public static void Configure(IApplicationBuilder app)
- {
- app.UseRouting();
- app.UseCors("CorsPolicy");
- app.UseAuthentication();
- app.UseAuthorization();
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllers();
- });
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/IdentityServerConfig.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/IdentityServerConfig.cs
deleted file mode 100644
index 5ab69ba6..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/IdentityServerConfig.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System.Collections.Generic;
-using IdentityServer4;
-using IdentityServer4.Models;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart
-{
- ///
- /// IdentityServer configuration
- ///
- public class IdentityServerConfig
- {
- ///
- /// clients want to access resources (aka scopes)
- ///
- ///
- public static IEnumerable GetClients()
- {
- // client credentials client
- return new List
- {
- // resource owner password grant client
- // you can create your own client
- new Client
- {
- ClientId = "microservice1",
- AllowAccessTokensViaBrowser = true,
- IdentityTokenLifetime = 21600,
- AuthorizationCodeLifetime = 21600,
- AccessTokenLifetime = 21600,
- AllowOfflineAccess = true,
- RefreshTokenUsage = TokenUsage.ReUse,
- RefreshTokenExpiration = TokenExpiration.Sliding,
- SlidingRefreshTokenLifetime = 1296000, //in seconds = 15 days
- AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
- RequireClientSecret = false,
- AllowedScopes = {
- IdentityServerConstants.StandardScopes.OpenId,
- IdentityServerConstants.StandardScopes.Profile,
- IdentityServerConstants.StandardScopes.Email,
- IdentityServerConstants.StandardScopes.Address,
- "api1"
- }
- }
- };
- }
-
- ///
- /// scopes define the resources in your system
- ///
- ///
- public static IEnumerable GetIdentityResources()
- {
- return new List
- {
- new IdentityResources.OpenId(),
- new IdentityResources.Email(),
- new IdentityResources.Profile()
- };
- }
-
- ///
- /// IdentityServer4 API resources
- ///
- ///
- public static IEnumerable GetApiResources()
- {
- return new List
- {
- new ApiResource("api1", "API Default")
- };
- }
-
- public static IEnumerable GetAPiScopes()
- {
- yield return new ApiScope("api1");
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/MapperRegistration.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/MapperRegistration.cs
deleted file mode 100644
index 08a17417..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/MapperRegistration.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using AutoMapper;
-using Calabonga.Microservice.IdentityModule.Web.Infrastructure.Mappers.Base;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart
-{
- ///
- /// AutoMapper profiles registration
- ///
- public static class MapperRegistration
- {
- private static List GetProfiles()
- {
- return (from t in typeof(Startup).GetTypeInfo().Assembly.GetTypes()
- where typeof(IAutoMapper).IsAssignableFrom(t) && !t.GetTypeInfo().IsAbstract
- select t).ToList();
- }
-
- ///
- /// Create and build mapper profiles
- ///
- ///
- public static MapperConfiguration GetMapperConfiguration()
- {
- var profiles = GetProfiles();
- return new MapperConfiguration(cfg =>
- {
- foreach (var item in profiles.Select(profile => (Profile)Activator.CreateInstance(profile)))
- {
- cfg.AddProfile(item);
- }
- });
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/SwaggerFilters/ApplySummariesOperationFilter.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/SwaggerFilters/ApplySummariesOperationFilter.cs
deleted file mode 100644
index b4940b1b..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/AppStart/SwaggerFilters/ApplySummariesOperationFilter.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using Microsoft.AspNetCore.Mvc.Controllers;
-using Microsoft.OpenApi.Models;
-using Swashbuckle.AspNetCore.SwaggerGen;
-
-namespace Calabonga.Microservice.IdentityModule.Web.AppStart.SwaggerFilters
-{
- ///
- /// Swagger Method Info Generator from summary for
- ///
- public class ApplySummariesOperationFilter : IOperationFilter
- {
- ///
- public void Apply(OpenApiOperation operation, OperationFilterContext context)
- {
- var controllerActionDescriptor = context.ApiDescription.ActionDescriptor as ControllerActionDescriptor;
- if (controllerActionDescriptor == null)
- {
- return;
- }
-
- var actionName = controllerActionDescriptor.ActionName;
- if (actionName != "GetPaged") return;
- var resourceName = controllerActionDescriptor.ControllerName;
- operation.Summary = $"Returns paged list of the {resourceName} as IPagedList wrapped with OperationResult";
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Calabonga.Microservice.IdentityModule.Web.csproj b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Calabonga.Microservice.IdentityModule.Web.csproj
deleted file mode 100644
index 2f9541e6..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Calabonga.Microservice.IdentityModule.Web.csproj
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
- netcoreapp3.1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/Account2Controller.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/Account2Controller.cs
deleted file mode 100644
index 242cf985..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/Account2Controller.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using Calabonga.Microservice.IdentityModule.Web.Infrastructure.Services;
-using Calabonga.Microservice.IdentityModule.Web.ViewModels.AccountViewModels;
-using Calabonga.Microservices.Core.Exceptions;
-using Calabonga.OperationResults;
-using Calabonga.UnitOfWork.Controllers.Controllers;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Controllers
-{
- ///
- /// Account Controller
- ///
- [Route("api/[controller]")]
- [Authorize]
- public class Account2Controller : OperationResultController
- {
- private readonly IAccountService _accountService;
-
- ///
- /// Register controller
- ///
- ///
- public Account2Controller(IAccountService accountService)
- {
- _accountService = accountService;
- }
-
- ///
- /// Register new user. Success registration returns UserProfile for new user.
- ///
- ///
- ///
- [HttpPost("[action]")]
- [AllowAnonymous]
- [ProducesResponseType(200, Type = typeof(OperationResult))]
- public async Task>> Register([FromBody]RegisterViewModel model)
- {
- if (!ModelState.IsValid)
- {
- return ValidationProblem(ModelState);
- }
-
- return OperationResultResponse(await _accountService.RegisterAsync(model));
- }
-
- ///
- /// Returns profile information for authenticated user
- ///
- ///
- [HttpGet("[action]")]
- [ProducesResponseType(200, Type = typeof(OperationResult))]
- public async Task>> Profile()
- {
- if (!User.Identity.IsAuthenticated)
- {
- return OperationResultError(null, new MicroserviceUnauthorizedException());
- }
-
- var userId = _accountService.GetCurrentUserId();
- if (Guid.Empty == userId)
- {
- return BadRequest();
- }
-
- var claimsOperationResult = await _accountService.GetProfileAsync(userId.ToString());
- return Ok(claimsOperationResult);
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/AccountController.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/AccountController.cs
deleted file mode 100644
index 6f597614..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/AccountController.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Threading.Tasks;
-using Calabonga.Microservice.IdentityModule.Web.Mediator.Account;
-using Calabonga.Microservice.IdentityModule.Web.ViewModels.AccountViewModels;
-using Calabonga.OperationResults;
-using MediatR;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Controllers
-{
- ///
- /// Account Controller
- ///
- [Route("api/[controller]")]
- [Authorize]
- public class AccountController : ControllerBase
- {
- private readonly IMediator _mediator;
-
- ///
- /// Register controller
- ///
- public AccountController(IMediator mediator)
- {
- _mediator = mediator;
- }
-
- ///
- /// Register new user. Success registration returns UserProfile for new user.
- ///
- ///
- ///
- [HttpPost("[action]")]
- [AllowAnonymous]
- [ProducesResponseType(200, Type = typeof(OperationResult))]
- public async Task>> Register([FromBody]RegisterViewModel model)
- {
- return Ok(await _mediator.Send(new RegisterRequest(model), HttpContext.RequestAborted));
- }
-
- ///
- /// Returns profile information for authenticated user
- ///
- ///
- [HttpGet("[action]")]
- [ProducesResponseType(200, Type = typeof(OperationResult))]
- public async Task>> Profile()
- {
- return await _mediator.Send(new ProfileRequest(), HttpContext.RequestAborted);
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsReadOnlyController.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsReadOnlyController.cs
deleted file mode 100644
index 0c3b2c5e..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsReadOnlyController.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Security.Claims;
-using System.Threading;
-using System.Threading.Tasks;
-using Calabonga.Microservice.IdentityModule.Core;
-using Calabonga.Microservice.IdentityModule.Web.Mediator.LogsReadonly;
-using Calabonga.Microservice.IdentityModule.Web.ViewModels.LogViewModels;
-using Calabonga.Microservices.Core;
-using Calabonga.Microservices.Core.QueryParams;
-using Calabonga.OperationResults;
-using Calabonga.UnitOfWork;
-using MediatR;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Controllers
-{
- ///
- /// ReadOnlyController Demo
- ///
- [Route("api/[controller]")]
- [Authorize]
- public class LogsReadonlyController : ControllerBase
- {
- private readonly IMediator _mediator;
-
- public LogsReadonlyController(IMediator mediator)
- {
- _mediator = mediator;
- }
-
- [HttpGet("[action]")]
- [Authorize(Policy = "Logs:UserRoles:View", Roles = AppData.SystemAdministratorRoleName)]
- public async Task GetRoles()
- {
- //Get Roles for current user
- return Ok(await _mediator.Send(new GetRolesRequest(), HttpContext.RequestAborted));
- }
-
- [HttpGet("[action]/{id:guid}")]
- [ProducesResponseType(200)]
- public async Task GetById(Guid id)
- {
- return Ok(await _mediator.Send(new LogGetByIdRequest(id), HttpContext.RequestAborted));
- }
-
-
- [HttpGet("[action]")]
- [ProducesResponseType(200)]
- public async Task GetPaged([FromQuery] PagedListQueryParams queryParams)
- {
- return Ok(await _mediator.Send(new LogGetPagedRequest(queryParams), HttpContext.RequestAborted));
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsReadonly2Controller.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsReadonly2Controller.cs
deleted file mode 100644
index 6c08164c..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsReadonly2Controller.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System.Security.Claims;
-
-using AutoMapper;
-
-using Calabonga.Microservice.IdentityModule.Core;
-using Calabonga.Microservice.IdentityModule.Data;
-using Calabonga.Microservice.IdentityModule.Entities;
-using Calabonga.Microservice.IdentityModule.Web.Infrastructure.Settings;
-using Calabonga.Microservice.IdentityModule.Web.ViewModels.LogViewModels;
-using Calabonga.Microservices.Core;
-using Calabonga.Microservices.Core.QueryParams;
-using Calabonga.Microservices.Core.Validators;
-using Calabonga.UnitOfWork;
-using Calabonga.UnitOfWork.Controllers.Controllers;
-
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Controllers
-{
- ///
- /// ReadOnlyController Demo
- ///
- [Route("api/[controller]")]
- [Authorize]
- public class LogsReadonly2Controller : ReadOnlyController
- {
- private readonly CurrentAppSettings _appSettings;
-
- ///
- public LogsReadonly2Controller(
- IOptions appSettings,
- IUnitOfWork unitOfWork,
- IMapper mapper)
- : base(unitOfWork, mapper)
- {
- _appSettings = appSettings.Value;
- }
-
- [HttpGet("[action]")]
- [Authorize(Policy = "Logs:UserRoles:View", Roles = AppData.SystemAdministratorRoleName)]
- public IActionResult GetRoles()
- {
- //Get Roles for current user
- var roles = ClaimsHelper.GetValues((ClaimsIdentity)User.Identity, "role");
- return Ok($"Current user ({User.Identity.Name}) have following roles: {string.Join("|", roles)}");
- }
-
- ///
- protected override PermissionValidationResult ValidateQueryParams(PagedListQueryParams queryParams)
- {
- if (queryParams.PageSize <= 0)
- {
- queryParams.PageSize = _appSettings.PageSize;
- }
- return new PermissionValidationResult();
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsWritable2Controller.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsWritable2Controller.cs
deleted file mode 100644
index 1d90515d..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsWritable2Controller.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using AutoMapper;
-using Calabonga.Microservice.IdentityModule.Data;
-using Calabonga.Microservice.IdentityModule.Entities;
-using Calabonga.Microservice.IdentityModule.Web.Infrastructure.Settings;
-using Calabonga.Microservice.IdentityModule.Web.ViewModels.LogViewModels;
-using Calabonga.Microservices.Core.QueryParams;
-using Calabonga.Microservices.Core.Validators;
-using Calabonga.UnitOfWork;
-using Calabonga.UnitOfWork.Controllers.Controllers;
-using Calabonga.UnitOfWork.Controllers.Factories;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Controllers
-{
- ///
- /// WritableController Demo
- ///
- [Route("api/[controller]")]
- [Authorize]
- public class LogsWritable2Controller : WritableController
- {
- private readonly CurrentAppSettings _appSettings;
-
- ///
- public LogsWritable2Controller(
- IOptions appSettings,
- IEntityManagerFactory entityManagerFactory,
- IUnitOfWork unitOfWork,
- IMapper mapper)
- : base(entityManagerFactory, unitOfWork, mapper)
- {
- _appSettings = appSettings.Value;
- }
-
- ///
- protected override PermissionValidationResult ValidateQueryParams(PagedListQueryParams queryParams)
- {
- if (queryParams.PageSize <= 0)
- {
- queryParams.PageSize = _appSettings.PageSize;
- }
- return new PermissionValidationResult();
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsWritableController.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsWritableController.cs
deleted file mode 100644
index fe410619..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Controllers/LogsWritableController.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using Calabonga.Microservice.IdentityModule.Web.Mediator.LogsReadonly;
-using Calabonga.Microservice.IdentityModule.Web.Mediator.LogsWritable;
-using Calabonga.Microservice.IdentityModule.Web.ViewModels.LogViewModels;
-using Calabonga.Microservices.Core.QueryParams;
-using MediatR;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Controllers
-{
- ///
- /// WritableController Demo
- ///
- [Route("api/[controller]")]
- [Authorize]
- public class LogsWritableController : ControllerBase
- {
- private readonly IMediator _mediator;
-
- public LogsWritableController(IMediator mediator)
- {
- _mediator = mediator;
- }
-
-
- [HttpGet("[action]/{id:guid}")]
- [ProducesResponseType(200)]
- public async Task GetById(Guid id)
- {
- return Ok(await _mediator.Send(new LogGetByIdRequest(id), HttpContext.RequestAborted));
- }
-
-
- [HttpGet("[action]")]
- [ProducesResponseType(200)]
- public async Task GetPaged([FromQuery] PagedListQueryParams queryParams)
- {
- return Ok(await _mediator.Send(new LogGetPagedRequest(queryParams), HttpContext.RequestAborted));
- }
-
- [HttpGet("[action]")]
- public async Task GetViewmodelForCreation()
- {
- return Ok(await _mediator.Send(new LogCreateViewModelRequest(), HttpContext.RequestAborted));
- }
-
- [HttpGet("[action]/{id:guid}")]
- public async Task GetViewmodelForEditing(Guid id)
- {
- return Ok(await _mediator.Send(new LogUpdateViewModelRequest(id), HttpContext.RequestAborted));
- }
-
- [HttpPost("[action]")]
- public async Task PostItem([FromBody]LogCreateViewModel model)
- {
- return Ok(await _mediator.Send(new LogPostItemRequest(model), HttpContext.RequestAborted));
- }
-
- [HttpPut("[action]")]
- public async Task PutItem([FromBody]LogUpdateViewModel model)
- {
- return Ok(await _mediator.Send(new LogPutItemRequest(model), HttpContext.RequestAborted));
- }
-
- [HttpDelete("[action]/{id:guid}")]
- public async Task DeleteItem(Guid id)
- {
- return Ok(await _mediator.Send(new LogDeleteItemRequest(id), HttpContext.RequestAborted));
- }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/ApplicationBuilderExtensions.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/ApplicationBuilderExtensions.cs
deleted file mode 100644
index 1d1bb366..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/ApplicationBuilderExtensions.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.Text.RegularExpressions;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.ApplicationModels;
-using Microsoft.AspNetCore.Routing;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Extensions
-{
- ///
- /// Extensions for application class
- ///
- public static class ApplicationBuilderExtensions
- {
- ///
- /// Use special route slugify for Pegasus routing
- ///
- ///
- public static void UseRouteSlugify(this MvcOptions options)
- {
- options.Conventions.Add(new RouteTokenTransformerConvention(new SlugifyParameterTransformer()));
- }
- }
-
- ///
- /// Special route naming convention
- ///
- public class SlugifyParameterTransformer : IOutboundParameterTransformer
- {
- ///
- public string TransformOutbound(object value)
- {
- return value == null
- ? null
- : Regex.Replace(value.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower();
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/AssemblyExtensions.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/AssemblyExtensions.cs
deleted file mode 100644
index 717120b0..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/AssemblyExtensions.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Extensions
-{
- ///
- /// Assembly helpers
- ///
- public static class AssemblyExtensions
- {
- ///
- /// Returns types
- ///
- ///
- ///
- ///
- public static List GetTypesAssignableFrom(this Assembly assembly)
- {
- return assembly.GetTypesAssignableFrom(typeof(T));
- }
-
- private static List GetTypesAssignableFrom(this Assembly assembly, Type compareType)
- {
- var ret = new List();
- foreach (var type in assembly.DefinedTypes)
- {
- if (compareType.IsAssignableFrom(type) && compareType != type && !type.IsAbstract)
- {
- ret.Add(type);
- }
- }
- return ret;
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/DateTimeExtensions.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/DateTimeExtensions.cs
deleted file mode 100644
index 2bde1b47..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/DateTimeExtensions.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Extensions
-{
- ///
- /// DateTime extensions
- ///
- public static class DateTimeExtensions
- {
- ///
- /// Each day enumeration
- ///
- ///
- ///
- ///
- private static IEnumerable EachDay(DateTime from, DateTime thru)
- {
- for (var day = from.Date; day.Date <= thru.Date; day = day.AddDays(1))
- {
- yield return day;
- }
- }
-
- ///
- /// Each month enumeration
- ///
- ///
- ///
- ///
- private static IEnumerable EachMonth(DateTime from, DateTime thru)
- {
- for (var month = from.Date; month.Date <= thru.Date || month.Month == thru.Month; month = month.AddMonths(1))
- {
- yield return month;
- }
- }
-
- ///
- /// Enumerates all days in period
- ///
- ///
- ///
- ///
- public static IEnumerable EachDayTo(this DateTime dateFrom, DateTime dateTo)
- {
- return EachDay(dateFrom, dateTo);
- }
-
- ///
- /// Enumerates all months in period
- ///
- ///
- ///
- ///
- public static IEnumerable EachMonthTo(this DateTime dateFrom, DateTime dateTo)
- {
- return EachMonth(dateFrom, dateTo);
- }
-
-
- ///
- /// Total Month count between two dates
- ///
- ///
- ///
- ///
- public static int TotalMonths(this DateTime start, DateTime end)
- {
- return (start.Year * 12 + start.Month) - (end.Year * 12 + end.Month);
- }
-
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/EntityValidatorExtensions.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/EntityValidatorExtensions.cs
deleted file mode 100644
index c79081ae..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/EntityValidatorExtensions.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Collections.Generic;
-using Calabonga.Microservices.Core.Validators;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Extensions
-{
- ///
- /// Entity Validator Extensions
- ///
- public static class EntityValidatorExtensions
- {
- ///
- /// Returns validator from validation results
- ///
- ///
- ///
- public static ValidationContext GetResult(this List source)
- {
- return new ValidationContext(source);
- }
-
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/IdentityExtensions.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/IdentityExtensions.cs
deleted file mode 100644
index 46843f98..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Extensions/IdentityExtensions.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Security.Principal;
-using Calabonga.Microservices.Core.Extensions;
-using IdentityServer4.Extensions;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Extensions
-{
- ///
- /// Extensions
- ///
- public static class IdentityExtensions
- {
- ///
- /// Returns true/false user is owner
- ///
- ///
- ///
- ///
- public static bool IsOwner(this IIdentity source, Guid userId)
- {
- return source.GetSubjectId().ToGuid() == userId;
- }
- }
-}
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Infrastructure/Attributes/SwaggerFormAttribute.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Infrastructure/Attributes/SwaggerFormAttribute.cs
deleted file mode 100644
index ae907aa9..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Infrastructure/Attributes/SwaggerFormAttribute.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Infrastructure.Attributes
-{
- ///
- /// Custom attribute for Swagger Upload Form
- ///
- [AttributeUsage(AttributeTargets.Method)]
- public sealed class SwaggerFormAttribute : Attribute
- {
- ///
- public SwaggerFormAttribute(string parameterName, string description, bool hasFileUpload = true)
- {
- ParameterName = parameterName;
- Description = description;
- HasFileUpload = hasFileUpload;
- }
-
- ///
- /// UploadFile enabled
- ///
- public bool HasFileUpload { get; }
-
- ///
- /// Name for the parameter
- ///
- public string ParameterName { get; }
-
- ///
- /// Small description
- ///
- public string Description { get;}
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Infrastructure/Attributes/SwaggerGroupAttribute.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Infrastructure/Attributes/SwaggerGroupAttribute.cs
deleted file mode 100644
index 1e336e6d..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Infrastructure/Attributes/SwaggerGroupAttribute.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Infrastructure.Attributes
-{
- ///
- /// Swagger controller group attribute
- ///
- ///
- [AttributeUsage(AttributeTargets.Class)]
- public class SwaggerGroupAttribute : Attribute
- {
- ///
- public SwaggerGroupAttribute(string groupName)
- {
- GroupName = groupName;
- }
-
- ///
- /// Group name
- ///
- public string GroupName { get; }
- }
-}
\ No newline at end of file
diff --git a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Infrastructure/Attributes/ValidateModelStateAttribute.cs b/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Infrastructure/Attributes/ValidateModelStateAttribute.cs
deleted file mode 100644
index dedc5bd8..00000000
--- a/AspNetCore v3.1/Calabonga.Microservice.IdentityModule/Calabonga.Microservice.IdentityModule.Web/Infrastructure/Attributes/ValidateModelStateAttribute.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System.Linq;
-using Calabonga.OperationResults;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.Filters;
-
-namespace Calabonga.Microservice.IdentityModule.Web.Infrastructure.Attributes
-{
- ///
- /// Custom validation handler for availability to whit OperationResult
- ///
- public class ValidateModelStateAttribute : ActionFilterAttribute
- {
- ///
- public override void OnActionExecuting(ActionExecutingContext context)
- {
- if (context.ModelState.IsValid) return;
- var operation = OperationResult.CreateResult