Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Jan 2, 2024
1 parent a3d1b34 commit 97809c3
Show file tree
Hide file tree
Showing 43 changed files with 84 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde

return builder.Build();
}

public static WebApplication ConfigurePipeline(this WebApplication app)
{
IdentityModelEventSource.ShowPII = true;
//JsonWebTokenHandler.DefaultInboundClaimTypeMap.Clear();

app.UseSerilogRequestLogging();

if (_env!.IsDevelopment())
{
app.UseDeveloperExceptionPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde

return builder.Build();
}

public static WebApplication ConfigurePipeline(this WebApplication app)
{
IdentityModelEventSource.ShowPII = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public DelegatedFailApiModel(SingleTenantApiService apiService)
public async Task OnGetAsync()
{
// Must fail
DataFromApi = await _apiService.GetApiDataAsync(true);
DataFromApi = await _apiService.GetApiDataAsync(true);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace RazorMicrosoftEntraID.Pages;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.AspNetCore.Builder;

namespace RazorMicrosoftEntraID;
namespace RazorMicrosoftEntraID;

public static class SecurityHeadersDefinitions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task<List<string>> GetApiDataAsync(bool testIncorrectMultiEndpoint
var responseContent = await response.Content.ReadAsStringAsync();
var data = System.Text.Json.JsonSerializer.Deserialize<List<string>>(responseContent);

if(data != null)
if (data != null)
return data;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using OpeniddictServer.Data;

[assembly: HostingStartup(typeof(OpeniddictServer.Areas.Identity.IdentityHostingStartup))]
[assembly: HostingStartup(typeof(OpeniddictServer.Areas.Identity.IdentityHostingStartup))]
namespace OpeniddictServer.Areas.Identity
{
public class IdentityHostingStartup : IHostingStartup
{
public void Configure(IWebHostBuilder builder)
{
builder.ConfigureServices((context, services) => {
builder.ConfigureServices((context, services) =>
{
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
#nullable disable

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Fido2Identity;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using OpeniddictServer.Data;
using Fido2Identity;
using System.ComponentModel.DataAnnotations;

namespace OpeniddictServer.Areas.Identity.Pages.Account
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
#nullable disable

using System;
using System.Threading.Tasks;
using Fido2Identity;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using OpeniddictServer.Data;

namespace OpeniddictServer.Areas.Identity.Pages.Account.Manage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
#nullable disable

using System;
using Microsoft.AspNetCore.Mvc.Rendering;

namespace OpeniddictServer.Areas.Identity.Pages.Account.Manage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
* the license and the contributors participating to this project.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
Expand All @@ -22,6 +16,7 @@
using OpeniddictServer.Data;
using OpeniddictServer.Helpers;
using OpeniddictServer.ViewModels.Authorization;
using System.Security.Claims;
using static OpenIddict.Abstractions.OpenIddictConstants;

namespace OpeniddictServer.Controllers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace OpeniddictServer.Controllers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
Expand Down
2 changes: 1 addition & 1 deletion MultiIdentityProvider/IdentityProvider/Fido2/Fido2Store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public async Task UpdateCounterAsync(byte[] credentialId, uint counter)
var cred = await _applicationDbContext.FidoStoredCredential
.Where(c => c.DescriptorJson != null && c.DescriptorJson.Contains(credentialIdString)).FirstOrDefaultAsync();

if(cred != null)
if (cred != null)
{
cred.SignatureCounter = counter;
await _applicationDbContext.SaveChangesAsync();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Identity;
using OpeniddictServer.Data;
using System.Threading.Tasks;

namespace Fido2Identity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class FidoStoredCredential
/// </summary>
public virtual string? UserName { get; set; }

Check warning on line 21 in MultiIdentityProvider/IdentityProvider/Fido2/FidoStoredCredential.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

public virtual byte[]? UserId { get; set; }
public virtual byte[]? UserId { get; set; }

Check warning on line 23 in MultiIdentityProvider/IdentityProvider/Fido2/FidoStoredCredential.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

/// <summary>
/// Gets or sets the public key for this user.
Expand All @@ -35,7 +35,7 @@ public class FidoStoredCredential
public virtual uint SignatureCounter { get; set; }

public virtual string? CredType { get; set; }

/// <summary>
/// Gets or sets the registration date for this user.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Text;
using Fido2NetLib;
using Fido2NetLib.Objects;
using Fido2NetLib;
using Microsoft.AspNetCore.Mvc;
using static Fido2NetLib.Fido2;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using OpeniddictServer.Data;
using System.Text;
using static Fido2NetLib.Fido2;

namespace Fido2Identity;

Expand Down Expand Up @@ -66,7 +66,7 @@ public async Task<JsonResult> MakeCredentialOptions([FromForm] string username,
var existingKeys = new List<PublicKeyCredentialDescriptor>();
foreach (var publicKeyCredentialDescriptor in items)
{
if(publicKeyCredentialDescriptor.Descriptor != null)
if (publicKeyCredentialDescriptor.Descriptor != null)
existingKeys.Add(publicKeyCredentialDescriptor.Descriptor);
}

Expand All @@ -81,13 +81,13 @@ public async Task<JsonResult> MakeCredentialOptions([FromForm] string username,
authenticatorSelection.AuthenticatorAttachment = authType.ToEnum<AuthenticatorAttachment>();

var exts = new AuthenticationExtensionsClientInputs
{
Extensions = true,
UserVerificationMethod = true,
{
Extensions = true,
UserVerificationMethod = true,
};

var options = _lib.RequestNewCredential(
user, existingKeys,
user, existingKeys,
authenticatorSelection, attType.ToEnum<AttestationConveyancePreference>(), exts);

// 4. Temporarily store options, session/in-memory cache/redis/db
Expand Down Expand Up @@ -125,7 +125,7 @@ async Task<bool> callback(IsCredentialIdUniqueToUserParams args, CancellationTok
// 2. Verify and make the credentials
var success = await _lib.MakeNewCredentialAsync(attestationResponse, options, callback);

if(success.Result != null)
if (success.Result != null)
{
// 3. Store the credentials in db
await _fido2Store.AddCredentialToUserAsync(options.User, new FidoStoredCredential
Expand All @@ -146,7 +146,7 @@ async Task<bool> callback(IsCredentialIdUniqueToUserParams args, CancellationTok
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
return Json(new CredentialMakeResult("error",
return Json(new CredentialMakeResult("error",
$"Unable to load user with ID '{_userManager.GetUserId(User)}'.",
success.Result));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Text;
using Fido2NetLib;
using Fido2NetLib.Objects;
using Fido2NetLib;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using OpeniddictServer.Data;
using System.Text;

namespace Fido2Identity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Text;
using Fido2NetLib;
using Fido2NetLib.Objects;
using Fido2NetLib;
using Microsoft.AspNetCore.Mvc;
using static Fido2NetLib.Fido2;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using OpeniddictServer.Data;
using System.Text;
using static Fido2NetLib.Fido2;

namespace Fido2Identity;

Expand Down Expand Up @@ -122,7 +122,7 @@ public async Task<JsonResult> MakeCredential([FromBody] AuthenticatorAttestation
// 2. Verify and make the credentials
var success = await _lib.MakeNewCredentialAsync(attestationResponse, options, callback);

if(success.Result != null)
if (success.Result != null)
{
// 3. Store the credentials in db
await _fido2Store.AddCredentialToUserAsync(options.User, new FidoStoredCredential
Expand All @@ -146,8 +146,8 @@ public async Task<JsonResult> MakeCredential([FromBody] AuthenticatorAttestation
if (user == null)
{
return Json(new CredentialMakeResult("error",
$"Unable to load user with ID '{_userManager.GetUserId(User)}'.",
success.Result ));
$"Unable to load user with ID '{_userManager.GetUserId(User)}'.",
success.Result));
}

//await _userManager.SetTwoFactorEnabledAsync(user, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Text;
using Fido2NetLib;
using Fido2NetLib.Objects;
using Fido2NetLib;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using OpeniddictServer.Data;
using System.Text;

namespace Fido2Identity;

Expand Down Expand Up @@ -125,7 +125,7 @@ public async Task<JsonResult> MakeAssertion([FromBody] AuthenticatorAssertionRaw
return storedCreds.Any(c => c.Descriptor != null && c.Descriptor.Id.SequenceEqual(args.CredentialId));
};

if(creds.PublicKey == null)
if (creds.PublicKey == null)
{
throw new InvalidOperationException($"No public key");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde

return builder.Build();
}

public static WebApplication ConfigurePipeline(this WebApplication app)
{
IdentityModelEventSource.ShowPII = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

Expand Down
4 changes: 2 additions & 2 deletions MultiIdentityProvider/IdentityProvider/Worker.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Globalization;
using OpenIddict.Abstractions;
using OpenIddict.Abstractions;
using OpeniddictServer.Data;
using System.Globalization;
using static OpenIddict.Abstractions.OpenIddictConstants;

namespace OpeniddictServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde

return builder.Build();
}

public static WebApplication ConfigurePipeline(this WebApplication app)
{
IdentityModelEventSource.ShowPII = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace RazorAuth0Client.Pages;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.AspNetCore.Builder;

namespace RazorAuth0Client;
namespace RazorAuth0Client;

public static class SecurityHeadersDefinitions
{
Expand Down
Loading

0 comments on commit 97809c3

Please sign in to comment.