Skip to content

Commit

Permalink
Merge pull request #1055 from ITfoxtec/test
Browse files Browse the repository at this point in the history
Test
  • Loading branch information
Revsgaard authored Nov 26, 2024
2 parents 0dbed50 + efad6b3 commit 2fcaf6b
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 25 deletions.
3 changes: 2 additions & 1 deletion docs/claim-transform.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ The API has a base URL and the functionality is divided into folders. Currently,

If the base URL for the API is `https://somewhere.org/myclaimsstore` the URL for the `claims` folder will be `https://somewhere.org/myclaimsstore/claims`.

> FoxIDs cloud call the API from the IP address `57.128.60.142`.
> FoxIDs cloud calls your API from the IP address `57.128.60.142`.
*The outgoing IP address can be changed and more can be added over time.*

#### Request
The API call is secured with [HTTP Basic authentication scheme](https://datatracker.ietf.org/doc/html/rfc6749#section-2.3.1) where FoxIDs sends the ID `external_claims` as the username and the configured secret as the password.
Expand Down
3 changes: 2 additions & 1 deletion docs/external-login.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ The API has a base URL and the functionality is divided into folders. Currently,

If the base URL for the API is `https://somewhere.org/mystore` the URL for the `authentication` folder will be `https://somewhere.org/mystore/authentication`.

> FoxIDs cloud call the API from the IP address `57.128.60.142`.
> FoxIDs cloud calls your API from the IP address `57.128.60.142`.
*The outgoing IP address can be changed and more can be added over time.*

### Request
The API call is secured with [HTTP Basic authentication scheme](https://datatracker.ietf.org/doc/html/rfc6749#section-2.3.1) where FoxIDs sends the ID `external_login` as the username and the configured secret as the password.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,21 +271,20 @@ private string GetUpPartyDisplayName(UpPartyLink upParty)
throw;
}
}
private string GetAuthority(string partyName, bool backendCall = false)
private string GetAuthority(string partyName)
{
var routeBinding = RouteBinding;
var useBackendCall = backendCall && !settings.FoxIDsBackendEndpoint.IsNullOrWhiteSpace();
var useValidCustomDomain = !routeBinding.TrackName.Equals(Constants.Routes.MasterTrackName, StringComparison.OrdinalIgnoreCase) && routeBinding.UseCustomDomain;
var useValidCustomDomain = !routeBinding.TrackName.Equals(Constants.Routes.MasterTrackName, StringComparison.OrdinalIgnoreCase) && routeBinding.HasVerifiedCustomDomain;

var urlItems = new List<string>();
if (useBackendCall || !useValidCustomDomain)
if (!useValidCustomDomain)
{
urlItems.Add(routeBinding.TenantName);
}
urlItems.Add(routeBinding.TrackName);
urlItems.Add($"{partyName}(*)");

return UrlCombine.Combine(useBackendCall ? settings.FoxIDsBackendEndpoint : (useValidCustomDomain ? $"{HttpContext.Request.Scheme}://{routeBinding.CustomDomain}" : settings.FoxIDsEndpoint), urlItems.ToArray());
return UrlCombine.Combine(useValidCustomDomain ? $"{HttpContext.Request.Scheme}://{routeBinding.CustomDomain}" : settings.FoxIDsEndpoint, urlItems.ToArray());
}

private async Task<(TokenResponse tokenResponse, ClaimsPrincipal idTokenPrincipal, ClaimsPrincipal accessTokenPrincipal)> AcquireTokensAsync(OidcDownParty mParty, string clientSecret, string nonce, string code)
Expand All @@ -308,7 +307,7 @@ private string GetAuthority(string partyName, bool backendCall = false)
CodeVerifier = mParty.CodeVerifier,
};

(var oidcDiscovery, var jsonWebKeySet) = await oidcDiscoveryReadLogic.GetOidcDiscoveryAndValidateAsync(GetAuthority(mParty.Name, backendCall: true));
(var oidcDiscovery, var jsonWebKeySet) = await oidcDiscoveryReadLogic.GetOidcDiscoveryAndValidateAsync(GetAuthority(mParty.Name));

var requestDictionary = tokenRequest.ToDictionary().AddToDictionary(clientCredentials).AddToDictionary(codeVerifierSecret);

Expand Down
2 changes: 1 addition & 1 deletion src/FoxIDs.Control/FoxIDs.Control.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Version>1.12.4</Version>
<Version>1.12.7</Version>
<RootNamespace>FoxIDs</RootNamespace>
<Authors>Anders Revsgaard</Authors>
<Company>ITfoxtec</Company>
Expand Down
2 changes: 1 addition & 1 deletion src/FoxIDs.ControlClient/FoxIDs.ControlClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Version>1.12.4</Version>
<Version>1.12.7</Version>
<RootNamespace>FoxIDs.Client</RootNamespace>
<Authors>Anders Revsgaard</Authors>
<Company>ITfoxtec</Company>
Expand Down
17 changes: 14 additions & 3 deletions src/FoxIDs.ControlClient/Pages/Components/ELoginUpParty.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
using FoxIDs.Client.Models.ViewModels;
using System;
using System.Linq;
using System.Threading.Tasks;
using FoxIDs.Infrastructure;
using FoxIDs.Client.Services;
using Microsoft.AspNetCore.Components.Forms;
using ITfoxtec.Identity.BlazorWebAssembly.OpenidConnect;
using FoxIDs.Client.Infrastructure.Security;
using FoxIDs.Models.Api;
using System.Collections.Generic;
using ITfoxtec.Identity;
using System.Net.Http;
using System.Linq;

namespace FoxIDs.Client.Pages.Components
{
Expand Down Expand Up @@ -62,7 +61,19 @@ private LoginUpPartyViewModel ToViewModel(LoginUpParty loginUpParty)
{
afterMap.CreateUser.ClaimTransforms = afterMap.CreateUser.ClaimTransforms.MapOAuthClaimTransforms();
}
});

if (afterMap.CreateUser?.Elements?.Count > 0)
{
foreach (var element in afterMap.CreateUser.Elements)
{
if (element.Type == DynamicElementTypes.EmailAndPassword)
{
element.IsStaticRequired = true;
element.Required = true;
}
}
}
});
}

private async Task LoginUpPartyViewModelAfterInitAsync(GeneralLoginUpPartyViewModel loginParty, LoginUpPartyViewModel model)
Expand Down
1 change: 1 addition & 0 deletions src/FoxIDs.ControlClient/Pages/Components/UpPartyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private void InitCreateUser(GeneralLoginUpPartyViewModel generalLoginUpParty)
if (element.Type == DynamicElementTypes.EmailAndPassword)
{
element.IsStaticRequired = true;
element.Required = true;
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/FoxIDs.ControlClient/Shared/Components/FInputToggle.razor
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@

private async Task ToggleCurrentValueAsync()
{
if (Disabled)
{
return;
}

var oldCurrentValue = CurrentValue;
if (CurrentValue == true)
{
Expand Down
2 changes: 1 addition & 1 deletion src/FoxIDs.ControlShared/FoxIDs.ControlShared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Version>1.12.4</Version>
<Version>1.12.7</Version>
<RootNamespace>FoxIDs</RootNamespace>
<Authors>Anders Revsgaard</Authors>
<Company>ITfoxtec</Company>
Expand Down
2 changes: 1 addition & 1 deletion src/FoxIDs.Shared/FoxIDs.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Version>1.12.4</Version>
<Version>1.12.7</Version>
<RootNamespace>FoxIDs</RootNamespace>
<Authors>Anders Revsgaard</Authors>
<Company>ITfoxtec</Company>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,30 @@ private bool GetUseCustomDomain(string[] route, string customDomain)
private async Task<RouteBinding> GetRouteDataAsync(TelemetryScopedLogger scopedLogger, IServiceProvider requestServices, Track.IdKey trackIdKey, bool useCustomDomain, string customDomain, string partyNameAndBinding, bool acceptUnknownParty)
{
var tenant = await GetTenantAsync(requestServices, useCustomDomain, customDomain, trackIdKey.TenantName);

var useCustomDomainVerified = useCustomDomain && !tenant.CustomDomain.IsNullOrEmpty() && tenant.CustomDomainVerified;
if (useCustomDomainVerified)
if (useCustomDomain)
{
trackIdKey.TenantName = tenant.Name;
}

var plan = await GetPlanAsync(requestServices, tenant.PlanName);
if (plan != null)
{
if (useCustomDomainVerified && !plan.EnableCustomDomain)
if (useCustomDomain && !plan.EnableCustomDomain)
{
throw new Exception($"Custom domain is not supported in the '{plan.Name}' plan.");
}
}

var track = await GetTrackAsync(scopedLogger, requestServices, trackIdKey, useCustomDomainVerified);
var track = await GetTrackAsync(scopedLogger, requestServices, trackIdKey, useCustomDomain);
scopedLogger.SetScopeProperty(Constants.Logs.TenantName, trackIdKey.TenantName);
scopedLogger.SetScopeProperty(Constants.Logs.TrackName, trackIdKey.TrackName);
var hasVerifiedCustomDomain = !tenant.CustomDomain.IsNullOrEmpty() && tenant.CustomDomainVerified;
var routeBinding = new RouteBinding
{
UseCustomDomain = useCustomDomainVerified,
HasVerifiedCustomDomain = hasVerifiedCustomDomain,
UseCustomDomain = useCustomDomain && hasVerifiedCustomDomain,
CustomDomain = tenant.CustomDomain,
RouteUrl = $"{(!useCustomDomainVerified ? $"{trackIdKey.TenantName}/" : string.Empty)}{trackIdKey.TrackName}{(!partyNameAndBinding.IsNullOrWhiteSpace() ? $"/{partyNameAndBinding}" : string.Empty)}",
RouteUrl = $"{(!useCustomDomain ? $"{trackIdKey.TenantName}/" : string.Empty)}{trackIdKey.TrackName}{(!partyNameAndBinding.IsNullOrWhiteSpace() ? $"/{partyNameAndBinding}" : string.Empty)}",
PlanName = plan?.Name,
TenantName = trackIdKey.TenantName,
TrackName = trackIdKey.TrackName,
Expand Down
2 changes: 2 additions & 0 deletions src/FoxIDs.Shared/Models/Routes/RouteBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace FoxIDs.Models
{
public class RouteBinding
{
public bool HasVerifiedCustomDomain { get; set; }

public bool UseCustomDomain { get; set; }

public string CustomDomain { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/FoxIDs.SharedBase/FoxIDs.SharedBase.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Version>1.12.4</Version>
<Version>1.12.7</Version>
<RootNamespace>FoxIDs</RootNamespace>
<Authors>Anders Revsgaard</Authors>
<Company>ITfoxtec</Company>
Expand Down
2 changes: 1 addition & 1 deletion src/FoxIDs/FoxIDs.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Version>1.12.4</Version>
<Version>1.12.7</Version>
<RootNamespace>FoxIDs</RootNamespace>
<Authors>Anders Revsgaard</Authors>
<Company>ITfoxtec</Company>
Expand Down
2 changes: 1 addition & 1 deletion src/FoxIDs/Logic/Tracks/SendEmailLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private SendEmail GetSettings()
{
return new SendEmail
{
FromName =settings.Smtp.FromName,
FromName = settings.Smtp.FromName,
FromEmail = settings.Smtp.FromEmail,
SmtpHost = settings.Smtp.Host,
SmtpPort = settings.Smtp.Port,
Expand Down

0 comments on commit 2fcaf6b

Please sign in to comment.