diff --git a/prdeploy-api/Directory.Build.props b/prdeploy-api/Directory.Build.props new file mode 100644 index 0000000..4cb60ff --- /dev/null +++ b/prdeploy-api/Directory.Build.props @@ -0,0 +1,7 @@ + + + net10.0 + enable + enable + + \ No newline at end of file diff --git a/prdeploy-api/Directory.Packages.props b/prdeploy-api/Directory.Packages.props index b9f72ad..63550ad 100644 --- a/prdeploy-api/Directory.Packages.props +++ b/prdeploy-api/Directory.Packages.props @@ -3,34 +3,34 @@ true - - - - - - + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - + \ No newline at end of file diff --git a/prdeploy-api/Dockerfile b/prdeploy-api/Dockerfile index 25d3793..138993a 100644 --- a/prdeploy-api/Dockerfile +++ b/prdeploy-api/Dockerfile @@ -1,11 +1,12 @@ -FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base WORKDIR /app EXPOSE 8080 -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build ARG VERSION=1.0.0 WORKDIR /src COPY ["nuget.config", "."] +COPY ["Directory.Build.props", "."] COPY ["Directory.Packages.props", "."] COPY ["src/PrDeploy.Api/PrDeploy.Api.csproj", "src/PrDeploy.Api/"] COPY ["src/PrDeploy.Api.Business/PrDeploy.Api.Business.csproj", "src/PrDeploy.Api.Business/"] diff --git a/prdeploy-api/prdeploy-api.sln b/prdeploy-api/prdeploy-api.sln index f0d503c..3d420ed 100644 --- a/prdeploy-api/prdeploy-api.sln +++ b/prdeploy-api/prdeploy-api.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31903.59 +# Visual Studio Version 18 +VisualStudioVersion = 18.3.11222.16 d18.3 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4AE5B802-264E-4EAE-8870-8BEE0E035BA5}" EndProject @@ -22,6 +22,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{2D34 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}" ProjectSection(SolutionItems) = preProject + Directory.Build.props = Directory.Build.props Directory.Packages.props = Directory.Packages.props EndProjectSection EndProject diff --git a/prdeploy-api/src/PrDeploy.Api.Business/Clients/GitHubAuthClient.cs b/prdeploy-api/src/PrDeploy.Api.Business/Clients/GitHubAuthClient.cs index 5711845..269b6a4 100644 --- a/prdeploy-api/src/PrDeploy.Api.Business/Clients/GitHubAuthClient.cs +++ b/prdeploy-api/src/PrDeploy.Api.Business/Clients/GitHubAuthClient.cs @@ -54,6 +54,12 @@ public async Task GetAccessTokenAsync(AccessTokenRequest ac request.AddQueryParameter("client_secret", _gitHubOptions.ClientSecret); request.AddQueryParameter("code", accessTokenRequest.Code); request.AddQueryParameter("redirect_uri", accessTokenRequest.RedirectUrl); + + // Add code_verifier if provided (required for PKCE flow) + if (!string.IsNullOrEmpty(accessTokenRequest.CodeVerifier)) + { + request.AddQueryParameter("code_verifier", accessTokenRequest.CodeVerifier); + } var response = await _client.PostAsync(request); var userInfo = await GetUserInfoAsync(response!.AccessToken); diff --git a/prdeploy-api/src/PrDeploy.Api.Business/PrDeploy.Api.Business.csproj b/prdeploy-api/src/PrDeploy.Api.Business/PrDeploy.Api.Business.csproj index d451d15..819ce4f 100644 --- a/prdeploy-api/src/PrDeploy.Api.Business/PrDeploy.Api.Business.csproj +++ b/prdeploy-api/src/PrDeploy.Api.Business/PrDeploy.Api.Business.csproj @@ -1,11 +1,5 @@ - - net9.0 - enable - enable - - diff --git a/prdeploy-api/src/PrDeploy.Api.Models/PrDeploy.Api.Models.csproj b/prdeploy-api/src/PrDeploy.Api.Models/PrDeploy.Api.Models.csproj index e494587..9ac1a23 100644 --- a/prdeploy-api/src/PrDeploy.Api.Models/PrDeploy.Api.Models.csproj +++ b/prdeploy-api/src/PrDeploy.Api.Models/PrDeploy.Api.Models.csproj @@ -1,11 +1,5 @@ - - net9.0 - enable - enable - - diff --git a/prdeploy-api/src/PrDeploy.Api/Configuration/DotEnv.cs b/prdeploy-api/src/PrDeploy.Api/Configuration/DotEnv.cs index 1f37225..00c47a2 100644 --- a/prdeploy-api/src/PrDeploy.Api/Configuration/DotEnv.cs +++ b/prdeploy-api/src/PrDeploy.Api/Configuration/DotEnv.cs @@ -10,14 +10,22 @@ public static void Load(string filePath) foreach (var line in File.ReadAllLines(filePath)) { - var parts = line.Split( - '=', - StringSplitOptions.RemoveEmptyEntries); + var separator = line.IndexOf("="); - if (parts.Length != 2) + if (separator == -1) + { continue; + } - Environment.SetEnvironmentVariable(parts[0], parts[1].Trim('"')); + var name = line.Substring(0, separator); + var value = line.Substring(separator + 1); + + if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value)) + { + continue; + } + + Environment.SetEnvironmentVariable(name, value.Trim('"')); } } } diff --git a/prdeploy-api/src/PrDeploy.Api/PrDeploy.Api.csproj b/prdeploy-api/src/PrDeploy.Api/PrDeploy.Api.csproj index 0c45b1d..64d70d0 100644 --- a/prdeploy-api/src/PrDeploy.Api/PrDeploy.Api.csproj +++ b/prdeploy-api/src/PrDeploy.Api/PrDeploy.Api.csproj @@ -1,9 +1,6 @@ - + - net9.0 - enable - enable ee2e9923-c992-48f1-b2ad-cdd432e4dafa Linux ..\.. @@ -25,7 +22,6 @@ - diff --git a/prdeploy-api/src/PrDeploy.Api/Program.cs b/prdeploy-api/src/PrDeploy.Api/Program.cs index fef2829..7a02275 100644 --- a/prdeploy-api/src/PrDeploy.Api/Program.cs +++ b/prdeploy-api/src/PrDeploy.Api/Program.cs @@ -53,7 +53,7 @@ .Configure(options => { options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; - options.KnownNetworks.Clear(); + options.KnownIPNetworks.Clear(); options.KnownProxies.Clear(); }) .AddCors(options => diff --git a/prdeploy-api/test/PrDeploy.Api.Tests/Framework/Client/ApiClientException.cs b/prdeploy-api/test/PrDeploy.Api.Tests/Framework/Client/ApiClientException.cs index 8bab210..ce90122 100644 --- a/prdeploy-api/test/PrDeploy.Api.Tests/Framework/Client/ApiClientException.cs +++ b/prdeploy-api/test/PrDeploy.Api.Tests/Framework/Client/ApiClientException.cs @@ -1,6 +1,5 @@ -using System.Runtime.Serialization; +using StrawberryShake; using System.Text; -using StrawberryShake; namespace PrDeploy.Api.Tests.Framework.Client { @@ -15,10 +14,7 @@ public ApiClientException(string message) public ApiClientException(IClientError error) { - if (error is null) - { - throw new ArgumentNullException(nameof(error)); - } + ArgumentNullException.ThrowIfNull(error); Message = error.Message; Errors = new[] { error }; @@ -26,10 +22,7 @@ public ApiClientException(IClientError error) public ApiClientException(params IClientError[] errors) { - if (errors is null) - { - throw new ArgumentNullException(nameof(errors)); - } + ArgumentNullException.ThrowIfNull(errors); if (errors.Length == 0) { @@ -71,15 +64,6 @@ public ApiClientException(IEnumerable errors) { } - protected ApiClientException( - SerializationInfo info, - StreamingContext context) - : base(info, context) - { - Message = base.Message; - Errors ??= Array.Empty(); - } - /// /// The aggregated error message. /// diff --git a/prdeploy-api/test/PrDeploy.Api.Tests/PrDeploy.Api.Tests.csproj b/prdeploy-api/test/PrDeploy.Api.Tests/PrDeploy.Api.Tests.csproj index b31c947..b46ea8f 100644 --- a/prdeploy-api/test/PrDeploy.Api.Tests/PrDeploy.Api.Tests.csproj +++ b/prdeploy-api/test/PrDeploy.Api.Tests/PrDeploy.Api.Tests.csproj @@ -1,10 +1,6 @@  - net9.0 - enable - enable - false $(MSBuildProjectExtensionsPath)berry