Skip to content

Commit

Permalink
Merge pull request #32 from DFE-Digital/feature/user-login
Browse files Browse the repository at this point in the history
Remove authentication logging
  • Loading branch information
paullocknimble authored Jan 8, 2025
2 parents 5727247 + b0f485e commit 1b08d54
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Schools requiring improvement
</h1>
<a asp-page="/WhichSchoolNeedsHelp" role="button" draggable="false" class="govuk-button" data-module="govuk-button" data-cy="create_new_conversion_btn">
Select a new school
Add a school
</a>
</div>
<div class="govuk-grid-column-one-third">
Expand Down
45 changes: 1 addition & 44 deletions src/Dfe.RegionalImprovementForStandardsAndExcellence/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,50 +65,7 @@
options.MaxModelValidationErrors = 50;
});

builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme).AddMicrosoftIdentityWebApp(options =>
{
builder.Configuration.Bind("AzureAd", options);

options.Events = new OpenIdConnectEvents
{
OnRemoteFailure = context =>
{
// Log error details
Console.WriteLine("Authentication failure: " + context.Failure?.Message);
if (context.Failure?.InnerException != null)
{
Console.WriteLine("Inner exception: " + context.Failure.InnerException.Message);
}

// Redirect to a custom error page or show the error
context.Response.Redirect("/Account/Error");
context.HandleResponse();
return Task.CompletedTask;
},

OnTokenValidated = context =>
{
// Log claims received
var claims = context.Principal?.Claims;
Console.WriteLine("User claims:");
foreach (var claim in claims ?? Enumerable.Empty<System.Security.Claims.Claim>())
{
Console.WriteLine($"{claim.Type}: {claim.Value}");
}

return Task.CompletedTask;
},

OnRedirectToIdentityProvider = context =>
{
// Log the details of the redirect request
Console.WriteLine("Redirecting to Identity Provider");
Console.WriteLine($"Redirect URI: {context.ProtocolMessage.RedirectUri}");
Console.WriteLine($"Request Type: {context.ProtocolMessage.RequestType}");
return Task.CompletedTask;
}
};
});
builder.Services.AddMicrosoftIdentityWebAppAuthentication(config);
builder.Services.AddAuthorization(options => { options.DefaultPolicy = SetupAuthorizationPolicyBuilder().Build(); });

AuthorizationPolicyBuilder SetupAuthorizationPolicyBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"DefaultConnection": ""
},
"AllowedHosts": "*",

"AcademiesApi": {
"ApiKey": "",
"Url": ""
Expand Down

0 comments on commit 1b08d54

Please sign in to comment.