Skip to content

Commit

Permalink
Merge commit '29069965b4142ea6a29307e47bda94adcbea267b'
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollo3zehn committed Sep 29, 2023
2 parents 8ef90d3 + 2906996 commit 08b4061
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* 2. Configure docker so that port 22 is exposed (e.g. to port 2222), then test the connection:
* - ssh [email protected] -p 2222
*
* 3. Replace <docker host> below with the actual host
* 3. Replace ensyno.iwes.fraunhofer.de below with the actual host
*/
"name": "Attach to Nexus (Docker)",
"type": "coreclr",
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v2.0.0-beta.20 - 2023-09-29

### Features:
- Simplify containerization.

## v2.0.0-beta.19 - 2023-09-26

### Bugs fixed:
Expand Down
3 changes: 2 additions & 1 deletion src/Nexus/Core/NexusAuthExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using Microsoft.IdentityModel.Tokens;
using Nexus.Core;
using Nexus.Utilities;
using System.IdentityModel.Tokens.Jwt;
using System.Net;
using System.Security.Claims;
Expand All @@ -20,7 +21,7 @@ internal static class NexusAuthExtensions
{
Scheme = "nexus",
DisplayName = "Nexus",
Authority = "http://localhost:5000",
Authority = NexusUtilities.DefaultBaseUrl,
ClientId = "nexus",
ClientSecret = "nexus-secret"
};
Expand Down
6 changes: 3 additions & 3 deletions src/Nexus/Core/NexusIdentityProviderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Nexus.Utilities;
using OpenIddict.Abstractions;
using OpenIddict.Server.AspNetCore;
using System.Security.Claims;
Expand Down Expand Up @@ -201,14 +202,13 @@ public async Task StartAsync(CancellationToken cancellationToken)

if (await manager.FindByClientIdAsync("nexus", cancellationToken) is null)
{
// TODO: http://localhost:5000 should not be hardcoded
await manager.CreateAsync(new OpenIddictApplicationDescriptor
{
ClientId = "nexus",
ClientSecret = "nexus-secret",
DisplayName = "Nexus",
RedirectUris = { new Uri("http://localhost:5000/signin-oidc/nexus") },
PostLogoutRedirectUris = { new Uri("http://localhost:5000/signout-oidc/nexus") },
RedirectUris = { new Uri($"{NexusUtilities.DefaultBaseUrl}/signin-oidc/nexus") },
PostLogoutRedirectUris = { new Uri($"{NexusUtilities.DefaultBaseUrl}/signout-oidc/nexus") },
Permissions =
{
// endpoints
Expand Down
10 changes: 5 additions & 5 deletions src/Nexus/Core/NexusOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ internal record PathsOptions() : NexusOptionsBase
{
public const string Section = "Paths";

public string Config { get; set; } = Path.Combine(PathsOptions.PlatformSpecificRoot, "config");
public string Cache { get; set; } = Path.Combine(PathsOptions.PlatformSpecificRoot, "cache");
public string Catalogs { get; set; } = Path.Combine(PathsOptions.PlatformSpecificRoot, "catalogs");
public string Artifacts { get; set; } = Path.Combine(PathsOptions.PlatformSpecificRoot, "artifacts");
public string Users { get; set; } = Path.Combine(PathsOptions.PlatformSpecificRoot, "users");
public string Config { get; set; } = Path.Combine(PlatformSpecificRoot, "config");
public string Cache { get; set; } = Path.Combine(PlatformSpecificRoot, "cache");
public string Catalogs { get; set; } = Path.Combine(PlatformSpecificRoot, "catalogs");
public string Artifacts { get; set; } = Path.Combine(PlatformSpecificRoot, "artifacts");
public string Users { get; set; } = Path.Combine(PlatformSpecificRoot, "users");
public string Packages { get; set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nexus", "packages");
// GetGlobalPackagesFolder: https://github.com/NuGet/NuGet.Client/blob/0fc58e13683565e7bdf30e706d49e58fc497bbed/src/NuGet.Core/NuGet.Configuration/Utility/SettingsUtility.cs#L225-L254
// GetFolderPath: https://github.com/NuGet/NuGet.Client/blob/1d75910076b2ecfbe5f142227cfb4fb45c093a1e/src/NuGet.Core/NuGet.Common/PathUtil/NuGetEnvironment.cs#L54-L57
Expand Down
19 changes: 19 additions & 0 deletions src/Nexus/Utilities/NexusUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ namespace Nexus.Utilities
{
internal static class NexusUtilities
{
private static string? _defaultBaseUrl;

public static string DefaultBaseUrl
{
get
{
// TODO: make this more dynamic

if (_defaultBaseUrl is null)
_defaultBaseUrl =
Environment.GetEnvironmentVariable("ASPNETCORE_URLS") == "http://+:80" &&
Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") == "true"
? "http://localhost:80"
: "http://localhost:5000";

return _defaultBaseUrl;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Scale(TimeSpan value, TimeSpan samplePeriod) => (int)(value.Ticks / samplePeriod.Ticks);

Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.0.0",
"suffix": "beta.19"
"suffix": "beta.20"
}

0 comments on commit 08b4061

Please sign in to comment.