Skip to content

Test #1245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2025
Merged

Test #1245

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public GenericOAuthClientSecretUpPartyController(TelemetryScopedLogger logger, I
{
return Ok(new Api.OAuthClientSecretSingleResponse
{
Info = oauthUpParty.Client.ClientSecret.Length > 20 ? oauthUpParty.Client.ClientSecret.Substring(0, 3) : oauthUpParty.Client.ClientSecret,
Info = oauthUpParty.Client.ClientSecret.GetShortSecret(false),
});
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace FoxIDs.Controllers
/// Abstract connection API.
/// </summary>
[TenantScopeAuthorize(Constants.ControlApi.Segment.Party)]
public abstract class GenericPartyApiController<AParty, AClaimTransform, MParty> : ApiController where AParty : Api.INewNameValue, Api.IClaimTransform<AClaimTransform> where MParty : Party where AClaimTransform : Api.ClaimTransform
public abstract class GenericPartyApiController<AParty, AClaimTransform, MParty> : ApiController where AParty : Api.INewNameValue, Api.IClaimTransformRef<AClaimTransform> where MParty : Party where AClaimTransform : Api.ClaimTransform
{
private readonly FoxIDsControlSettings settings;
private readonly TelemetryScopedLogger logger;
Expand Down Expand Up @@ -112,7 +112,6 @@ protected async Task<ActionResult<AParty>> Post(AParty party, Func<AParty, Value

var mUpPartyProfiles = GetMUpPartyProfils(mParty);

if (!(mParty is UpParty upParty ? await validateModelGenericPartyLogic.ValidateModelExtendedUiAsync(ModelState, upParty, false) : true)) return BadRequest(ModelState);
if (!(mParty is UpParty ? validateModelGenericPartyLogic.ValidateModelUpPartyProfiles(ModelState, mUpPartyProfiles) : true)) return BadRequest(ModelState);
if (!(party is Api.IDownParty downParty ? await validateModelGenericPartyLogic.ValidateModelAllowUpPartiesAsync(ModelState, nameof(downParty.AllowUpParties), mParty as DownParty) : true)) return BadRequest(ModelState);
if (!await validateModelGenericPartyLogic.ValidateModelClaimTransformsAsync(ModelState, mParty)) return BadRequest(ModelState);
Expand Down Expand Up @@ -177,7 +176,12 @@ protected async Task<ActionResult<AParty>> Put(AParty party, Func<AParty, ValueT
}
}

if (!(mParty is UpParty upParty ? await validateModelGenericPartyLogic.ValidateModelExtendedUiAsync(ModelState, upParty, true) : true)) return BadRequest(ModelState);
if(mParty is UpParty upParty)
{
await validateModelGenericPartyLogic.HandleModelExtendedUiSecretAsync<AParty, AClaimTransform>(party, upParty);
}
await validateModelGenericPartyLogic.HandleClaimTransformationSecretAsync<AParty, AClaimTransform, MParty>(party, mParty);

if (!(mParty is UpParty ? validateModelGenericPartyLogic.ValidateModelUpPartyProfiles(ModelState, mUpPartyProfiles) : true)) return BadRequest(ModelState);
if (!(party is Api.IDownParty downParty ? await validateModelGenericPartyLogic.ValidateModelAllowUpPartiesAsync(ModelState, nameof(downParty.AllowUpParties), mParty as DownParty) : true)) return BadRequest(ModelState);
if (!await validateModelGenericPartyLogic.ValidateModelClaimTransformsAsync(ModelState, mParty)) return BadRequest(ModelState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public TExternalLoginSecretUpPartyController(TelemetryScopedLogger logger, ITena
{
return Ok(new Api.ExternalLoginSecretResponse
{
Info = extLoginUpParty.Secret.Length > 20 ? extLoginUpParty.Secret.Substring(0, 3) : extLoginUpParty.Secret,
Info = extLoginUpParty.Secret.GetShortSecret(false),
});
}
else
Expand Down
3 changes: 1 addition & 2 deletions src/FoxIDs.Control/Extensions/ClaimExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Azure.Cosmos.Serialization.HybridRow.Schemas;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Api = FoxIDs.Models.Api;
Expand Down
19 changes: 19 additions & 0 deletions src/FoxIDs.Control/Extensions/SecretExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace FoxIDs
{
public static class SecretExtensions
{
/// <summary>
/// Short secret returned in the API
/// </summary>
public static string GetShortSecret(this string secret, bool withDots)
{
if (secret != null && secret.Length > 20)
{
var shortSecret = secret.Substring(0, 3);
return withDots && shortSecret.Length == 3 ? $"{shortSecret}..." : shortSecret;
}

return secret;
}
}
}
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>net9.0</TargetFramework>
<Version>2.0.9</Version>
<Version>2.0.10</Version>
<RootNamespace>FoxIDs</RootNamespace>
<Authors>Anders Revsgaard</Authors>
<Company>FoxIDs</Company>
Expand Down
Loading
Loading