Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Oct 5, 2024
1 parent 7593781 commit cf2af28
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions server/Cae/WebApiMsalUiRequiredException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Net.Http.Headers;
using System.Net;
using System.Net;
using System.Net.Http.Headers;

namespace BffMicrosoftEntraExternalID.Server;

Expand Down
4 changes: 1 addition & 3 deletions server/Models/UserInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;

namespace BffMicrosoftEntraExternalID.Server.Models;
namespace BffMicrosoftEntraExternalID.Server.Models;

public class UserInfo
{
Expand Down
4 changes: 2 additions & 2 deletions server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
// If you use persistent cache, you do not require this.
// You can also return the 403 with the required scopes, this needs special handling for ajax calls
// The check is only for single scopes
services.Configure<CookieAuthenticationOptions>(CookieAuthenticationDefaults.AuthenticationScheme,
options => options.Events = new RejectSessionCookieWhenAccountNotInCacheEvents(initialScopes));
services.Configure<CookieAuthenticationOptions>(CookieAuthenticationDefaults.AuthenticationScheme,
options => options.Events = new RejectSessionCookieWhenAccountNotInCacheEvents(initialScopes));

services.AddControllersWithViews(options =>
options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute()));
Expand Down
4 changes: 2 additions & 2 deletions server/RejectSessionCookieWhenAccountNotInCacheEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async override Task ValidatePrincipal(CookieValidatePrincipalContext cont
var tokenAcquisition = context.HttpContext.RequestServices
.GetRequiredService<ITokenAcquisition>();

string token = await tokenAcquisition.GetAccessTokenForUserAsync(scopes: _downstreamScopes,
string token = await tokenAcquisition.GetAccessTokenForUserAsync(scopes: _downstreamScopes,
user: context.Principal);
}
catch (MicrosoftIdentityWebChallengeUserException ex) when (AccountDoesNotExitInTokenCache(ex))
Expand All @@ -31,7 +31,7 @@ public async override Task ValidatePrincipal(CookieValidatePrincipalContext cont

private static bool AccountDoesNotExitInTokenCache(MicrosoftIdentityWebChallengeUserException ex)
{
return ex.InnerException is MsalUiRequiredException
return ex.InnerException is MsalUiRequiredException
&& (ex.InnerException as MsalUiRequiredException)!.ErrorCode == "user_null";
}
}
2 changes: 1 addition & 1 deletion server/SecurityHeadersDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public static class SecurityHeadersDefinitions
{
public static HeaderPolicyCollection GetHeaderPolicyCollection(bool isDev, string? idpHost)
{
if(idpHost == null)
if (idpHost == null)
{
throw new ArgumentNullException(nameof(idpHost));
}
Expand Down

0 comments on commit cf2af28

Please sign in to comment.