From d39d5995ab01ad963ad04fbc2549dba1f3958dc6 Mon Sep 17 00:00:00 2001 From: D4VID Date: Fri, 1 Mar 2024 12:18:05 +0100 Subject: [PATCH] Initial commit --- .dockerignore | 25 +++++++++++ .gitignore | 5 +++ .idea/.idea.OAuthServer/.idea/.gitignore | 13 ++++++ .idea/.idea.OAuthServer/.idea/encodings.xml | 4 ++ .idea/.idea.OAuthServer/.idea/indexLayout.xml | 8 ++++ .idea/.idea.OAuthServer/.idea/vcs.xml | 6 +++ OAuthServer.sln | 16 +++++++ OAuthServer/Dockerfile | 23 ++++++++++ OAuthServer/OAuthServer.csproj | 22 ++++++++++ OAuthServer/OAuthServer.http | 6 +++ OAuthServer/Program.cs | 44 +++++++++++++++++++ OAuthServer/Properties/launchSettings.json | 41 +++++++++++++++++ OAuthServer/appsettings.Development.json | 8 ++++ OAuthServer/appsettings.json | 9 ++++ 14 files changed, 230 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 .idea/.idea.OAuthServer/.idea/.gitignore create mode 100644 .idea/.idea.OAuthServer/.idea/encodings.xml create mode 100644 .idea/.idea.OAuthServer/.idea/indexLayout.xml create mode 100644 .idea/.idea.OAuthServer/.idea/vcs.xml create mode 100644 OAuthServer.sln create mode 100644 OAuthServer/Dockerfile create mode 100644 OAuthServer/OAuthServer.csproj create mode 100644 OAuthServer/OAuthServer.http create mode 100644 OAuthServer/Program.cs create mode 100644 OAuthServer/Properties/launchSettings.json create mode 100644 OAuthServer/appsettings.Development.json create mode 100644 OAuthServer/appsettings.json diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..38bece4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/.idea +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..add57be --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +/packages/ +riderModule.iml +/_ReSharper.Caches/ \ No newline at end of file diff --git a/.idea/.idea.OAuthServer/.idea/.gitignore b/.idea/.idea.OAuthServer/.idea/.gitignore new file mode 100644 index 0000000..eec70f1 --- /dev/null +++ b/.idea/.idea.OAuthServer/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/.idea.OAuthServer.iml +/modules.xml +/contentModel.xml +/projectSettingsUpdater.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.OAuthServer/.idea/encodings.xml b/.idea/.idea.OAuthServer/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.OAuthServer/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.OAuthServer/.idea/indexLayout.xml b/.idea/.idea.OAuthServer/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.OAuthServer/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.OAuthServer/.idea/vcs.xml b/.idea/.idea.OAuthServer/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.OAuthServer/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OAuthServer.sln b/OAuthServer.sln new file mode 100644 index 0000000..7aad985 --- /dev/null +++ b/OAuthServer.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OAuthServer", "OAuthServer\OAuthServer.csproj", "{2BC47D06-9A04-4CDE-9A8B-1A2B7730710A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2BC47D06-9A04-4CDE-9A8B-1A2B7730710A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2BC47D06-9A04-4CDE-9A8B-1A2B7730710A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2BC47D06-9A04-4CDE-9A8B-1A2B7730710A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2BC47D06-9A04-4CDE-9A8B-1A2B7730710A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/OAuthServer/Dockerfile b/OAuthServer/Dockerfile new file mode 100644 index 0000000..59a3b24 --- /dev/null +++ b/OAuthServer/Dockerfile @@ -0,0 +1,23 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER $APP_UID +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["OAuthServer/OAuthServer.csproj", "OAuthServer/"] +RUN dotnet restore "OAuthServer/OAuthServer.csproj" +COPY . . +WORKDIR "/src/OAuthServer" +RUN dotnet build "OAuthServer.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "OAuthServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "OAuthServer.dll"] diff --git a/OAuthServer/OAuthServer.csproj b/OAuthServer/OAuthServer.csproj new file mode 100644 index 0000000..009e075 --- /dev/null +++ b/OAuthServer/OAuthServer.csproj @@ -0,0 +1,22 @@ + + + + net8.0 + enable + enable + true + Linux + + + + + + + + + + .dockerignore + + + + diff --git a/OAuthServer/OAuthServer.http b/OAuthServer/OAuthServer.http new file mode 100644 index 0000000..6595015 --- /dev/null +++ b/OAuthServer/OAuthServer.http @@ -0,0 +1,6 @@ +@OAuthServer_HostAddress = http://localhost:5196 + +GET {{OAuthServer_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/OAuthServer/Program.cs b/OAuthServer/Program.cs new file mode 100644 index 0000000..161f695 --- /dev/null +++ b/OAuthServer/Program.cs @@ -0,0 +1,44 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +var summaries = new[] +{ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" +}; + +app.MapGet("/weatherforecast", () => + { + var forecast = Enumerable.Range(1, 5).Select(index => + new WeatherForecast + ( + DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + Random.Shared.Next(-20, 55), + summaries[Random.Shared.Next(summaries.Length)] + )) + .ToArray(); + return forecast; + }) + .WithName("GetWeatherForecast") + .WithOpenApi(); + +app.Run(); + +record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +{ + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); +} \ No newline at end of file diff --git a/OAuthServer/Properties/launchSettings.json b/OAuthServer/Properties/launchSettings.json new file mode 100644 index 0000000..72a93d3 --- /dev/null +++ b/OAuthServer/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:10311", + "sslPort": 44300 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5196", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7205;http://localhost:5196", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/OAuthServer/appsettings.Development.json b/OAuthServer/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/OAuthServer/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/OAuthServer/appsettings.json b/OAuthServer/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/OAuthServer/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}