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
master
Tudor Stanciu 2023-01-31 00:17:54 +00:00
parent c032338bcd
commit 2eb299049e
82 changed files with 482 additions and 536 deletions

4
.gitignore vendored
View File

@ -338,3 +338,7 @@ ASALocalRun/
# BeatPulse healthcheck temp database # BeatPulse healthcheck temp database
healthchecksdb healthchecksdb
*/**/appsettings.Development.json
build.sh
buildx.sh

View File

@ -1,10 +1,10 @@
<Project> <Project>
<Import Project="dependencies.props" /> <Import Project="dependencies.props" />
<PropertyGroup> <PropertyGroup>
<Version>1.1.3</Version> <Version>2.0.0</Version>
<Authors>Tudor Stanciu</Authors> <Authors>Tudor Stanciu</Authors>
<Company>STA</Company> <Company>STA</Company>
<PackageTags>IdentityServer</PackageTags> <PackageTags>Tuitio</PackageTags>
<Copyright>STA Identity server</Copyright> <Copyright>STA Tuitio</Copyright>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -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\

View File

@ -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"]

View File

@ -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<string>("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<string>("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<Startup>()
.UseConfiguration(configuration)
.UseSerilog();
});
if (useWindowsService)
builder.UseWindowsService();
return builder;
}
}
}

View File

@ -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<IBehaviorService>();
behaviorService.FillTokenStore();
}
}
}

View File

@ -1,9 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -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
}
}

View File

@ -1,11 +0,0 @@
using IdentityServer.PublishedLanguage.Events;
using NDB.Application.DataContracts;
namespace IdentityServer.Application.Commands
{
public class AuthenticateUser : Command<AuthenticateUserResult>
{
public string UserName { get; set; }
public string Password { get; set; }
}
}

View File

@ -1,10 +0,0 @@
using IdentityServer.PublishedLanguage.Dto;
using NDB.Application.DataContracts;
namespace IdentityServer.Application.Commands
{
public class AuthorizeToken : Command<TokenCore>
{
public string Token { get; set; }
}
}

View File

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>Identity server published language package</Description>
<PackageProjectUrl>https://dev.azure.com/tstanciu94/IdentityServer</PackageProjectUrl>
<RepositoryUrl>https://dev.azure.com/tstanciu94/_git/IdentityServer</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageReleaseNotes>Identity server published language package</PackageReleaseNotes>
<Version>1.1.0</Version>
</PropertyGroup>
</Project>

View File

@ -1,21 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>Identity server wrapper</Description>
<PackageReleaseNotes>Identity server wrapper</PackageReleaseNotes>
<PackageProjectUrl>https://dev.azure.com/tstanciu94/IdentityServer</PackageProjectUrl>
<RepositoryType>Git</RepositoryType>
<RepositoryUrl>https://dev.azure.com/tstanciu94/_git/IdentityServer</RepositoryUrl>
<PackageTags>IdentityServer wrapper</PackageTags>
<Version>1.1.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IdentityServer.PublishedLanguage" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.3" />
<PackageReference Include="NDB.Extensions.Http" Version="1.0.0" />
</ItemGroup>
</Project>

View File

@ -3,14 +3,14 @@ Publish:
dotnet publish --configuration Release --runtime win7-x64 dotnet publish --configuration Release --runtime win7-x64
Create windows service: Create windows service:
sc create IdentityServer.Api binPath= "<path_to_the_service_executable>" sc create Tuitio.Api binPath= "<path_to_the_service_executable>"
####################################################################################################################################################### #######################################################################################################################################################
####################################################################################################################################################### #######################################################################################################################################################
Push language package: Push language package:
dotnet nuget push IdentityServer.PublishedLanguage.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 IdentityServer.Wrapper.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: TO DO:
@ -22,7 +22,7 @@ Docker commands:
Create image: Create image:
--from solution folder: --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: Run image:
docker run -p 5053:80 -it identity-server-api:1.0.1 docker run -p 5053:80 -it identity-server-api:1.0.1

View File

@ -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: 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/authenticate``` - handles user authentication using credentials and generates an access token.
* ```/identity/authorize``` - deals with the authorization of a token (verifies its existence, validity, authenticity, etc) * ```/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=<server>;Database=<database>;User Id=<user>;Password=<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 ## Stack
* .NET (C#) * .NET (C#)
@ -11,4 +37,4 @@ At the moment it has a simple API consisting of only two methods:
* SQL Server * SQL Server
* Swagger * Swagger
* Docker * Docker
* Shell * Seq

View File

@ -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" } - 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: "***" } - 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: 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. - Tuitio.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.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 - The source of this nugets is public, but on my personal server: https://lab.code-rove.com/public-nuget-server/nuget
</Content> </Content>
</Note> </Note>
@ -27,13 +27,13 @@
<Version>1.1.0</Version> <Version>1.1.0</Version>
<Content> <Content>
◾ Upgrade all projects to .NET 5 ◾ Upgrade all projects to .NET 5
◾ Upgrade packages MicrosoftExtensions, AutoMapper, EntityFramework, NDB ◾ Upgrade packages MicrosoftExtensions, AutoMapper, EntityFramework, Netmash
</Content> </Content>
</Note> </Note>
<Note> <Note>
<Version>1.1.1</Version> <Version>1.1.1</Version>
<Content> <Content>
◾ Added NDB.Infrastructure.DatabaseMigration ◾ Added Netmash.Infrastructure.DatabaseMigration
◾ Organized sql scripts to meet database migrator requirements ◾ Organized sql scripts to meet database migrator requirements
</Content> </Content>
</Note> </Note>
@ -49,4 +49,15 @@
◾ Upgrade the migration service to version 1.1.0. Migration metadata is now stored in the sql server database. ◾ Upgrade the migration service to version 1.1.0. Migration metadata is now stored in the sql server database.
</Content> </Content>
</Note> </Note>
<Note>
<Version>2.0.0</Version>
<Content>
◾ Tuitio rebranding
◾ .NET 6 upgrade
◾ Nuget packages upgrade
◾ Added Seq logging
◾ Refactoring and code cleanup
◾ Added README.md file
</Content>
</Note>
</ReleaseNotes> </ReleaseNotes>

View File

@ -5,37 +5,29 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5A8FF505-3E4D-4258-BC3E-CACD74A7B98C}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5A8FF505-3E4D-4258-BC3E-CACD74A7B98C}"
EndProject 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 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 ProjectSection(SolutionItems) = preProject
.dockerignore = .dockerignore .dockerignore = .dockerignore
.gitattributes = .gitattributes .gitattributes = .gitattributes
.gitignore = .gitignore .gitignore = .gitignore
dependencies.props = dependencies.props dependencies.props = dependencies.props
Directory.Build.props = Directory.Build.props Directory.Build.props = Directory.Build.props
Documentation.md = Documentation.md
Notes.txt = Notes.txt
NuGet.config = NuGet.config NuGet.config = NuGet.config
ReleaseNotes.xml = ReleaseNotes.xml
README.md = README.md README.md = README.md
ReleaseNotes.xml = ReleaseNotes.xml
EndProjectSection EndProjectSection
EndProject 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 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 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 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 EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Wrapper", "IdentityServer.Wrapper\IdentityServer.Wrapper.csproj", "{F6FEC33B-C79E-4484-B356-9C7F1A5E5D95}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tuitio.Wrapper", "src\Tuitio.Wrapper\Tuitio.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
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -78,7 +70,6 @@ Global
{CE81A435-49AC-4544-A381-FAC91BEB3C49} = {5A8FF505-3E4D-4258-BC3E-CACD74A7B98C} {CE81A435-49AC-4544-A381-FAC91BEB3C49} = {5A8FF505-3E4D-4258-BC3E-CACD74A7B98C}
{67B4D1FF-D02E-4DA6-9FB8-F71667360448} = {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} {F6FEC33B-C79E-4484-B356-9C7F1A5E5D95} = {5A8FF505-3E4D-4258-BC3E-CACD74A7B98C}
{5A9268B6-F73B-4773-86BF-45DFF7EF75F7} = {0B8B6E9B-0200-47EC-91D9-BEDF4BFC248F}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E93DC46D-9C55-4A05-B299-497CDD90747E} SolutionGuid = {E93DC46D-9C55-4A05-B299-497CDD90747E}

View File

@ -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!"

View File

@ -1,17 +1,16 @@
<Project> <Project>
<PropertyGroup Label="Package Versions"> <PropertyGroup Label="Package Versions">
<MicrosoftExtensionsPackageVersion>5.0.0</MicrosoftExtensionsPackageVersion> <MicrosoftExtensionsPackageVersion>6.0.0</MicrosoftExtensionsPackageVersion>
<SerilogPackageVersion>4.1.0</SerilogPackageVersion> <SerilogPackageVersion>6.1.0</SerilogPackageVersion>
<SerilogExtensionsPackageVersion>3.1.0</SerilogExtensionsPackageVersion> <SerilogSinksSeqPackageVersion>5.2.2</SerilogSinksSeqPackageVersion>
<SerilogSinksConsolePackageVersion>4.0.0</SerilogSinksConsolePackageVersion>
<SerilogSinksMSSqlServerPackageVersion>5.6.1</SerilogSinksMSSqlServerPackageVersion> <SerilogSinksMSSqlServerPackageVersion>5.6.1</SerilogSinksMSSqlServerPackageVersion>
<AutoMapperPackageVersion>10.1.1</AutoMapperPackageVersion> <AutoMapperPackageVersion>12.0.1</AutoMapperPackageVersion>
<AutoMapperExtensionsPackageVersion>8.1.1</AutoMapperExtensionsPackageVersion> <AutoMapperExtensionsPackageVersion>12.0.0</AutoMapperExtensionsPackageVersion>
<MediatRPackageVersion>6.0.0</MediatRPackageVersion> <MediatRPackageVersion>9.0.0</MediatRPackageVersion>
<SwashbucklePackageVersion>5.3.1</SwashbucklePackageVersion> <EntityFrameworkCorePackageVersion>6.0.1</EntityFrameworkCorePackageVersion>
<EntityFrameworkCorePackageVersion>5.0.12</EntityFrameworkCorePackageVersion> <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
<NDBExtensionsSwaggerPackageVersion>1.0.2</NDBExtensionsSwaggerPackageVersion> <NetmashExtensionsSwaggerPackageVersion>1.0.6</NetmashExtensionsSwaggerPackageVersion>
<NDBApplicationPackageVersion>1.0.0</NDBApplicationPackageVersion> <NetmashDatabaseMigrationPackageVersion>1.2.0</NetmashDatabaseMigrationPackageVersion>
<NDBDatabaseMigrationPackageVersion>1.1.3</NDBDatabaseMigrationPackageVersion> <NetmashExtensionsHttpPackageVersion>1.0.0</NetmashExtensionsHttpPackageVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -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!"

View File

@ -1,15 +1,15 @@
using AutoMapper; using AutoMapper;
using IdentityServer.Application.Commands; using Tuitio.Application.Commands;
using IdentityServer.Application.Services; using Tuitio.Application.Services;
using IdentityServer.PublishedLanguage.Constants; using Tuitio.PublishedLanguage.Constants;
using IdentityServer.PublishedLanguage.Dto; using Tuitio.PublishedLanguage.Dto;
using IdentityServer.PublishedLanguage.Events; using Tuitio.PublishedLanguage.Events;
using MediatR; using MediatR;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace IdentityServer.Application.CommandHandlers namespace Tuitio.Application.CommandHandlers
{ {
public class AuthenticateUserHandler : IRequestHandler<AuthenticateUser, AuthenticateUserResult> public class AuthenticateUserHandler : IRequestHandler<AuthenticateUser, AuthenticateUserResult>
{ {

View File

@ -1,13 +1,13 @@
using AutoMapper; using AutoMapper;
using IdentityServer.Application.Commands; using Tuitio.Application.Commands;
using IdentityServer.Application.Services; using Tuitio.Application.Services;
using IdentityServer.PublishedLanguage.Dto; using Tuitio.PublishedLanguage.Dto;
using MediatR; using MediatR;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace IdentityServer.Application.CommandHandlers namespace Tuitio.Application.CommandHandlers
{ {
public class AuthorizeTokenHandler : IRequestHandler<AuthorizeToken, TokenCore> public class AuthorizeTokenHandler : IRequestHandler<AuthorizeToken, TokenCore>
{ {

View File

@ -0,0 +1,11 @@
using MediatR;
using Tuitio.PublishedLanguage.Events;
namespace Tuitio.Application.Commands
{
public class AuthenticateUser : IRequest<AuthenticateUserResult>
{
public string UserName { get; set; }
public string Password { get; set; }
}
}

View File

@ -0,0 +1,10 @@
using MediatR;
using Tuitio.PublishedLanguage.Dto;
namespace Tuitio.Application.Commands
{
public class AuthorizeToken : IRequest<TokenCore>
{
public string Token { get; set; }
}
}

View File

@ -1,10 +1,10 @@
using IdentityServer.Application.Services; using Tuitio.Application.Services;
using IdentityServer.Application.Services.Abstractions; using Tuitio.Application.Services.Abstractions;
using IdentityServer.Application.Stores; using Tuitio.Application.Stores;
using IdentityServer.Domain.Abstractions; using Tuitio.Domain.Abstractions;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace IdentityServer.Application namespace Tuitio.Application
{ {
public static class DependencyInjectionExtensions public static class DependencyInjectionExtensions
{ {

View File

@ -1,10 +1,10 @@
using AutoMapper; using AutoMapper;
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using System.Collections.Generic; using System.Collections.Generic;
using dto = IdentityServer.PublishedLanguage.Dto; using dto = Tuitio.PublishedLanguage.Dto;
using models = IdentityServer.Domain.Models; using models = Tuitio.Domain.Models;
namespace IdentityServer.Application.Mappings namespace Tuitio.Application.Mappings
{ {
public class MappingProfile : Profile public class MappingProfile : Profile
{ {

View File

@ -1,4 +1,4 @@
namespace IdentityServer.Application.Services.Abstractions namespace Tuitio.Application.Services.Abstractions
{ {
public interface IBehaviorService public interface IBehaviorService
{ {

View File

@ -1,4 +1,4 @@
namespace IdentityServer.Application.Services.Abstractions namespace Tuitio.Application.Services.Abstractions
{ {
internal interface IHashingService internal interface IHashingService
{ {

View File

@ -1,14 +1,14 @@
using IdentityServer.Application.Services.Abstractions; using Tuitio.Application.Services.Abstractions;
using IdentityServer.Application.Stores; using Tuitio.Application.Stores;
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using IdentityServer.Domain.Models; using Tuitio.Domain.Models;
using IdentityServer.Domain.Repositories; using Tuitio.Domain.Repositories;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace IdentityServer.Application.Services namespace Tuitio.Application.Services
{ {
internal class BehaviorService : IBehaviorService internal class BehaviorService : IBehaviorService
{ {

View File

@ -1,8 +1,8 @@
using IdentityServer.Domain.Abstractions; using Tuitio.Domain.Abstractions;
using IdentityServer.Domain.Models.Config; using Tuitio.Domain.Models.Config;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
namespace IdentityServer.Application.Services namespace Tuitio.Application.Services
{ {
internal class ConfigProvider : IConfigProvider internal class ConfigProvider : IConfigProvider
{ {

View File

@ -1,9 +1,9 @@
using IdentityServer.Application.Services.Abstractions; using Tuitio.Application.Services.Abstractions;
using System; using System;
using System.Security.Authentication; using System.Security.Authentication;
using System.Security.Cryptography; using System.Security.Cryptography;
namespace IdentityServer.Application.Services namespace Tuitio.Application.Services
{ {
internal class HashingService : IHashingService internal class HashingService : IHashingService
{ {

View File

@ -1,7 +1,7 @@
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using IdentityServer.Domain.Models; using Tuitio.Domain.Models;
namespace IdentityServer.Application.Services namespace Tuitio.Application.Services
{ {
internal interface ITokenService internal interface ITokenService
{ {

View File

@ -1,7 +1,7 @@
using IdentityServer.Domain.Models; using Tuitio.Domain.Models;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace IdentityServer.Application.Services namespace Tuitio.Application.Services
{ {
public interface IUserService public interface IUserService
{ {

View File

@ -1,13 +1,13 @@
using AutoMapper; using AutoMapper;
using IdentityServer.Domain.Abstractions; using Tuitio.Domain.Abstractions;
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using IdentityServer.Domain.Models; using Tuitio.Domain.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace IdentityServer.Application.Services namespace Tuitio.Application.Services
{ {
internal class TokenService : ITokenService internal class TokenService : ITokenService
{ {

View File

@ -1,13 +1,13 @@
using IdentityServer.Application.Services.Abstractions; using Tuitio.Application.Services.Abstractions;
using IdentityServer.Application.Stores; using Tuitio.Application.Stores;
using IdentityServer.Domain.Abstractions; using Tuitio.Domain.Abstractions;
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using IdentityServer.Domain.Models; using Tuitio.Domain.Models;
using IdentityServer.Domain.Repositories; using Tuitio.Domain.Repositories;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace IdentityServer.Application.Services namespace Tuitio.Application.Services
{ {
internal class UserService : IUserService internal class UserService : IUserService
{ {

View File

@ -1,6 +1,6 @@
using IdentityServer.Domain.Models; using Tuitio.Domain.Models;
namespace IdentityServer.Application.Stores namespace Tuitio.Application.Stores
{ {
internal interface ITokenStore internal interface ITokenStore
{ {

View File

@ -1,10 +1,10 @@
using IdentityServer.Application.Services; using Tuitio.Application.Services;
using IdentityServer.Domain.Models; using Tuitio.Domain.Models;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace IdentityServer.Application.Stores namespace Tuitio.Application.Stores
{ {
internal class TokenStore : ITokenStore internal class TokenStore : ITokenStore
{ {

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -11,13 +11,12 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(MicrosoftExtensionsPackageVersion)" /> <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="NDB.Application.DataContracts" Version="$(NDBApplicationPackageVersion)" /> <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\IdentityServer.Domain\IdentityServer.Domain.csproj" /> <ProjectReference Include="..\Tuitio.Domain\Tuitio.Domain.csproj" />
<ProjectReference Include="..\IdentityServer.PublishedLanguage\IdentityServer.PublishedLanguage.csproj" /> <ProjectReference Include="..\Tuitio.PublishedLanguage\Tuitio.PublishedLanguage.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,8 +1,8 @@
using IdentityServer.Domain.Data.EntityTypeConfiguration; using Tuitio.Domain.Data.EntityTypeConfiguration;
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace IdentityServer.Domain.Data.DbContexts namespace Tuitio.Domain.Data.DbContexts
{ {
public class IdentityDbContext : DbContext public class IdentityDbContext : DbContext
{ {

View File

@ -1,11 +1,11 @@
using IdentityServer.Domain.Data.DbContexts; using Tuitio.Domain.Data.DbContexts;
using IdentityServer.Domain.Data.Repositories; using Tuitio.Domain.Data.Repositories;
using IdentityServer.Domain.Repositories; using Tuitio.Domain.Repositories;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace IdentityServer.Domain.Data namespace Tuitio.Domain.Data
{ {
public static class DependencyInjectionExtensions public static class DependencyInjectionExtensions
{ {

View File

@ -1,8 +1,8 @@
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace IdentityServer.Domain.Data.EntityTypeConfiguration namespace Tuitio.Domain.Data.EntityTypeConfiguration
{ {
class AppUserConfiguration : IEntityTypeConfiguration<AppUser> class AppUserConfiguration : IEntityTypeConfiguration<AppUser>
{ {

View File

@ -1,8 +1,8 @@
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace IdentityServer.Domain.Data.EntityTypeConfiguration namespace Tuitio.Domain.Data.EntityTypeConfiguration
{ {
class UserClaimConfiguration : IEntityTypeConfiguration<UserClaim> class UserClaimConfiguration : IEntityTypeConfiguration<UserClaim>
{ {

View File

@ -1,8 +1,8 @@
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace IdentityServer.Domain.Data.EntityTypeConfiguration namespace Tuitio.Domain.Data.EntityTypeConfiguration
{ {
class UserStatusConfiguration : IEntityTypeConfiguration<UserStatus> class UserStatusConfiguration : IEntityTypeConfiguration<UserStatus>
{ {

View File

@ -1,8 +1,8 @@
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace IdentityServer.Domain.Data.EntityTypeConfiguration namespace Tuitio.Domain.Data.EntityTypeConfiguration
{ {
class UserTokenConfiguration : IEntityTypeConfiguration<UserToken> class UserTokenConfiguration : IEntityTypeConfiguration<UserToken>
{ {

View File

@ -1,13 +1,13 @@
using IdentityServer.Domain.Data.DbContexts; using Tuitio.Domain.Data.DbContexts;
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using IdentityServer.Domain.Models; using Tuitio.Domain.Models;
using IdentityServer.Domain.Repositories; using Tuitio.Domain.Repositories;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace IdentityServer.Domain.Data.Repositories namespace Tuitio.Domain.Data.Repositories
{ {
class IdentityRepository : IIdentityRepository class IdentityRepository : IIdentityRepository
{ {

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -9,7 +9,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\IdentityServer.Domain\IdentityServer.Domain.csproj" /> <ProjectReference Include="..\Tuitio.Domain\Tuitio.Domain.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -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 public interface IConfigProvider
{ {

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace IdentityServer.Domain.Entities namespace Tuitio.Domain.Entities
{ {
public class AppUser public class AppUser
{ {

View File

@ -1,4 +1,4 @@
namespace IdentityServer.Domain.Entities namespace Tuitio.Domain.Entities
{ {
public class UserClaim public class UserClaim
{ {

View File

@ -1,4 +1,4 @@
namespace IdentityServer.Domain.Entities namespace Tuitio.Domain.Entities
{ {
public class UserStatus public class UserStatus
{ {

View File

@ -1,6 +1,6 @@
using System; using System;
namespace IdentityServer.Domain.Entities namespace Tuitio.Domain.Entities
{ {
public class UserToken public class UserToken
{ {

View File

@ -1,4 +1,4 @@
namespace IdentityServer.Domain.Models.Config namespace Tuitio.Domain.Models.Config
{ {
public class RestrictionsConfig public class RestrictionsConfig
{ {

View File

@ -1,4 +1,4 @@
namespace IdentityServer.Domain.Models.Config namespace Tuitio.Domain.Models.Config
{ {
public class TokenConfig public class TokenConfig
{ {

View File

@ -1,6 +1,6 @@
using System; using System;
namespace IdentityServer.Domain.Models namespace Tuitio.Domain.Models
{ {
public class Token public class Token
{ {

View File

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace IdentityServer.Domain.Models namespace Tuitio.Domain.Models
{ {
public class TokenCore public class TokenCore
{ {

View File

@ -1,8 +1,8 @@
using IdentityServer.Domain.Entities; using Tuitio.Domain.Entities;
using IdentityServer.Domain.Models; using Tuitio.Domain.Models;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace IdentityServer.Domain.Repositories namespace Tuitio.Domain.Repositories
{ {
public interface IIdentityRepository public interface IIdentityRepository
{ {

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -1,4 +1,4 @@
namespace IdentityServer.PublishedLanguage.Constants namespace Tuitio.PublishedLanguage.Constants
{ {
public struct AuthenticationStatus public struct AuthenticationStatus
{ {

View File

@ -1,6 +1,6 @@
using System; using System;
namespace IdentityServer.PublishedLanguage.Dto namespace Tuitio.PublishedLanguage.Dto
{ {
public class Token public class Token
{ {

View File

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace IdentityServer.PublishedLanguage.Dto namespace Tuitio.PublishedLanguage.Dto
{ {
public class TokenCore public class TokenCore
{ {

View File

@ -1,6 +1,6 @@
using IdentityServer.PublishedLanguage.Dto; using Tuitio.PublishedLanguage.Dto;
namespace IdentityServer.PublishedLanguage.Events namespace Tuitio.PublishedLanguage.Events
{ {
public class AuthenticateUserResult public class AuthenticateUserResult
{ {

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description>Tuitio published language package</Description>
<PackageProjectUrl>https://lab.code-rove.com/gitea/tudor.stanciu/tuitio</PackageProjectUrl>
<RepositoryUrl>https://lab.code-rove.com/gitea/tudor.stanciu/tuitio</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageReleaseNotes>Tuitio published language package</PackageReleaseNotes>
<Version>2.0.0</Version>
</PropertyGroup>
</Project>

View File

@ -1,4 +1,4 @@
namespace IdentityServer.Wrapper.Constants namespace Tuitio.Wrapper.Constants
{ {
internal struct ApiRoutes internal struct ApiRoutes
{ {

View File

@ -1,8 +1,8 @@
using IdentityServer.Wrapper.Models; using Tuitio.Wrapper.Models;
using IdentityServer.Wrapper.Services; using Tuitio.Wrapper.Services;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace IdentityServer.Wrapper namespace Tuitio.Wrapper
{ {
public static class DependencyInjectionExtension public static class DependencyInjectionExtension
{ {

View File

@ -1,4 +1,4 @@
namespace IdentityServer.Wrapper.Models namespace Tuitio.Wrapper.Models
{ {
internal class ServiceConfiguration internal class ServiceConfiguration
{ {

View File

@ -1,7 +1,7 @@
using IdentityServer.PublishedLanguage.Dto; using Tuitio.PublishedLanguage.Dto;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace IdentityServer.Wrapper.Services namespace Tuitio.Wrapper.Services
{ {
public interface IIdentityService public interface IIdentityService
{ {

View File

@ -1,13 +1,13 @@
using IdentityServer.PublishedLanguage.Dto; using Tuitio.PublishedLanguage.Dto;
using IdentityServer.Wrapper.Constants; using Tuitio.Wrapper.Constants;
using IdentityServer.Wrapper.Models; using Tuitio.Wrapper.Models;
using NDB.Extensions.Http; using Netmash.Extensions.Http;
using System; using System;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace IdentityServer.Wrapper.Services namespace Tuitio.Wrapper.Services
{ {
internal class IdentityService : IIdentityService internal class IdentityService : IIdentityService
{ {

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description>Tuitio wrapper</Description>
<PackageReleaseNotes>Tuitio wrapper</PackageReleaseNotes>
<PackageProjectUrl>https://lab.code-rove.com/gitea/tudor.stanciu/tuitio</PackageProjectUrl>
<RepositoryType>Git</RepositoryType>
<RepositoryUrl>https://lab.code-rove.com/gitea/tudor.stanciu/tuitio</RepositoryUrl>
<PackageTags>Tuitio wrapper</PackageTags>
<Version>2.0.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Netmash.Extensions.Http" Version="$(NetmashExtensionsHttpPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tuitio.PublishedLanguage\Tuitio.PublishedLanguage.csproj" />
</ItemGroup>
</Project>

View File

@ -1,9 +1,9 @@
using IdentityServer.Application.Commands; using Tuitio.Application.Commands;
using MediatR; using MediatR;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace IdentityServer.Api.Controllers namespace Tuitio.Api.Controllers
{ {
[ApiController] [ApiController]
[Route("identity")] [Route("identity")]

View File

@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System; using System;
namespace IdentityServer.Api.Controllers namespace Tuitio.Api.Controllers
{ {
[ApiController] [ApiController]
[Route("system")] [Route("system")]

36
src/Tuitio/Dockerfile Normal file
View File

@ -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"]

View File

@ -0,0 +1,8 @@
namespace Tuitio.Extensions
{
internal static class DataTypeExtensions
{
public static string Nullify(this string value)
=> string.IsNullOrWhiteSpace(value) ? null : value;
}
}

View File

@ -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<bool>("Logs:SqlServer:Enabled");
var sqlServerConnection = configuration.GetValue<string>("Logs:SqlServer:Connection");
var seqEnabled = configuration.GetValue<bool>("Logs:Seq:Enabled");
var seqUrl = configuration.GetValue<string>("Logs:Seq:Url");
var seqApiKey = configuration.GetValue<string>("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;
}
}
}

View File

@ -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<IBehaviorService>();
behaviorService.FillTokenStore();
}
}
}

48
src/Tuitio/Program.cs Normal file
View File

@ -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<string>("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();
}
}
}
}

View File

@ -1,6 +1,6 @@
{ {
"profiles": { "profiles": {
"IdentityServer.Api": { "Tuitio.Api": {
"commandName": "Project", "commandName": "Project",
"applicationUrl": "http://localhost:5000", "applicationUrl": "http://localhost:5000",
"environmentVariables": { "environmentVariables": {

View File

@ -1,30 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.4" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="$(MicrosoftExtensionsPackageVersion)" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(MicrosoftExtensionsPackageVersion)" /> <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MicrosoftExtensionsPackageVersion)" /> <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionsPackageVersion)" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="NDB.Extensions.Swagger" Version="$(NDBExtensionsSwaggerPackageVersion)" /> <PackageReference Include="Netmash.Extensions.Swagger" Version="$(NetmashExtensionsSwaggerPackageVersion)" />
<PackageReference Include="NDB.Infrastructure.DatabaseMigration" Version="$(NDBDatabaseMigrationPackageVersion)" /> <PackageReference Include="Netmash.Infrastructure.DatabaseMigration" Version="$(NetmashDatabaseMigrationPackageVersion)" />
<PackageReference Include="Serilog.AspNetCore" Version="$(SerilogPackageVersion)" /> <PackageReference Include="Serilog.AspNetCore" Version="$(SerilogPackageVersion)" />
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsPackageVersion)" />
<PackageReference Include="Serilog.Sinks.Console" Version="$(SerilogSinksConsolePackageVersion)" />
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="$(SerilogSinksMSSqlServerPackageVersion)" /> <PackageReference Include="Serilog.Sinks.MSSqlServer" Version="$(SerilogSinksMSSqlServerPackageVersion)" />
<PackageReference Include="Serilog.Sinks.Seq" Version="$(SerilogSinksSeqPackageVersion)" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="$(AutoMapperExtensionsPackageVersion)" /> <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="$(AutoMapperExtensionsPackageVersion)" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="$(MediatRPackageVersion)" /> <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="$(MediatRPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="$(MicrosoftExtensionsPackageVersion)" /> <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="$(MicrosoftExtensionsPackageVersion)" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\IdentityServer.Application\IdentityServer.Application.csproj" /> <ProjectReference Include="..\Tuitio.Application\Tuitio.Application.csproj" />
<ProjectReference Include="..\IdentityServer.Domain.Data\IdentityServer.Domain.Data.csproj" /> <ProjectReference Include="..\Tuitio.Domain.Data\Tuitio.Domain.Data.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -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
}
}