From 2eb299049eb86410e04c5eea3f9e78164732960b Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Tue, 31 Jan 2023 00:17:54 +0000 Subject: [PATCH] Merged PR 70: Tuitio rebranding - Tuitio rebranding - Tuitio rebranding - Tuitio rebranding - Tuitio rebranding - netmash - Tuitio - Tuitio rebranding - Dockerfile update - Tuitio rebranding - removed old scripts - readme update - removed old notes file - packages updates --- .gitignore | 6 +- Directory.Build.props | 6 +- Documentation.md | 18 ---- IdentityServer.Api/Dockerfile | 37 -------- IdentityServer.Api/Program.cs | 93 ------------------- IdentityServer.Api/Startup.cs | 89 ------------------ .../appsettings.Development.json | 9 -- IdentityServer.Api/appsettings.json | 20 ---- .../Commands/AuthenticateUser.cs | 11 --- .../Commands/AuthorizeToken.cs | 10 -- .../IdentityServer.PublishedLanguage.csproj | 13 --- .../IdentityServer.Wrapper.csproj | 21 ----- Notes.txt | 8 +- README.md | 36 ++++++- ReleaseNotes.xml | 19 +++- IdentityServer.sln => Tuitio.sln | 25 ++--- build-amd64.sh | 23 ----- dependencies.props | 23 +++-- release.sh | 23 ----- .../AuthenticateUserHandler.cs | 12 +-- .../CommandHandlers/AuthorizeTokenHandler.cs | 8 +- .../Commands/AuthenticateUser.cs | 11 +++ .../Commands/AuthorizeToken.cs | 10 ++ .../DependencyInjectionExtensions.cs | 10 +- .../Mappings/MappingProfile.cs | 8 +- .../Services/Abstractions/IBehaviorService.cs | 2 +- .../Services/Abstractions/IHashingService.cs | 2 +- .../Services/BehaviorService.cs | 12 +-- .../Services/ConfigProvider.cs | 6 +- .../Services/HashingService.cs | 4 +- .../Services/ITokenService.cs | 6 +- .../Services/IUserService.cs | 4 +- .../Services/TokenService.cs | 8 +- .../Services/UserService.cs | 14 +-- .../Tuitio.Application}/Stores/ITokenStore.cs | 4 +- .../Tuitio.Application}/Stores/TokenStore.cs | 6 +- .../Tuitio.Application.csproj | 9 +- .../DbContexts/IdentityDbContext.cs | 6 +- .../DependencyInjectionExtensions.cs | 8 +- .../AppUserConfiguration.cs | 4 +- .../UserClaimConfiguration.cs | 4 +- .../UserStatusConfiguration.cs | 4 +- .../UserTokenConfiguration.cs | 4 +- .../Repositories/IdentityRepository.cs | 10 +- .../Scripts/1.0.0/01.UserStatus table.sql | 0 .../Scripts/1.0.0/02.AppUser table.sql | 0 .../1.0.0/03.IDX_AppUser_Email_NOTNULL.sql | 0 .../Scripts/1.0.1/01.UserClaim table.sql | 0 .../Scripts/1.0.1/02.UserToken table.sql | 0 .../Tuitio.Domain.Data.csproj | 4 +- .../Abstractions/IConfigProvider.cs | 4 +- .../Tuitio.Domain}/Entities/AppUser.cs | 2 +- .../Tuitio.Domain}/Entities/UserClaim.cs | 2 +- .../Tuitio.Domain}/Entities/UserStatus.cs | 2 +- .../Tuitio.Domain}/Entities/UserToken.cs | 2 +- .../Models/Config/RestrictionsConfig.cs | 2 +- .../Models/Config/TokenConfig.cs | 2 +- .../Tuitio.Domain}/Models/Token.cs | 2 +- .../Tuitio.Domain}/Models/TokenCore.cs | 2 +- .../Repositories/IIdentityRepository.cs | 6 +- .../Tuitio.Domain/Tuitio.Domain.csproj | 2 +- .../Constants/AuthenticationStatus.cs | 2 +- .../Tuitio.PublishedLanguage}/Dto/Token.cs | 2 +- .../Dto/TokenCore.cs | 2 +- .../Events/AuthenticateUserResult.cs | 4 +- .../Tuitio.PublishedLanguage.csproj | 13 +++ .../Tuitio.Wrapper}/Constants/ApiRoutes.cs | 2 +- .../DependencyInjectionExtension.cs | 6 +- .../Models/ServiceConfiguration.cs | 2 +- .../Services/IIdentityService.cs | 4 +- .../Services/IdentityService.cs | 10 +- src/Tuitio.Wrapper/Tuitio.Wrapper.csproj | 24 +++++ .../Tuitio}/Controllers/IdentityController.cs | 4 +- .../Tuitio}/Controllers/SystemController.cs | 2 +- src/Tuitio/Dockerfile | 36 +++++++ src/Tuitio/Extensions/DataTypeExtensions.cs | 8 ++ src/Tuitio/Extensions/LoggingExtensions.cs | 41 ++++++++ src/Tuitio/Extensions/StartupExtensions.cs | 62 +++++++++++++ src/Tuitio/Program.cs | 48 ++++++++++ .../Tuitio}/Properties/launchSettings.json | 2 +- .../Tuitio/Tuitio.csproj | 14 ++- src/Tuitio/appsettings.json | 32 +++++++ 82 files changed, 482 insertions(+), 536 deletions(-) delete mode 100644 Documentation.md delete mode 100644 IdentityServer.Api/Dockerfile delete mode 100644 IdentityServer.Api/Program.cs delete mode 100644 IdentityServer.Api/Startup.cs delete mode 100644 IdentityServer.Api/appsettings.Development.json delete mode 100644 IdentityServer.Api/appsettings.json delete mode 100644 IdentityServer.Application/Commands/AuthenticateUser.cs delete mode 100644 IdentityServer.Application/Commands/AuthorizeToken.cs delete mode 100644 IdentityServer.PublishedLanguage/IdentityServer.PublishedLanguage.csproj delete mode 100644 IdentityServer.Wrapper/IdentityServer.Wrapper.csproj rename IdentityServer.sln => Tuitio.sln (69%) delete mode 100644 build-amd64.sh delete mode 100644 release.sh rename {IdentityServer.Application => src/Tuitio.Application}/CommandHandlers/AuthenticateUserHandler.cs (83%) rename {IdentityServer.Application => src/Tuitio.Application}/CommandHandlers/AuthorizeTokenHandler.cs (86%) create mode 100644 src/Tuitio.Application/Commands/AuthenticateUser.cs create mode 100644 src/Tuitio.Application/Commands/AuthorizeToken.cs rename {IdentityServer.Application => src/Tuitio.Application}/DependencyInjectionExtensions.cs (77%) rename {IdentityServer.Application => src/Tuitio.Application}/Mappings/MappingProfile.cs (81%) rename {IdentityServer.Application => src/Tuitio.Application}/Services/Abstractions/IBehaviorService.cs (57%) rename {IdentityServer.Application => src/Tuitio.Application}/Services/Abstractions/IHashingService.cs (80%) rename {IdentityServer.Application => src/Tuitio.Application}/Services/BehaviorService.cs (85%) rename {IdentityServer.Application => src/Tuitio.Application}/Services/ConfigProvider.cs (78%) rename {IdentityServer.Application => src/Tuitio.Application}/Services/HashingService.cs (95%) rename {IdentityServer.Application => src/Tuitio.Application}/Services/ITokenService.cs (54%) rename {IdentityServer.Application => src/Tuitio.Application}/Services/IUserService.cs (68%) rename {IdentityServer.Application => src/Tuitio.Application}/Services/TokenService.cs (93%) rename {IdentityServer.Application => src/Tuitio.Application}/Services/UserService.cs (86%) rename {IdentityServer.Application => src/Tuitio.Application}/Stores/ITokenStore.cs (65%) rename {IdentityServer.Application => src/Tuitio.Application}/Stores/TokenStore.cs (91%) rename IdentityServer.Application/IdentityServer.Application.csproj => src/Tuitio.Application/Tuitio.Application.csproj (66%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/DbContexts/IdentityDbContext.cs (86%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/DependencyInjectionExtensions.cs (81%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/EntityTypeConfiguration/AppUserConfiguration.cs (84%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/EntityTypeConfiguration/UserClaimConfiguration.cs (79%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/EntityTypeConfiguration/UserStatusConfiguration.cs (79%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/EntityTypeConfiguration/UserTokenConfiguration.cs (79%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/Repositories/IdentityRepository.cs (87%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/Scripts/1.0.0/01.UserStatus table.sql (100%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/Scripts/1.0.0/02.AppUser table.sql (100%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/Scripts/1.0.0/03.IDX_AppUser_Email_NOTNULL.sql (100%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/Scripts/1.0.1/01.UserClaim table.sql (100%) rename {IdentityServer.Domain.Data => src/Tuitio.Domain.Data}/Scripts/1.0.1/02.UserToken table.sql (100%) rename IdentityServer.Domain.Data/IdentityServer.Domain.Data.csproj => src/Tuitio.Domain.Data/Tuitio.Domain.Data.csproj (88%) rename {IdentityServer.Domain => src/Tuitio.Domain}/Abstractions/IConfigProvider.cs (60%) rename {IdentityServer.Domain => src/Tuitio.Domain}/Entities/AppUser.cs (95%) rename {IdentityServer.Domain => src/Tuitio.Domain}/Entities/UserClaim.cs (83%) rename {IdentityServer.Domain => src/Tuitio.Domain}/Entities/UserStatus.cs (80%) rename {IdentityServer.Domain => src/Tuitio.Domain}/Entities/UserToken.cs (88%) rename {IdentityServer.Domain => src/Tuitio.Domain}/Models/Config/RestrictionsConfig.cs (68%) rename {IdentityServer.Domain => src/Tuitio.Domain}/Models/Config/TokenConfig.cs (66%) rename {IdentityServer.Domain => src/Tuitio.Domain}/Models/Token.cs (83%) rename {IdentityServer.Domain => src/Tuitio.Domain}/Models/TokenCore.cs (92%) rename {IdentityServer.Domain => src/Tuitio.Domain}/Repositories/IIdentityRepository.cs (68%) rename IdentityServer.Domain/IdentityServer.Domain.csproj => src/Tuitio.Domain/Tuitio.Domain.csproj (64%) rename {IdentityServer.PublishedLanguage => src/Tuitio.PublishedLanguage}/Constants/AuthenticationStatus.cs (74%) rename {IdentityServer.PublishedLanguage => src/Tuitio.PublishedLanguage}/Dto/Token.cs (80%) rename {IdentityServer.PublishedLanguage => src/Tuitio.PublishedLanguage}/Dto/TokenCore.cs (91%) rename {IdentityServer.PublishedLanguage => src/Tuitio.PublishedLanguage}/Events/AuthenticateUserResult.cs (58%) create mode 100644 src/Tuitio.PublishedLanguage/Tuitio.PublishedLanguage.csproj rename {IdentityServer.Wrapper => src/Tuitio.Wrapper}/Constants/ApiRoutes.cs (82%) rename {IdentityServer.Wrapper => src/Tuitio.Wrapper}/DependencyInjectionExtension.cs (77%) rename {IdentityServer.Wrapper => src/Tuitio.Wrapper}/Models/ServiceConfiguration.cs (83%) rename {IdentityServer.Wrapper => src/Tuitio.Wrapper}/Services/IIdentityService.cs (69%) rename {IdentityServer.Wrapper => src/Tuitio.Wrapper}/Services/IdentityService.cs (85%) create mode 100644 src/Tuitio.Wrapper/Tuitio.Wrapper.csproj rename {IdentityServer.Api => src/Tuitio}/Controllers/IdentityController.cs (92%) rename {IdentityServer.Api => src/Tuitio}/Controllers/SystemController.cs (94%) create mode 100644 src/Tuitio/Dockerfile create mode 100644 src/Tuitio/Extensions/DataTypeExtensions.cs create mode 100644 src/Tuitio/Extensions/LoggingExtensions.cs create mode 100644 src/Tuitio/Extensions/StartupExtensions.cs create mode 100644 src/Tuitio/Program.cs rename {IdentityServer.Api => src/Tuitio}/Properties/launchSettings.json (87%) rename IdentityServer.Api/IdentityServer.Api.csproj => src/Tuitio/Tuitio.csproj (62%) create mode 100644 src/Tuitio/appsettings.json diff --git a/.gitignore b/.gitignore index 4ce6fdd..42155da 100644 --- a/.gitignore +++ b/.gitignore @@ -337,4 +337,8 @@ ASALocalRun/ .localhistory/ # BeatPulse healthcheck temp database -healthchecksdb \ No newline at end of file +healthchecksdb + +*/**/appsettings.Development.json +build.sh +buildx.sh \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index eacdac7..3e9b9c6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,10 +1,10 @@ - 1.1.3 + 2.0.0 Tudor Stanciu STA - IdentityServer - STA Identity server + Tuitio + STA Tuitio \ No newline at end of file diff --git a/Documentation.md b/Documentation.md deleted file mode 100644 index 37a40d7..0000000 --- a/Documentation.md +++ /dev/null @@ -1,18 +0,0 @@ -# Identity Server - -## How To Use 🔧 - -## Roadmap 🚧 - -## IdentityServer.Api - -⚡️ Nu mai returna si status code din metoda de autentificare -⚡️ Store passwords as hash\ -⚡️ Documentatie in fisier .md afisata in frontend - e diferite de release notes\ - - -## IdentityServer.Frontend - -⚡️ Se vor putea adauga/edita/sterge/inactiva useri\ -⚡️ Se vor putea vedea login-urile unui user; se va putea invalida un token activ\ -⚡️ Se va putea decoda un token - public, fara auth\ \ No newline at end of file diff --git a/IdentityServer.Api/Dockerfile b/IdentityServer.Api/Dockerfile deleted file mode 100644 index ce69f26..0000000 --- a/IdentityServer.Api/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base -WORKDIR /app -EXPOSE 80 - -FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build -WORKDIR /src -COPY dependencies.props . -COPY Directory.Build.props . -COPY NuGet.config . -COPY ["IdentityServer.Api/IdentityServer.Api.csproj", "IdentityServer.Api/"] -COPY ["IdentityServer.Application/IdentityServer.Application.csproj", "IdentityServer.Application/"] -COPY ["IdentityServer.Domain/IdentityServer.Domain.csproj", "IdentityServer.Domain/"] -COPY ["IdentityServer.PublishedLanguage/IdentityServer.PublishedLanguage.csproj", "IdentityServer.PublishedLanguage/"] -COPY ["IdentityServer.Domain.Data/IdentityServer.Domain.Data.csproj", "IdentityServer.Domain.Data/"] -RUN dotnet restore "IdentityServer.Api/IdentityServer.Api.csproj" -COPY . . -WORKDIR "/src/IdentityServer.Api" -RUN dotnet build "IdentityServer.Api.csproj" -c Release -o /app/build - -FROM build AS publish -RUN dotnet publish "IdentityServer.Api.csproj" -c Release -o /app/publish - -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . - -ENV urls="http://*:80" -ENV ConnectionStrings__DatabaseConnection="*********************************" -ENV TZ=Europe/Bucharest -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -#Workaround to lower the TLS level in container for old sql server version -RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf - -ENTRYPOINT ["dotnet", "IdentityServer.Api.dll", "--console"] \ No newline at end of file diff --git a/IdentityServer.Api/Program.cs b/IdentityServer.Api/Program.cs deleted file mode 100644 index 4460c50..0000000 --- a/IdentityServer.Api/Program.cs +++ /dev/null @@ -1,93 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; -using Serilog; -using Serilog.Core; -using Serilog.Events; -using Serilog.Sinks.MSSqlServer; -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; - -namespace IdentityServer.Api -{ - public class Program - { - public static void Main(string[] args) - { - var isConsole = args.Contains("--console"); - if (!isConsole) - { - var pathToExe = Process.GetCurrentProcess().MainModule.FileName; - var pathToContentRoot = Path.GetDirectoryName(pathToExe); - Directory.SetCurrentDirectory(pathToContentRoot); - } - - var configuration = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddEnvironmentVariables() - .Build(); - - var connectionString = configuration.GetConnectionString("DatabaseConnection"); - var loggingLevelParam = configuration.GetValue("Logging:LogLevel:Default"); - - var loggingLevelOk = Enum.TryParse(loggingLevelParam, out LogEventLevel loggingLevel); - if (!loggingLevelOk) - throw new Exception($"Logging level '{loggingLevelParam}' is not valid."); - - var loggingLevelSwitch = new LoggingLevelSwitch(loggingLevel); - - var columnOptions = new ColumnOptions(); - columnOptions.Store.Remove(StandardColumn.Properties); - columnOptions.Store.Remove(StandardColumn.MessageTemplate); - columnOptions.Store.Add(StandardColumn.LogEvent); - - var mssqlSinkOptions = new MSSqlServerSinkOptions() { AutoCreateSqlTable = true, TableName = "__Logs" }; - - Log.Logger = new LoggerConfiguration() - .MinimumLevel.ControlledBy(loggingLevelSwitch) - .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) - .Enrich.FromLogContext() - .WriteTo.Console() - .WriteTo.MSSqlServer(connectionString, mssqlSinkOptions, columnOptions: columnOptions) - .CreateLogger(); - - //Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg)); - - try - { - var urls = configuration.GetValue("urls"); - Log.Information("Starting identity server API..."); - Log.Information($"API listening on {urls}"); - Console.WriteLine("Application started. Press Ctrl+C to shut down."); - CreateHostBuilder(args, configuration, !isConsole).Build().Run(); - } - catch (Exception ex) - { - Log.Fatal(ex, "Identity server API host terminated unexpectedly"); - } - finally - { - Log.CloseAndFlush(); - } - } - - public static IHostBuilder CreateHostBuilder(string[] args, IConfiguration configuration, bool useWindowsService) - { - var builder = Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseConfiguration(configuration) - .UseSerilog(); - }); - - if (useWindowsService) - builder.UseWindowsService(); - - return builder; - } - } -} diff --git a/IdentityServer.Api/Startup.cs b/IdentityServer.Api/Startup.cs deleted file mode 100644 index 790c024..0000000 --- a/IdentityServer.Api/Startup.cs +++ /dev/null @@ -1,89 +0,0 @@ -using IdentityServer.Application; -using IdentityServer.Application.Services.Abstractions; -using IdentityServer.Domain.Data; -using MediatR; -using MediatR.Pipeline; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using NDB.Extensions.Swagger; -using NDB.Extensions.Swagger.Constants; -using NDB.Infrastructure.DatabaseMigration; -using NDB.Infrastructure.DatabaseMigration.Constants; -using Newtonsoft.Json; -using System.Reflection; - -namespace IdentityServer.Api -{ - public class Startup - { - private readonly IConfiguration _configuration; - - public Startup(IConfiguration configuration) - { - _configuration = configuration; - } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - services.AddControllers() - .AddNewtonsoftJson(o => o.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc); - - // MediatR - services.AddMediatR(GetMediatRAssemblies()); - services.AddScoped(typeof(IPipelineBehavior<,>), typeof(RequestPreProcessorBehavior<,>)); - services.AddScoped(typeof(IPipelineBehavior<,>), typeof(RequestPostProcessorBehavior<,>)); - - // AutoMapper - services.AddAutoMapper( - typeof(Application.Mappings.MappingProfile).Assembly); - - // Swagger - services.AddSwagger("Identity Server API", AuthorizationType.None); - - // Data access - services.AddMigration(DatabaseType.SQLServer, MetadataLocation.Database); - services.AddDataAccess(); - - // Application - services.AddApplicationServices(); - } - - private Assembly[] GetMediatRAssemblies() - { - var assembly = typeof(Application.Commands.AuthenticateUser).Assembly; - return new Assembly[] { assembly }; - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - // global cors policy - app.UseCors(x => x - .AllowAnyOrigin() - .AllowAnyMethod() - .AllowAnyHeader()); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseRouting(); - app.UseAuthorization(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - app.ConfigureSwagger("IdentityServer API"); - - app.UseMigration(); - - var behaviorService = app.ApplicationServices.GetService(); - behaviorService.FillTokenStore(); - } - } -} diff --git a/IdentityServer.Api/appsettings.Development.json b/IdentityServer.Api/appsettings.Development.json deleted file mode 100644 index 8983e0f..0000000 --- a/IdentityServer.Api/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/IdentityServer.Api/appsettings.json b/IdentityServer.Api/appsettings.json deleted file mode 100644 index f3b6759..0000000 --- a/IdentityServer.Api/appsettings.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "urls": "http://*:5063", - "ConnectionStrings": { - "DatabaseConnection": "Server=######;Database=######;User Id=######;Password=######;MultipleActiveResultSets=true" - }, - "Logging": { - "LogLevel": { - "Default": "Debug", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*", - "Restrictions": { - "MaxFailedLoginAttempts": 5 - }, - "Token": { - "ValidityInMinutes": 43800 - } -} diff --git a/IdentityServer.Application/Commands/AuthenticateUser.cs b/IdentityServer.Application/Commands/AuthenticateUser.cs deleted file mode 100644 index f433c98..0000000 --- a/IdentityServer.Application/Commands/AuthenticateUser.cs +++ /dev/null @@ -1,11 +0,0 @@ -using IdentityServer.PublishedLanguage.Events; -using NDB.Application.DataContracts; - -namespace IdentityServer.Application.Commands -{ - public class AuthenticateUser : Command - { - public string UserName { get; set; } - public string Password { get; set; } - } -} diff --git a/IdentityServer.Application/Commands/AuthorizeToken.cs b/IdentityServer.Application/Commands/AuthorizeToken.cs deleted file mode 100644 index 03dae3e..0000000 --- a/IdentityServer.Application/Commands/AuthorizeToken.cs +++ /dev/null @@ -1,10 +0,0 @@ -using IdentityServer.PublishedLanguage.Dto; -using NDB.Application.DataContracts; - -namespace IdentityServer.Application.Commands -{ - public class AuthorizeToken : Command - { - public string Token { get; set; } - } -} diff --git a/IdentityServer.PublishedLanguage/IdentityServer.PublishedLanguage.csproj b/IdentityServer.PublishedLanguage/IdentityServer.PublishedLanguage.csproj deleted file mode 100644 index 9dadd87..0000000 --- a/IdentityServer.PublishedLanguage/IdentityServer.PublishedLanguage.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - netstandard2.0 - Identity server published language package - https://dev.azure.com/tstanciu94/IdentityServer - https://dev.azure.com/tstanciu94/_git/IdentityServer - Git - Identity server published language package - 1.1.0 - - - diff --git a/IdentityServer.Wrapper/IdentityServer.Wrapper.csproj b/IdentityServer.Wrapper/IdentityServer.Wrapper.csproj deleted file mode 100644 index ab7c6f1..0000000 --- a/IdentityServer.Wrapper/IdentityServer.Wrapper.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - netstandard2.0 - Identity server wrapper - Identity server wrapper - https://dev.azure.com/tstanciu94/IdentityServer - Git - https://dev.azure.com/tstanciu94/_git/IdentityServer - IdentityServer wrapper - 1.1.0 - - - - - - - - - - diff --git a/Notes.txt b/Notes.txt index 9d1562e..0fe4dc4 100644 --- a/Notes.txt +++ b/Notes.txt @@ -3,14 +3,14 @@ Publish: dotnet publish --configuration Release --runtime win7-x64 Create windows service: -sc create IdentityServer.Api binPath= "" +sc create Tuitio.Api binPath= "" ####################################################################################################################################################### ####################################################################################################################################################### Push language package: -dotnet nuget push IdentityServer.PublishedLanguage.1.1.0.nupkg -k ******** -s http://********/NuGetServer/nuget -dotnet nuget push IdentityServer.Wrapper.1.1.0.nupkg -k ******** -s http://********/NuGetServer/nuget +dotnet nuget push Tuitio.PublishedLanguage.1.1.0.nupkg -k ******** -s http://********/NuGetServer/nuget +dotnet nuget push Tuitio.Wrapper.1.1.0.nupkg -k ******** -s http://********/NuGetServer/nuget ####################################################################################################################################################### TO DO: @@ -22,7 +22,7 @@ Docker commands: Create image: --from solution folder: -docker image build -t "identity-server-api:1.0.1" -f "IdentityServer.Api/Dockerfile" . +docker image build -t "identity-server-api:1.0.1" -f "Tuitio.Api/Dockerfile" . Run image: docker run -p 5053:80 -it identity-server-api:1.0.1 diff --git a/README.md b/README.md index b591d7d..f99ae34 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,35 @@ -# Identity Server +# Tuitio -This project represents a simple identity server implementation focused strictly on the needs of my home lab. +Tuitio is a simple identity server implementation focused strictly on the needs of my home lab. At the moment it has a simple API consisting of only two methods: -* ```/identity/authenticate``` - takes care of authenticating a user based on credentials and generates an access token. -* ```/identity/authorize``` - deals with the authorization of a token (verifies its existence, validity, authenticity, etc) +* ```/identity/authenticate``` - handles user authentication using credentials and generates an access token. +* ```/identity/authorize``` - manages the authorization process for a token, including verification of its existence, validity, and authenticity. + +***Tuitio*** is a latin word that encompasses meanings such as supervision, safeguarding, defense, guard duty, and protection. + +## Database +Currently, the database server supported by the system is only Microsoft SQL Server. In the following versions, the system will also be compatible with PostgreSQL and SQLite. + +## Logging +The logging functionality is managed with Serilog, and its configuration is done in the ```appsettings.json``` file. In addition to its standard configuration, Tuitio also has a preconfigured area where two destinations for logs are available: SqlServer database and Seq. Each of the destinations can be activated or not. If logging in the console is sufficient, all additional logging destinations can be disabled. +This configuration area is: + +``` +"Logs": { + "SqlServer": { + "Enabled": false, + "Connection": "Server=;Database=;User Id=;Password=;" + }, + "Seq": { + "Enabled": false, + "Url": "", + "ApiKey": "" + } +} +``` + +## Hosting +The only hosting environment tested for this service is Docker, but considering that .NET 6 is cross platform, it can most likely be hosted in any environment. ## Stack * .NET (C#) @@ -11,4 +37,4 @@ At the moment it has a simple API consisting of only two methods: * SQL Server * Swagger * Docker -* Shell +* Seq \ No newline at end of file diff --git a/ReleaseNotes.xml b/ReleaseNotes.xml index 935ffd5..48b7fb7 100644 --- a/ReleaseNotes.xml +++ b/ReleaseNotes.xml @@ -9,8 +9,8 @@ - Authentication: An user name and a password are required in the request body. The request type is POST. The output is an object with the following structure: { token: { raw: "***", validFrom: "", validUntil: "" }, status: "SUCCESS" } - Authorization: The request type is also POST and and its scope is to authorize a token. The input is just the token in string format: { token: "***" } For .NET consumers there are two nuget packages developed to facilitate the integration with this identity server: - - IdentityServer.PublishedLanguage: It contains constants and classes for data transfer objects. - - IdentityServer.Wrapper: It compose and executes all the REST requests to the identity server and offers to a consumer a simple interface with all methods. This interface can be injected with dependency injection at consumer startup with UseIdentityServices method. The only input is the server base address. + - Tuitio.PublishedLanguage: It contains constants and classes for data transfer objects. + - Tuitio.Wrapper: It compose and executes all the REST requests to the identity server and offers to a consumer a simple interface with all methods. This interface can be injected with dependency injection at consumer startup with UseIdentityServices method. The only input is the server base address. - The source of this nugets is public, but on my personal server: https://lab.code-rove.com/public-nuget-server/nuget @@ -27,13 +27,13 @@ 1.1.0 ◾ Upgrade all projects to .NET 5 - ◾ Upgrade packages MicrosoftExtensions, AutoMapper, EntityFramework, NDB + ◾ Upgrade packages MicrosoftExtensions, AutoMapper, EntityFramework, Netmash 1.1.1 - ◾ Added NDB.Infrastructure.DatabaseMigration + ◾ Added Netmash.Infrastructure.DatabaseMigration ◾ Organized sql scripts to meet database migrator requirements @@ -49,4 +49,15 @@ ◾ Upgrade the migration service to version 1.1.0. Migration metadata is now stored in the sql server database. + + 2.0.0 + + ◾ Tuitio rebranding + ◾ .NET 6 upgrade + ◾ Nuget packages upgrade + ◾ Added Seq logging + ◾ Refactoring and code cleanup + ◾ Added README.md file + + \ No newline at end of file diff --git a/IdentityServer.sln b/Tuitio.sln similarity index 69% rename from IdentityServer.sln rename to Tuitio.sln index 78baac9..004792e 100644 --- a/IdentityServer.sln +++ b/Tuitio.sln @@ -5,37 +5,29 @@ VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5A8FF505-3E4D-4258-BC3E-CACD74A7B98C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Api", "IdentityServer.Api\IdentityServer.Api.csproj", "{2F84E560-EEC0-4511-B8D9-2C35C226B688}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tuitio", "src\Tuitio\Tuitio.csproj", "{2F84E560-EEC0-4511-B8D9-2C35C226B688}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0B8B6E9B-0200-47EC-91D9-BEDF4BFC248F}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution items", "{0B8B6E9B-0200-47EC-91D9-BEDF4BFC248F}" ProjectSection(SolutionItems) = preProject .dockerignore = .dockerignore .gitattributes = .gitattributes .gitignore = .gitignore dependencies.props = dependencies.props Directory.Build.props = Directory.Build.props - Documentation.md = Documentation.md - Notes.txt = Notes.txt NuGet.config = NuGet.config - ReleaseNotes.xml = ReleaseNotes.xml README.md = README.md + ReleaseNotes.xml = ReleaseNotes.xml EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Application", "IdentityServer.Application\IdentityServer.Application.csproj", "{6556D255-AF22-478E-A71A-BE37C16D5EE4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tuitio.Application", "src\Tuitio.Application\Tuitio.Application.csproj", "{6556D255-AF22-478E-A71A-BE37C16D5EE4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Domain", "IdentityServer.Domain\IdentityServer.Domain.csproj", "{5890B079-3CB0-4AD6-8809-BB2E081590B1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tuitio.Domain", "src\Tuitio.Domain\Tuitio.Domain.csproj", "{5890B079-3CB0-4AD6-8809-BB2E081590B1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Domain.Data", "IdentityServer.Domain.Data\IdentityServer.Domain.Data.csproj", "{CE81A435-49AC-4544-A381-FAC91BEB3C49}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tuitio.Domain.Data", "src\Tuitio.Domain.Data\Tuitio.Domain.Data.csproj", "{CE81A435-49AC-4544-A381-FAC91BEB3C49}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.PublishedLanguage", "IdentityServer.PublishedLanguage\IdentityServer.PublishedLanguage.csproj", "{67B4D1FF-D02E-4DA6-9FB8-F71667360448}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tuitio.PublishedLanguage", "src\Tuitio.PublishedLanguage\Tuitio.PublishedLanguage.csproj", "{67B4D1FF-D02E-4DA6-9FB8-F71667360448}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Wrapper", "IdentityServer.Wrapper\IdentityServer.Wrapper.csproj", "{F6FEC33B-C79E-4484-B356-9C7F1A5E5D95}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{5A9268B6-F73B-4773-86BF-45DFF7EF75F7}" - ProjectSection(SolutionItems) = preProject - build-amd64.sh = build-amd64.sh - release.sh = release.sh - EndProjectSection +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tuitio.Wrapper", "src\Tuitio.Wrapper\Tuitio.Wrapper.csproj", "{F6FEC33B-C79E-4484-B356-9C7F1A5E5D95}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -78,7 +70,6 @@ Global {CE81A435-49AC-4544-A381-FAC91BEB3C49} = {5A8FF505-3E4D-4258-BC3E-CACD74A7B98C} {67B4D1FF-D02E-4DA6-9FB8-F71667360448} = {5A8FF505-3E4D-4258-BC3E-CACD74A7B98C} {F6FEC33B-C79E-4484-B356-9C7F1A5E5D95} = {5A8FF505-3E4D-4258-BC3E-CACD74A7B98C} - {5A9268B6-F73B-4773-86BF-45DFF7EF75F7} = {0B8B6E9B-0200-47EC-91D9-BEDF4BFC248F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E93DC46D-9C55-4A05-B299-497CDD90747E} diff --git a/build-amd64.sh b/build-amd64.sh deleted file mode 100644 index 7af68e6..0000000 --- a/build-amd64.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# chmod u+x build-amd64.sh -echo "Welcome!" - -version="1.1.3-alpha3" -localRegistryPass="************" - -echo "Create docker image with version $version." -docker image build -t "identity-server:$version" -f "IdentityServer.Api/Dockerfile" . - -echo "Tag docker image with registry prefix." -docker tag identity-server:$version alpine-nexus:8500/identity/identity-server:$version - -echo "Login to alpine-nexus registry." -docker login --username=admin --password=$localRegistryPass alpine-nexus:8500 - -echo "Push image alpine-nexus:8500/identity/identity-server:$version to registry." -docker push alpine-nexus:8500/identity/identity-server:$version - -echo "Remove image alpine-nexus:8500/identity/identity-server:$version from local machine." -docker rmi alpine-nexus:8500/identity/identity-server:$version - -echo "DONE!" \ No newline at end of file diff --git a/dependencies.props b/dependencies.props index 1b56d05..4cafce3 100644 --- a/dependencies.props +++ b/dependencies.props @@ -1,17 +1,16 @@ - 5.0.0 - 4.1.0 - 3.1.0 - 4.0.0 + 6.0.0 + 6.1.0 + 5.2.2 5.6.1 - 10.1.1 - 8.1.1 - 6.0.0 - 5.3.1 - 5.0.12 - 1.0.2 - 1.0.0 - 1.1.3 + 12.0.1 + 12.0.0 + 9.0.0 + 6.0.1 + 13.0.1 + 1.0.6 + 1.2.0 + 1.0.0 \ No newline at end of file diff --git a/release.sh b/release.sh deleted file mode 100644 index 6ebd4a4..0000000 --- a/release.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -echo "Welcome!" - -version="1.1.3" -oldver="1.1.2" - -echo "Pull docker image identity-server:$version from registry." -docker pull alpine-nexus:8500/identity/identity-server:$version - -echo "Stop old container." -docker stop identity-server && docker rm identity-server - -echo "Run new container." -docker run -d --name identity-server --restart=always --memory 500mb --memory-reservation 100mb -p 5007:80 alpine-nexus:8500/identity/identity-server:$version -# https://phoenixnap.com/kb/docker-memory-and-cpu-limit - -echo "Remove old image identity-server:$oldver." -docker rmi alpine-nexus:8500/identity/identity-server:$oldver - -echo "Get container logs:" -docker logs identity-server - -echo "DONE!" \ No newline at end of file diff --git a/IdentityServer.Application/CommandHandlers/AuthenticateUserHandler.cs b/src/Tuitio.Application/CommandHandlers/AuthenticateUserHandler.cs similarity index 83% rename from IdentityServer.Application/CommandHandlers/AuthenticateUserHandler.cs rename to src/Tuitio.Application/CommandHandlers/AuthenticateUserHandler.cs index 4419192..c0de240 100644 --- a/IdentityServer.Application/CommandHandlers/AuthenticateUserHandler.cs +++ b/src/Tuitio.Application/CommandHandlers/AuthenticateUserHandler.cs @@ -1,15 +1,15 @@ using AutoMapper; -using IdentityServer.Application.Commands; -using IdentityServer.Application.Services; -using IdentityServer.PublishedLanguage.Constants; -using IdentityServer.PublishedLanguage.Dto; -using IdentityServer.PublishedLanguage.Events; +using Tuitio.Application.Commands; +using Tuitio.Application.Services; +using Tuitio.PublishedLanguage.Constants; +using Tuitio.PublishedLanguage.Dto; +using Tuitio.PublishedLanguage.Events; using MediatR; using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -namespace IdentityServer.Application.CommandHandlers +namespace Tuitio.Application.CommandHandlers { public class AuthenticateUserHandler : IRequestHandler { diff --git a/IdentityServer.Application/CommandHandlers/AuthorizeTokenHandler.cs b/src/Tuitio.Application/CommandHandlers/AuthorizeTokenHandler.cs similarity index 86% rename from IdentityServer.Application/CommandHandlers/AuthorizeTokenHandler.cs rename to src/Tuitio.Application/CommandHandlers/AuthorizeTokenHandler.cs index 93d784a..b448d3f 100644 --- a/IdentityServer.Application/CommandHandlers/AuthorizeTokenHandler.cs +++ b/src/Tuitio.Application/CommandHandlers/AuthorizeTokenHandler.cs @@ -1,13 +1,13 @@ using AutoMapper; -using IdentityServer.Application.Commands; -using IdentityServer.Application.Services; -using IdentityServer.PublishedLanguage.Dto; +using Tuitio.Application.Commands; +using Tuitio.Application.Services; +using Tuitio.PublishedLanguage.Dto; using MediatR; using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -namespace IdentityServer.Application.CommandHandlers +namespace Tuitio.Application.CommandHandlers { public class AuthorizeTokenHandler : IRequestHandler { diff --git a/src/Tuitio.Application/Commands/AuthenticateUser.cs b/src/Tuitio.Application/Commands/AuthenticateUser.cs new file mode 100644 index 0000000..a5c466f --- /dev/null +++ b/src/Tuitio.Application/Commands/AuthenticateUser.cs @@ -0,0 +1,11 @@ +using MediatR; +using Tuitio.PublishedLanguage.Events; + +namespace Tuitio.Application.Commands +{ + public class AuthenticateUser : IRequest + { + public string UserName { get; set; } + public string Password { get; set; } + } +} diff --git a/src/Tuitio.Application/Commands/AuthorizeToken.cs b/src/Tuitio.Application/Commands/AuthorizeToken.cs new file mode 100644 index 0000000..31854f6 --- /dev/null +++ b/src/Tuitio.Application/Commands/AuthorizeToken.cs @@ -0,0 +1,10 @@ +using MediatR; +using Tuitio.PublishedLanguage.Dto; + +namespace Tuitio.Application.Commands +{ + public class AuthorizeToken : IRequest + { + public string Token { get; set; } + } +} diff --git a/IdentityServer.Application/DependencyInjectionExtensions.cs b/src/Tuitio.Application/DependencyInjectionExtensions.cs similarity index 77% rename from IdentityServer.Application/DependencyInjectionExtensions.cs rename to src/Tuitio.Application/DependencyInjectionExtensions.cs index 02e5320..ee1b2ac 100644 --- a/IdentityServer.Application/DependencyInjectionExtensions.cs +++ b/src/Tuitio.Application/DependencyInjectionExtensions.cs @@ -1,10 +1,10 @@ -using IdentityServer.Application.Services; -using IdentityServer.Application.Services.Abstractions; -using IdentityServer.Application.Stores; -using IdentityServer.Domain.Abstractions; +using Tuitio.Application.Services; +using Tuitio.Application.Services.Abstractions; +using Tuitio.Application.Stores; +using Tuitio.Domain.Abstractions; using Microsoft.Extensions.DependencyInjection; -namespace IdentityServer.Application +namespace Tuitio.Application { public static class DependencyInjectionExtensions { diff --git a/IdentityServer.Application/Mappings/MappingProfile.cs b/src/Tuitio.Application/Mappings/MappingProfile.cs similarity index 81% rename from IdentityServer.Application/Mappings/MappingProfile.cs rename to src/Tuitio.Application/Mappings/MappingProfile.cs index f09334c..10804f2 100644 --- a/IdentityServer.Application/Mappings/MappingProfile.cs +++ b/src/Tuitio.Application/Mappings/MappingProfile.cs @@ -1,10 +1,10 @@ using AutoMapper; -using IdentityServer.Domain.Entities; +using Tuitio.Domain.Entities; using System.Collections.Generic; -using dto = IdentityServer.PublishedLanguage.Dto; -using models = IdentityServer.Domain.Models; +using dto = Tuitio.PublishedLanguage.Dto; +using models = Tuitio.Domain.Models; -namespace IdentityServer.Application.Mappings +namespace Tuitio.Application.Mappings { public class MappingProfile : Profile { diff --git a/IdentityServer.Application/Services/Abstractions/IBehaviorService.cs b/src/Tuitio.Application/Services/Abstractions/IBehaviorService.cs similarity index 57% rename from IdentityServer.Application/Services/Abstractions/IBehaviorService.cs rename to src/Tuitio.Application/Services/Abstractions/IBehaviorService.cs index 7a7c7b9..c79ffa6 100644 --- a/IdentityServer.Application/Services/Abstractions/IBehaviorService.cs +++ b/src/Tuitio.Application/Services/Abstractions/IBehaviorService.cs @@ -1,4 +1,4 @@ -namespace IdentityServer.Application.Services.Abstractions +namespace Tuitio.Application.Services.Abstractions { public interface IBehaviorService { diff --git a/IdentityServer.Application/Services/Abstractions/IHashingService.cs b/src/Tuitio.Application/Services/Abstractions/IHashingService.cs similarity index 80% rename from IdentityServer.Application/Services/Abstractions/IHashingService.cs rename to src/Tuitio.Application/Services/Abstractions/IHashingService.cs index 627de1e..84e7c23 100644 --- a/IdentityServer.Application/Services/Abstractions/IHashingService.cs +++ b/src/Tuitio.Application/Services/Abstractions/IHashingService.cs @@ -1,4 +1,4 @@ -namespace IdentityServer.Application.Services.Abstractions +namespace Tuitio.Application.Services.Abstractions { internal interface IHashingService { diff --git a/IdentityServer.Application/Services/BehaviorService.cs b/src/Tuitio.Application/Services/BehaviorService.cs similarity index 85% rename from IdentityServer.Application/Services/BehaviorService.cs rename to src/Tuitio.Application/Services/BehaviorService.cs index bbd33c9..210d9a7 100644 --- a/IdentityServer.Application/Services/BehaviorService.cs +++ b/src/Tuitio.Application/Services/BehaviorService.cs @@ -1,14 +1,14 @@ -using IdentityServer.Application.Services.Abstractions; -using IdentityServer.Application.Stores; -using IdentityServer.Domain.Entities; -using IdentityServer.Domain.Models; -using IdentityServer.Domain.Repositories; +using Tuitio.Application.Services.Abstractions; +using Tuitio.Application.Stores; +using Tuitio.Domain.Entities; +using Tuitio.Domain.Models; +using Tuitio.Domain.Repositories; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using System; using System.Threading.Tasks; -namespace IdentityServer.Application.Services +namespace Tuitio.Application.Services { internal class BehaviorService : IBehaviorService { diff --git a/IdentityServer.Application/Services/ConfigProvider.cs b/src/Tuitio.Application/Services/ConfigProvider.cs similarity index 78% rename from IdentityServer.Application/Services/ConfigProvider.cs rename to src/Tuitio.Application/Services/ConfigProvider.cs index 755a02b..6c1a0eb 100644 --- a/IdentityServer.Application/Services/ConfigProvider.cs +++ b/src/Tuitio.Application/Services/ConfigProvider.cs @@ -1,8 +1,8 @@ -using IdentityServer.Domain.Abstractions; -using IdentityServer.Domain.Models.Config; +using Tuitio.Domain.Abstractions; +using Tuitio.Domain.Models.Config; using Microsoft.Extensions.Configuration; -namespace IdentityServer.Application.Services +namespace Tuitio.Application.Services { internal class ConfigProvider : IConfigProvider { diff --git a/IdentityServer.Application/Services/HashingService.cs b/src/Tuitio.Application/Services/HashingService.cs similarity index 95% rename from IdentityServer.Application/Services/HashingService.cs rename to src/Tuitio.Application/Services/HashingService.cs index a0f7b53..0145dcb 100644 --- a/IdentityServer.Application/Services/HashingService.cs +++ b/src/Tuitio.Application/Services/HashingService.cs @@ -1,9 +1,9 @@ -using IdentityServer.Application.Services.Abstractions; +using Tuitio.Application.Services.Abstractions; using System; using System.Security.Authentication; using System.Security.Cryptography; -namespace IdentityServer.Application.Services +namespace Tuitio.Application.Services { internal class HashingService : IHashingService { diff --git a/IdentityServer.Application/Services/ITokenService.cs b/src/Tuitio.Application/Services/ITokenService.cs similarity index 54% rename from IdentityServer.Application/Services/ITokenService.cs rename to src/Tuitio.Application/Services/ITokenService.cs index 7ec21e9..03f3566 100644 --- a/IdentityServer.Application/Services/ITokenService.cs +++ b/src/Tuitio.Application/Services/ITokenService.cs @@ -1,7 +1,7 @@ -using IdentityServer.Domain.Entities; -using IdentityServer.Domain.Models; +using Tuitio.Domain.Entities; +using Tuitio.Domain.Models; -namespace IdentityServer.Application.Services +namespace Tuitio.Application.Services { internal interface ITokenService { diff --git a/IdentityServer.Application/Services/IUserService.cs b/src/Tuitio.Application/Services/IUserService.cs similarity index 68% rename from IdentityServer.Application/Services/IUserService.cs rename to src/Tuitio.Application/Services/IUserService.cs index 70145a2..8248a58 100644 --- a/IdentityServer.Application/Services/IUserService.cs +++ b/src/Tuitio.Application/Services/IUserService.cs @@ -1,7 +1,7 @@ -using IdentityServer.Domain.Models; +using Tuitio.Domain.Models; using System.Threading.Tasks; -namespace IdentityServer.Application.Services +namespace Tuitio.Application.Services { public interface IUserService { diff --git a/IdentityServer.Application/Services/TokenService.cs b/src/Tuitio.Application/Services/TokenService.cs similarity index 93% rename from IdentityServer.Application/Services/TokenService.cs rename to src/Tuitio.Application/Services/TokenService.cs index f3a32b0..98605dc 100644 --- a/IdentityServer.Application/Services/TokenService.cs +++ b/src/Tuitio.Application/Services/TokenService.cs @@ -1,13 +1,13 @@ using AutoMapper; -using IdentityServer.Domain.Abstractions; -using IdentityServer.Domain.Entities; -using IdentityServer.Domain.Models; +using Tuitio.Domain.Abstractions; +using Tuitio.Domain.Entities; +using Tuitio.Domain.Models; using Newtonsoft.Json; using System; using System.Text; using System.Text.RegularExpressions; -namespace IdentityServer.Application.Services +namespace Tuitio.Application.Services { internal class TokenService : ITokenService { diff --git a/IdentityServer.Application/Services/UserService.cs b/src/Tuitio.Application/Services/UserService.cs similarity index 86% rename from IdentityServer.Application/Services/UserService.cs rename to src/Tuitio.Application/Services/UserService.cs index 956d05b..57e2abc 100644 --- a/IdentityServer.Application/Services/UserService.cs +++ b/src/Tuitio.Application/Services/UserService.cs @@ -1,13 +1,13 @@ -using IdentityServer.Application.Services.Abstractions; -using IdentityServer.Application.Stores; -using IdentityServer.Domain.Abstractions; -using IdentityServer.Domain.Entities; -using IdentityServer.Domain.Models; -using IdentityServer.Domain.Repositories; +using Tuitio.Application.Services.Abstractions; +using Tuitio.Application.Stores; +using Tuitio.Domain.Abstractions; +using Tuitio.Domain.Entities; +using Tuitio.Domain.Models; +using Tuitio.Domain.Repositories; using System; using System.Threading.Tasks; -namespace IdentityServer.Application.Services +namespace Tuitio.Application.Services { internal class UserService : IUserService { diff --git a/IdentityServer.Application/Stores/ITokenStore.cs b/src/Tuitio.Application/Stores/ITokenStore.cs similarity index 65% rename from IdentityServer.Application/Stores/ITokenStore.cs rename to src/Tuitio.Application/Stores/ITokenStore.cs index c61ef10..7ee7aef 100644 --- a/IdentityServer.Application/Stores/ITokenStore.cs +++ b/src/Tuitio.Application/Stores/ITokenStore.cs @@ -1,6 +1,6 @@ -using IdentityServer.Domain.Models; +using Tuitio.Domain.Models; -namespace IdentityServer.Application.Stores +namespace Tuitio.Application.Stores { internal interface ITokenStore { diff --git a/IdentityServer.Application/Stores/TokenStore.cs b/src/Tuitio.Application/Stores/TokenStore.cs similarity index 91% rename from IdentityServer.Application/Stores/TokenStore.cs rename to src/Tuitio.Application/Stores/TokenStore.cs index f7bc716..e374950 100644 --- a/IdentityServer.Application/Stores/TokenStore.cs +++ b/src/Tuitio.Application/Stores/TokenStore.cs @@ -1,10 +1,10 @@ -using IdentityServer.Application.Services; -using IdentityServer.Domain.Models; +using Tuitio.Application.Services; +using Tuitio.Domain.Models; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -namespace IdentityServer.Application.Stores +namespace Tuitio.Application.Stores { internal class TokenStore : ITokenStore { diff --git a/IdentityServer.Application/IdentityServer.Application.csproj b/src/Tuitio.Application/Tuitio.Application.csproj similarity index 66% rename from IdentityServer.Application/IdentityServer.Application.csproj rename to src/Tuitio.Application/Tuitio.Application.csproj index 77faec9..924dd6c 100644 --- a/IdentityServer.Application/IdentityServer.Application.csproj +++ b/src/Tuitio.Application/Tuitio.Application.csproj @@ -1,7 +1,7 @@ - net5.0 + net6.0 @@ -11,13 +11,12 @@ - - + - - + + diff --git a/IdentityServer.Domain.Data/DbContexts/IdentityDbContext.cs b/src/Tuitio.Domain.Data/DbContexts/IdentityDbContext.cs similarity index 86% rename from IdentityServer.Domain.Data/DbContexts/IdentityDbContext.cs rename to src/Tuitio.Domain.Data/DbContexts/IdentityDbContext.cs index 9b50c20..dc35ca1 100644 --- a/IdentityServer.Domain.Data/DbContexts/IdentityDbContext.cs +++ b/src/Tuitio.Domain.Data/DbContexts/IdentityDbContext.cs @@ -1,8 +1,8 @@ -using IdentityServer.Domain.Data.EntityTypeConfiguration; -using IdentityServer.Domain.Entities; +using Tuitio.Domain.Data.EntityTypeConfiguration; +using Tuitio.Domain.Entities; using Microsoft.EntityFrameworkCore; -namespace IdentityServer.Domain.Data.DbContexts +namespace Tuitio.Domain.Data.DbContexts { public class IdentityDbContext : DbContext { diff --git a/IdentityServer.Domain.Data/DependencyInjectionExtensions.cs b/src/Tuitio.Domain.Data/DependencyInjectionExtensions.cs similarity index 81% rename from IdentityServer.Domain.Data/DependencyInjectionExtensions.cs rename to src/Tuitio.Domain.Data/DependencyInjectionExtensions.cs index 959cdc6..92add97 100644 --- a/IdentityServer.Domain.Data/DependencyInjectionExtensions.cs +++ b/src/Tuitio.Domain.Data/DependencyInjectionExtensions.cs @@ -1,11 +1,11 @@ -using IdentityServer.Domain.Data.DbContexts; -using IdentityServer.Domain.Data.Repositories; -using IdentityServer.Domain.Repositories; +using Tuitio.Domain.Data.DbContexts; +using Tuitio.Domain.Data.Repositories; +using Tuitio.Domain.Repositories; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.EntityFrameworkCore; -namespace IdentityServer.Domain.Data +namespace Tuitio.Domain.Data { public static class DependencyInjectionExtensions { diff --git a/IdentityServer.Domain.Data/EntityTypeConfiguration/AppUserConfiguration.cs b/src/Tuitio.Domain.Data/EntityTypeConfiguration/AppUserConfiguration.cs similarity index 84% rename from IdentityServer.Domain.Data/EntityTypeConfiguration/AppUserConfiguration.cs rename to src/Tuitio.Domain.Data/EntityTypeConfiguration/AppUserConfiguration.cs index f769238..acdb6bb 100644 --- a/IdentityServer.Domain.Data/EntityTypeConfiguration/AppUserConfiguration.cs +++ b/src/Tuitio.Domain.Data/EntityTypeConfiguration/AppUserConfiguration.cs @@ -1,8 +1,8 @@ -using IdentityServer.Domain.Entities; +using Tuitio.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace IdentityServer.Domain.Data.EntityTypeConfiguration +namespace Tuitio.Domain.Data.EntityTypeConfiguration { class AppUserConfiguration : IEntityTypeConfiguration { diff --git a/IdentityServer.Domain.Data/EntityTypeConfiguration/UserClaimConfiguration.cs b/src/Tuitio.Domain.Data/EntityTypeConfiguration/UserClaimConfiguration.cs similarity index 79% rename from IdentityServer.Domain.Data/EntityTypeConfiguration/UserClaimConfiguration.cs rename to src/Tuitio.Domain.Data/EntityTypeConfiguration/UserClaimConfiguration.cs index 915b6a6..3a624fd 100644 --- a/IdentityServer.Domain.Data/EntityTypeConfiguration/UserClaimConfiguration.cs +++ b/src/Tuitio.Domain.Data/EntityTypeConfiguration/UserClaimConfiguration.cs @@ -1,8 +1,8 @@ -using IdentityServer.Domain.Entities; +using Tuitio.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace IdentityServer.Domain.Data.EntityTypeConfiguration +namespace Tuitio.Domain.Data.EntityTypeConfiguration { class UserClaimConfiguration : IEntityTypeConfiguration { diff --git a/IdentityServer.Domain.Data/EntityTypeConfiguration/UserStatusConfiguration.cs b/src/Tuitio.Domain.Data/EntityTypeConfiguration/UserStatusConfiguration.cs similarity index 79% rename from IdentityServer.Domain.Data/EntityTypeConfiguration/UserStatusConfiguration.cs rename to src/Tuitio.Domain.Data/EntityTypeConfiguration/UserStatusConfiguration.cs index f5433f9..ce4c367 100644 --- a/IdentityServer.Domain.Data/EntityTypeConfiguration/UserStatusConfiguration.cs +++ b/src/Tuitio.Domain.Data/EntityTypeConfiguration/UserStatusConfiguration.cs @@ -1,8 +1,8 @@ -using IdentityServer.Domain.Entities; +using Tuitio.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace IdentityServer.Domain.Data.EntityTypeConfiguration +namespace Tuitio.Domain.Data.EntityTypeConfiguration { class UserStatusConfiguration : IEntityTypeConfiguration { diff --git a/IdentityServer.Domain.Data/EntityTypeConfiguration/UserTokenConfiguration.cs b/src/Tuitio.Domain.Data/EntityTypeConfiguration/UserTokenConfiguration.cs similarity index 79% rename from IdentityServer.Domain.Data/EntityTypeConfiguration/UserTokenConfiguration.cs rename to src/Tuitio.Domain.Data/EntityTypeConfiguration/UserTokenConfiguration.cs index 38a5d52..cc98b55 100644 --- a/IdentityServer.Domain.Data/EntityTypeConfiguration/UserTokenConfiguration.cs +++ b/src/Tuitio.Domain.Data/EntityTypeConfiguration/UserTokenConfiguration.cs @@ -1,8 +1,8 @@ -using IdentityServer.Domain.Entities; +using Tuitio.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace IdentityServer.Domain.Data.EntityTypeConfiguration +namespace Tuitio.Domain.Data.EntityTypeConfiguration { class UserTokenConfiguration : IEntityTypeConfiguration { diff --git a/IdentityServer.Domain.Data/Repositories/IdentityRepository.cs b/src/Tuitio.Domain.Data/Repositories/IdentityRepository.cs similarity index 87% rename from IdentityServer.Domain.Data/Repositories/IdentityRepository.cs rename to src/Tuitio.Domain.Data/Repositories/IdentityRepository.cs index 2883380..60a28e4 100644 --- a/IdentityServer.Domain.Data/Repositories/IdentityRepository.cs +++ b/src/Tuitio.Domain.Data/Repositories/IdentityRepository.cs @@ -1,13 +1,13 @@ -using IdentityServer.Domain.Data.DbContexts; -using IdentityServer.Domain.Entities; -using IdentityServer.Domain.Models; -using IdentityServer.Domain.Repositories; +using Tuitio.Domain.Data.DbContexts; +using Tuitio.Domain.Entities; +using Tuitio.Domain.Models; +using Tuitio.Domain.Repositories; using Microsoft.EntityFrameworkCore; using System; using System.Linq; using System.Threading.Tasks; -namespace IdentityServer.Domain.Data.Repositories +namespace Tuitio.Domain.Data.Repositories { class IdentityRepository : IIdentityRepository { diff --git a/IdentityServer.Domain.Data/Scripts/1.0.0/01.UserStatus table.sql b/src/Tuitio.Domain.Data/Scripts/1.0.0/01.UserStatus table.sql similarity index 100% rename from IdentityServer.Domain.Data/Scripts/1.0.0/01.UserStatus table.sql rename to src/Tuitio.Domain.Data/Scripts/1.0.0/01.UserStatus table.sql diff --git a/IdentityServer.Domain.Data/Scripts/1.0.0/02.AppUser table.sql b/src/Tuitio.Domain.Data/Scripts/1.0.0/02.AppUser table.sql similarity index 100% rename from IdentityServer.Domain.Data/Scripts/1.0.0/02.AppUser table.sql rename to src/Tuitio.Domain.Data/Scripts/1.0.0/02.AppUser table.sql diff --git a/IdentityServer.Domain.Data/Scripts/1.0.0/03.IDX_AppUser_Email_NOTNULL.sql b/src/Tuitio.Domain.Data/Scripts/1.0.0/03.IDX_AppUser_Email_NOTNULL.sql similarity index 100% rename from IdentityServer.Domain.Data/Scripts/1.0.0/03.IDX_AppUser_Email_NOTNULL.sql rename to src/Tuitio.Domain.Data/Scripts/1.0.0/03.IDX_AppUser_Email_NOTNULL.sql diff --git a/IdentityServer.Domain.Data/Scripts/1.0.1/01.UserClaim table.sql b/src/Tuitio.Domain.Data/Scripts/1.0.1/01.UserClaim table.sql similarity index 100% rename from IdentityServer.Domain.Data/Scripts/1.0.1/01.UserClaim table.sql rename to src/Tuitio.Domain.Data/Scripts/1.0.1/01.UserClaim table.sql diff --git a/IdentityServer.Domain.Data/Scripts/1.0.1/02.UserToken table.sql b/src/Tuitio.Domain.Data/Scripts/1.0.1/02.UserToken table.sql similarity index 100% rename from IdentityServer.Domain.Data/Scripts/1.0.1/02.UserToken table.sql rename to src/Tuitio.Domain.Data/Scripts/1.0.1/02.UserToken table.sql diff --git a/IdentityServer.Domain.Data/IdentityServer.Domain.Data.csproj b/src/Tuitio.Domain.Data/Tuitio.Domain.Data.csproj similarity index 88% rename from IdentityServer.Domain.Data/IdentityServer.Domain.Data.csproj rename to src/Tuitio.Domain.Data/Tuitio.Domain.Data.csproj index 93c700d..edd04a6 100644 --- a/IdentityServer.Domain.Data/IdentityServer.Domain.Data.csproj +++ b/src/Tuitio.Domain.Data/Tuitio.Domain.Data.csproj @@ -1,7 +1,7 @@ - net5.0 + net6.0 @@ -9,7 +9,7 @@ - + diff --git a/IdentityServer.Domain/Abstractions/IConfigProvider.cs b/src/Tuitio.Domain/Abstractions/IConfigProvider.cs similarity index 60% rename from IdentityServer.Domain/Abstractions/IConfigProvider.cs rename to src/Tuitio.Domain/Abstractions/IConfigProvider.cs index c2ec84a..f36624e 100644 --- a/IdentityServer.Domain/Abstractions/IConfigProvider.cs +++ b/src/Tuitio.Domain/Abstractions/IConfigProvider.cs @@ -1,6 +1,6 @@ -using IdentityServer.Domain.Models.Config; +using Tuitio.Domain.Models.Config; -namespace IdentityServer.Domain.Abstractions +namespace Tuitio.Domain.Abstractions { public interface IConfigProvider { diff --git a/IdentityServer.Domain/Entities/AppUser.cs b/src/Tuitio.Domain/Entities/AppUser.cs similarity index 95% rename from IdentityServer.Domain/Entities/AppUser.cs rename to src/Tuitio.Domain/Entities/AppUser.cs index ec1e415..bcc81c5 100644 --- a/IdentityServer.Domain/Entities/AppUser.cs +++ b/src/Tuitio.Domain/Entities/AppUser.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace IdentityServer.Domain.Entities +namespace Tuitio.Domain.Entities { public class AppUser { diff --git a/IdentityServer.Domain/Entities/UserClaim.cs b/src/Tuitio.Domain/Entities/UserClaim.cs similarity index 83% rename from IdentityServer.Domain/Entities/UserClaim.cs rename to src/Tuitio.Domain/Entities/UserClaim.cs index 22231f7..59d03b0 100644 --- a/IdentityServer.Domain/Entities/UserClaim.cs +++ b/src/Tuitio.Domain/Entities/UserClaim.cs @@ -1,4 +1,4 @@ -namespace IdentityServer.Domain.Entities +namespace Tuitio.Domain.Entities { public class UserClaim { diff --git a/IdentityServer.Domain/Entities/UserStatus.cs b/src/Tuitio.Domain/Entities/UserStatus.cs similarity index 80% rename from IdentityServer.Domain/Entities/UserStatus.cs rename to src/Tuitio.Domain/Entities/UserStatus.cs index 50c6622..3e1acab 100644 --- a/IdentityServer.Domain/Entities/UserStatus.cs +++ b/src/Tuitio.Domain/Entities/UserStatus.cs @@ -1,4 +1,4 @@ -namespace IdentityServer.Domain.Entities +namespace Tuitio.Domain.Entities { public class UserStatus { diff --git a/IdentityServer.Domain/Entities/UserToken.cs b/src/Tuitio.Domain/Entities/UserToken.cs similarity index 88% rename from IdentityServer.Domain/Entities/UserToken.cs rename to src/Tuitio.Domain/Entities/UserToken.cs index bde0b50..de082fa 100644 --- a/IdentityServer.Domain/Entities/UserToken.cs +++ b/src/Tuitio.Domain/Entities/UserToken.cs @@ -1,6 +1,6 @@ using System; -namespace IdentityServer.Domain.Entities +namespace Tuitio.Domain.Entities { public class UserToken { diff --git a/IdentityServer.Domain/Models/Config/RestrictionsConfig.cs b/src/Tuitio.Domain/Models/Config/RestrictionsConfig.cs similarity index 68% rename from IdentityServer.Domain/Models/Config/RestrictionsConfig.cs rename to src/Tuitio.Domain/Models/Config/RestrictionsConfig.cs index c51cbe4..b08b252 100644 --- a/IdentityServer.Domain/Models/Config/RestrictionsConfig.cs +++ b/src/Tuitio.Domain/Models/Config/RestrictionsConfig.cs @@ -1,4 +1,4 @@ -namespace IdentityServer.Domain.Models.Config +namespace Tuitio.Domain.Models.Config { public class RestrictionsConfig { diff --git a/IdentityServer.Domain/Models/Config/TokenConfig.cs b/src/Tuitio.Domain/Models/Config/TokenConfig.cs similarity index 66% rename from IdentityServer.Domain/Models/Config/TokenConfig.cs rename to src/Tuitio.Domain/Models/Config/TokenConfig.cs index e6e65d7..c5b8f2e 100644 --- a/IdentityServer.Domain/Models/Config/TokenConfig.cs +++ b/src/Tuitio.Domain/Models/Config/TokenConfig.cs @@ -1,4 +1,4 @@ -namespace IdentityServer.Domain.Models.Config +namespace Tuitio.Domain.Models.Config { public class TokenConfig { diff --git a/IdentityServer.Domain/Models/Token.cs b/src/Tuitio.Domain/Models/Token.cs similarity index 83% rename from IdentityServer.Domain/Models/Token.cs rename to src/Tuitio.Domain/Models/Token.cs index bd2bf16..44c638e 100644 --- a/IdentityServer.Domain/Models/Token.cs +++ b/src/Tuitio.Domain/Models/Token.cs @@ -1,6 +1,6 @@ using System; -namespace IdentityServer.Domain.Models +namespace Tuitio.Domain.Models { public class Token { diff --git a/IdentityServer.Domain/Models/TokenCore.cs b/src/Tuitio.Domain/Models/TokenCore.cs similarity index 92% rename from IdentityServer.Domain/Models/TokenCore.cs rename to src/Tuitio.Domain/Models/TokenCore.cs index cb17362..e2fbae9 100644 --- a/IdentityServer.Domain/Models/TokenCore.cs +++ b/src/Tuitio.Domain/Models/TokenCore.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace IdentityServer.Domain.Models +namespace Tuitio.Domain.Models { public class TokenCore { diff --git a/IdentityServer.Domain/Repositories/IIdentityRepository.cs b/src/Tuitio.Domain/Repositories/IIdentityRepository.cs similarity index 68% rename from IdentityServer.Domain/Repositories/IIdentityRepository.cs rename to src/Tuitio.Domain/Repositories/IIdentityRepository.cs index a605378..1335924 100644 --- a/IdentityServer.Domain/Repositories/IIdentityRepository.cs +++ b/src/Tuitio.Domain/Repositories/IIdentityRepository.cs @@ -1,8 +1,8 @@ -using IdentityServer.Domain.Entities; -using IdentityServer.Domain.Models; +using Tuitio.Domain.Entities; +using Tuitio.Domain.Models; using System.Threading.Tasks; -namespace IdentityServer.Domain.Repositories +namespace Tuitio.Domain.Repositories { public interface IIdentityRepository { diff --git a/IdentityServer.Domain/IdentityServer.Domain.csproj b/src/Tuitio.Domain/Tuitio.Domain.csproj similarity index 64% rename from IdentityServer.Domain/IdentityServer.Domain.csproj rename to src/Tuitio.Domain/Tuitio.Domain.csproj index f208d30..dbc1517 100644 --- a/IdentityServer.Domain/IdentityServer.Domain.csproj +++ b/src/Tuitio.Domain/Tuitio.Domain.csproj @@ -1,7 +1,7 @@ - net5.0 + net6.0 diff --git a/IdentityServer.PublishedLanguage/Constants/AuthenticationStatus.cs b/src/Tuitio.PublishedLanguage/Constants/AuthenticationStatus.cs similarity index 74% rename from IdentityServer.PublishedLanguage/Constants/AuthenticationStatus.cs rename to src/Tuitio.PublishedLanguage/Constants/AuthenticationStatus.cs index 29da4fa..109363d 100644 --- a/IdentityServer.PublishedLanguage/Constants/AuthenticationStatus.cs +++ b/src/Tuitio.PublishedLanguage/Constants/AuthenticationStatus.cs @@ -1,4 +1,4 @@ -namespace IdentityServer.PublishedLanguage.Constants +namespace Tuitio.PublishedLanguage.Constants { public struct AuthenticationStatus { diff --git a/IdentityServer.PublishedLanguage/Dto/Token.cs b/src/Tuitio.PublishedLanguage/Dto/Token.cs similarity index 80% rename from IdentityServer.PublishedLanguage/Dto/Token.cs rename to src/Tuitio.PublishedLanguage/Dto/Token.cs index 3a8c8e4..b8eff21 100644 --- a/IdentityServer.PublishedLanguage/Dto/Token.cs +++ b/src/Tuitio.PublishedLanguage/Dto/Token.cs @@ -1,6 +1,6 @@ using System; -namespace IdentityServer.PublishedLanguage.Dto +namespace Tuitio.PublishedLanguage.Dto { public class Token { diff --git a/IdentityServer.PublishedLanguage/Dto/TokenCore.cs b/src/Tuitio.PublishedLanguage/Dto/TokenCore.cs similarity index 91% rename from IdentityServer.PublishedLanguage/Dto/TokenCore.cs rename to src/Tuitio.PublishedLanguage/Dto/TokenCore.cs index 98873a9..5b55686 100644 --- a/IdentityServer.PublishedLanguage/Dto/TokenCore.cs +++ b/src/Tuitio.PublishedLanguage/Dto/TokenCore.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace IdentityServer.PublishedLanguage.Dto +namespace Tuitio.PublishedLanguage.Dto { public class TokenCore { diff --git a/IdentityServer.PublishedLanguage/Events/AuthenticateUserResult.cs b/src/Tuitio.PublishedLanguage/Events/AuthenticateUserResult.cs similarity index 58% rename from IdentityServer.PublishedLanguage/Events/AuthenticateUserResult.cs rename to src/Tuitio.PublishedLanguage/Events/AuthenticateUserResult.cs index 9ebd117..fdecd40 100644 --- a/IdentityServer.PublishedLanguage/Events/AuthenticateUserResult.cs +++ b/src/Tuitio.PublishedLanguage/Events/AuthenticateUserResult.cs @@ -1,6 +1,6 @@ -using IdentityServer.PublishedLanguage.Dto; +using Tuitio.PublishedLanguage.Dto; -namespace IdentityServer.PublishedLanguage.Events +namespace Tuitio.PublishedLanguage.Events { public class AuthenticateUserResult { diff --git a/src/Tuitio.PublishedLanguage/Tuitio.PublishedLanguage.csproj b/src/Tuitio.PublishedLanguage/Tuitio.PublishedLanguage.csproj new file mode 100644 index 0000000..5c365bc --- /dev/null +++ b/src/Tuitio.PublishedLanguage/Tuitio.PublishedLanguage.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + Tuitio published language package + https://lab.code-rove.com/gitea/tudor.stanciu/tuitio + https://lab.code-rove.com/gitea/tudor.stanciu/tuitio + Git + Tuitio published language package + 2.0.0 + + + diff --git a/IdentityServer.Wrapper/Constants/ApiRoutes.cs b/src/Tuitio.Wrapper/Constants/ApiRoutes.cs similarity index 82% rename from IdentityServer.Wrapper/Constants/ApiRoutes.cs rename to src/Tuitio.Wrapper/Constants/ApiRoutes.cs index 7a821ca..8c1b594 100644 --- a/IdentityServer.Wrapper/Constants/ApiRoutes.cs +++ b/src/Tuitio.Wrapper/Constants/ApiRoutes.cs @@ -1,4 +1,4 @@ -namespace IdentityServer.Wrapper.Constants +namespace Tuitio.Wrapper.Constants { internal struct ApiRoutes { diff --git a/IdentityServer.Wrapper/DependencyInjectionExtension.cs b/src/Tuitio.Wrapper/DependencyInjectionExtension.cs similarity index 77% rename from IdentityServer.Wrapper/DependencyInjectionExtension.cs rename to src/Tuitio.Wrapper/DependencyInjectionExtension.cs index 0f38086..1c7c49f 100644 --- a/IdentityServer.Wrapper/DependencyInjectionExtension.cs +++ b/src/Tuitio.Wrapper/DependencyInjectionExtension.cs @@ -1,8 +1,8 @@ -using IdentityServer.Wrapper.Models; -using IdentityServer.Wrapper.Services; +using Tuitio.Wrapper.Models; +using Tuitio.Wrapper.Services; using Microsoft.Extensions.DependencyInjection; -namespace IdentityServer.Wrapper +namespace Tuitio.Wrapper { public static class DependencyInjectionExtension { diff --git a/IdentityServer.Wrapper/Models/ServiceConfiguration.cs b/src/Tuitio.Wrapper/Models/ServiceConfiguration.cs similarity index 83% rename from IdentityServer.Wrapper/Models/ServiceConfiguration.cs rename to src/Tuitio.Wrapper/Models/ServiceConfiguration.cs index 9a29547..fc455a1 100644 --- a/IdentityServer.Wrapper/Models/ServiceConfiguration.cs +++ b/src/Tuitio.Wrapper/Models/ServiceConfiguration.cs @@ -1,4 +1,4 @@ -namespace IdentityServer.Wrapper.Models +namespace Tuitio.Wrapper.Models { internal class ServiceConfiguration { diff --git a/IdentityServer.Wrapper/Services/IIdentityService.cs b/src/Tuitio.Wrapper/Services/IIdentityService.cs similarity index 69% rename from IdentityServer.Wrapper/Services/IIdentityService.cs rename to src/Tuitio.Wrapper/Services/IIdentityService.cs index 7871b3d..0c88975 100644 --- a/IdentityServer.Wrapper/Services/IIdentityService.cs +++ b/src/Tuitio.Wrapper/Services/IIdentityService.cs @@ -1,7 +1,7 @@ -using IdentityServer.PublishedLanguage.Dto; +using Tuitio.PublishedLanguage.Dto; using System.Threading.Tasks; -namespace IdentityServer.Wrapper.Services +namespace Tuitio.Wrapper.Services { public interface IIdentityService { diff --git a/IdentityServer.Wrapper/Services/IdentityService.cs b/src/Tuitio.Wrapper/Services/IdentityService.cs similarity index 85% rename from IdentityServer.Wrapper/Services/IdentityService.cs rename to src/Tuitio.Wrapper/Services/IdentityService.cs index 2120f91..7ed8a54 100644 --- a/IdentityServer.Wrapper/Services/IdentityService.cs +++ b/src/Tuitio.Wrapper/Services/IdentityService.cs @@ -1,13 +1,13 @@ -using IdentityServer.PublishedLanguage.Dto; -using IdentityServer.Wrapper.Constants; -using IdentityServer.Wrapper.Models; -using NDB.Extensions.Http; +using Tuitio.PublishedLanguage.Dto; +using Tuitio.Wrapper.Constants; +using Tuitio.Wrapper.Models; +using Netmash.Extensions.Http; using System; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; -namespace IdentityServer.Wrapper.Services +namespace Tuitio.Wrapper.Services { internal class IdentityService : IIdentityService { diff --git a/src/Tuitio.Wrapper/Tuitio.Wrapper.csproj b/src/Tuitio.Wrapper/Tuitio.Wrapper.csproj new file mode 100644 index 0000000..64453d9 --- /dev/null +++ b/src/Tuitio.Wrapper/Tuitio.Wrapper.csproj @@ -0,0 +1,24 @@ + + + + net6.0 + Tuitio wrapper + Tuitio wrapper + https://lab.code-rove.com/gitea/tudor.stanciu/tuitio + Git + https://lab.code-rove.com/gitea/tudor.stanciu/tuitio + Tuitio wrapper + 2.0.0 + + + + + + + + + + + + + diff --git a/IdentityServer.Api/Controllers/IdentityController.cs b/src/Tuitio/Controllers/IdentityController.cs similarity index 92% rename from IdentityServer.Api/Controllers/IdentityController.cs rename to src/Tuitio/Controllers/IdentityController.cs index 2c425fe..70e73b2 100644 --- a/IdentityServer.Api/Controllers/IdentityController.cs +++ b/src/Tuitio/Controllers/IdentityController.cs @@ -1,9 +1,9 @@ -using IdentityServer.Application.Commands; +using Tuitio.Application.Commands; using MediatR; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; -namespace IdentityServer.Api.Controllers +namespace Tuitio.Api.Controllers { [ApiController] [Route("identity")] diff --git a/IdentityServer.Api/Controllers/SystemController.cs b/src/Tuitio/Controllers/SystemController.cs similarity index 94% rename from IdentityServer.Api/Controllers/SystemController.cs rename to src/Tuitio/Controllers/SystemController.cs index 486bc55..e1f65ab 100644 --- a/IdentityServer.Api/Controllers/SystemController.cs +++ b/src/Tuitio/Controllers/SystemController.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; -namespace IdentityServer.Api.Controllers +namespace Tuitio.Api.Controllers { [ApiController] [Route("system")] diff --git a/src/Tuitio/Dockerfile b/src/Tuitio/Dockerfile new file mode 100644 index 0000000..45b36c2 --- /dev/null +++ b/src/Tuitio/Dockerfile @@ -0,0 +1,36 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /workspace +COPY ["dependencies.props", "."] +COPY ["Directory.Build.props", "."] +COPY ["NuGet.config", "."] +COPY ["src/Tuitio/Tuitio.csproj", "src/Tuitio/"] +COPY ["src/Tuitio.Application/Tuitio.Application.csproj", "src/Tuitio.Application/"] +COPY ["src/Tuitio.Domain/Tuitio.Domain.csproj", "src/Tuitio.Domain/"] +COPY ["src/Tuitio.PublishedLanguage/Tuitio.PublishedLanguage.csproj", "src/Tuitio.PublishedLanguage/"] +COPY ["src/Tuitio.Domain.Data/Tuitio.Domain.Data.csproj", "src/Tuitio.Domain.Data/"] +RUN dotnet restore "src/Tuitio/Tuitio.csproj" +COPY . . +WORKDIR "/workspace/src/Tuitio" +RUN dotnet build "Tuitio.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Tuitio.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . + +ENV Urls="http://*:80" +ENV TZ=Europe/Bucharest +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +#Workaround to lower the TLS level in container for old sql server version +RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf + +ENTRYPOINT ["dotnet", "Tuitio.dll"] \ No newline at end of file diff --git a/src/Tuitio/Extensions/DataTypeExtensions.cs b/src/Tuitio/Extensions/DataTypeExtensions.cs new file mode 100644 index 0000000..efaacbd --- /dev/null +++ b/src/Tuitio/Extensions/DataTypeExtensions.cs @@ -0,0 +1,8 @@ +namespace Tuitio.Extensions +{ + internal static class DataTypeExtensions + { + public static string Nullify(this string value) + => string.IsNullOrWhiteSpace(value) ? null : value; + } +} diff --git a/src/Tuitio/Extensions/LoggingExtensions.cs b/src/Tuitio/Extensions/LoggingExtensions.cs new file mode 100644 index 0000000..609077a --- /dev/null +++ b/src/Tuitio/Extensions/LoggingExtensions.cs @@ -0,0 +1,41 @@ +using Microsoft.Extensions.Configuration; +using Serilog; +using Serilog.Configuration; +using Serilog.Sinks.MSSqlServer; +using System; + +namespace Tuitio.Extensions +{ + internal static class LoggingExtensions + { + internal static LoggerSinkConfiguration ConfiguredDestinations(this LoggerSinkConfiguration writeTo, IConfiguration configuration) + { + var sqlServerEnabled = configuration.GetValue("Logs:SqlServer:Enabled"); + var sqlServerConnection = configuration.GetValue("Logs:SqlServer:Connection"); + var seqEnabled = configuration.GetValue("Logs:Seq:Enabled"); + var seqUrl = configuration.GetValue("Logs:Seq:Url"); + var seqApiKey = configuration.GetValue("Logs:Seq:ApiKey"); + + if (sqlServerEnabled && string.IsNullOrWhiteSpace(sqlServerConnection)) + throw new Exception("If SqlServer logging is enabled, the SqlServer connection must be configured."); + if (seqEnabled && string.IsNullOrWhiteSpace(seqUrl)) + throw new Exception("If Seq logging is enabled, the Seq URL must be configured."); + + if (sqlServerEnabled) + { + var columnOptions = new ColumnOptions(); + columnOptions.Store.Remove(StandardColumn.Properties); + columnOptions.Store.Remove(StandardColumn.MessageTemplate); + columnOptions.Store.Add(StandardColumn.LogEvent); + var mssqlSinkOptions = new MSSqlServerSinkOptions() { AutoCreateSqlTable = true, TableName = "__Logs" }; + + writeTo.MSSqlServer(sqlServerConnection, mssqlSinkOptions, columnOptions: columnOptions); + } + + if (seqEnabled) + writeTo.Seq(seqUrl, apiKey: seqApiKey.Nullify()); + + return writeTo; + } + } +} diff --git a/src/Tuitio/Extensions/StartupExtensions.cs b/src/Tuitio/Extensions/StartupExtensions.cs new file mode 100644 index 0000000..a4f76cc --- /dev/null +++ b/src/Tuitio/Extensions/StartupExtensions.cs @@ -0,0 +1,62 @@ +using MediatR; +using MediatR.Pipeline; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Netmash.Extensions.Swagger; +using Netmash.Extensions.Swagger.Constants; +using Netmash.Infrastructure.DatabaseMigration; +using Netmash.Infrastructure.DatabaseMigration.Constants; +using Tuitio.Application; +using Tuitio.Application.Services.Abstractions; +using Tuitio.Domain.Data; + +namespace Tuitio.Extensions +{ + public static class StartupExtensions + { + public static void ConfigureServices(this IServiceCollection services, IConfiguration configuration) + { + services.AddControllers(); + + // MediatR + services.AddMediatR(typeof(Application.Commands.AuthenticateUser).Assembly); + services.AddScoped(typeof(IPipelineBehavior<,>), typeof(RequestPreProcessorBehavior<,>)); + services.AddScoped(typeof(IPipelineBehavior<,>), typeof(RequestPostProcessorBehavior<,>)); + + // AutoMapper + services.AddAutoMapper( + typeof(Application.Mappings.MappingProfile).Assembly); + + // Swagger + services.AddSwagger("Tuitio API", AuthorizationType.None); + + // Data access + services.AddMigration(DatabaseType.SQLServer, MetadataLocation.Database); + services.AddDataAccess(); + + // Application + services.AddApplicationServices(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public static void Configure(this WebApplication app) + { + // global cors policy + app.UseCors(z => z.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); + + app.UseRouting(); + app.UseAuthorization(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + app.ConfigureSwagger("Tuitio API"); + + app.UseMigration(); + + var behaviorService = app.Services.GetService(); + behaviorService.FillTokenStore(); + } + } +} diff --git a/src/Tuitio/Program.cs b/src/Tuitio/Program.cs new file mode 100644 index 0000000..1b80410 --- /dev/null +++ b/src/Tuitio/Program.cs @@ -0,0 +1,48 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Serilog; +using System; +using Tuitio.Extensions; + +namespace Tuitio.Api +{ + public class Program + { + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + builder.Host.UseSerilog((_, loggerConfiguration) => + { + loggerConfiguration + .ReadFrom.Configuration(builder.Configuration) + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.ConfiguredDestinations(builder.Configuration); + }); + + builder.Services.ConfigureServices(builder.Configuration); + var app = builder.Build(); + app.Configure(); + + try + { + var urls = builder.Configuration.GetValue("Urls"); + Log.Information("Starting Tuitio API..."); + Log.Information($"API listening on {urls}"); + Console.WriteLine("Application started. Press Ctrl+C to shut down."); + app.Run(); + } + catch (Exception ex) + { + Log.Fatal(ex, "Tuitio API host terminated unexpectedly"); + } + finally + { + Log.CloseAndFlush(); + } + } + } +} diff --git a/IdentityServer.Api/Properties/launchSettings.json b/src/Tuitio/Properties/launchSettings.json similarity index 87% rename from IdentityServer.Api/Properties/launchSettings.json rename to src/Tuitio/Properties/launchSettings.json index a86dcb0..4ee55fd 100644 --- a/IdentityServer.Api/Properties/launchSettings.json +++ b/src/Tuitio/Properties/launchSettings.json @@ -1,6 +1,6 @@ { "profiles": { - "IdentityServer.Api": { + "Tuitio.Api": { "commandName": "Project", "applicationUrl": "http://localhost:5000", "environmentVariables": { diff --git a/IdentityServer.Api/IdentityServer.Api.csproj b/src/Tuitio/Tuitio.csproj similarity index 62% rename from IdentityServer.Api/IdentityServer.Api.csproj rename to src/Tuitio/Tuitio.csproj index e76cdcf..1fed3de 100644 --- a/IdentityServer.Api/IdentityServer.Api.csproj +++ b/src/Tuitio/Tuitio.csproj @@ -1,30 +1,28 @@  - net5.0 + net6.0 Linux - - - + + - - + - - + + diff --git a/src/Tuitio/appsettings.json b/src/Tuitio/appsettings.json new file mode 100644 index 0000000..b305db6 --- /dev/null +++ b/src/Tuitio/appsettings.json @@ -0,0 +1,32 @@ +{ + "Urls": "http://*:5063", + "ConnectionStrings": { + "DatabaseConnection": "Server=######;Database=######;User Id=######;Password=######;MultipleActiveResultSets=true" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft": "Information" + } + } + }, + "Logs": { + "SqlServer": { + "Enabled": false, + "Connection": "Server=#########;Database=#########;User Id=#########;Password=#########;MultipleActiveResultSets=true" + }, + "Seq": { + "Enabled": false, + "Url": "", + "ApiKey": "" + } + }, + "AllowedHosts": "*", + "Restrictions": { + "MaxFailedLoginAttempts": 5 + }, + "Token": { + "ValidityInMinutes": 43800 + } +}