Skip to content

Commit

Permalink
Merge branch 'develop' into feature/pidp-969-Breadcrumb-functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaMantripragada committed Jul 15, 2024
2 parents f9678c4 + b233ec0 commit ef0ee87
Show file tree
Hide file tree
Showing 47 changed files with 1,236 additions and 625 deletions.
63 changes: 20 additions & 43 deletions backend/webapi/Features/Credentials/BCProvider.Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ namespace Pidp.Features.Credentials;

using DomainResults.Common;
using FluentValidation;
using Flurl;
using HybridModelBinding;
using Microsoft.EntityFrameworkCore;
using System.Text.Json.Serialization;
Expand Down Expand Up @@ -38,33 +37,20 @@ public CommandValidator()
}
}

public class CommandHandler : ICommandHandler<Command, IDomainResult<string>>
public class CommandHandler(
IBCProviderClient client,
IEmailService emailService,
IKeycloakAdministrationClient keycloakClient,
ILogger<CommandHandler> logger,
IPlrClient plrClient,
PidpDbContext context) : ICommandHandler<Command, IDomainResult<string>>
{
private readonly IBCProviderClient client;
private readonly IEmailService emailService;
private readonly IKeycloakAdministrationClient keycloakClient;
private readonly ILogger<CommandHandler> logger;
private readonly IPlrClient plrClient;
private readonly PidpDbContext context;
private readonly Url keycloakAdministrationUrl;

public CommandHandler(
IBCProviderClient client,
IEmailService emailService,
IKeycloakAdministrationClient keycloakClient,
ILogger<CommandHandler> logger,
IPlrClient plrClient,
PidpConfiguration config,
PidpDbContext context)
{
this.client = client;
this.emailService = emailService;
this.keycloakClient = keycloakClient;
this.logger = logger;
this.plrClient = plrClient;
this.context = context;
this.keycloakAdministrationUrl = Url.Parse(config.Keycloak.AdministrationUrl);
}
private readonly IBCProviderClient client = client;
private readonly IEmailService emailService = emailService;
private readonly IKeycloakAdministrationClient keycloakClient = keycloakClient;
private readonly ILogger<CommandHandler> logger = logger;
private readonly IPlrClient plrClient = plrClient;
private readonly PidpDbContext context = context;

public async Task<IDomainResult<string>> HandleAsync(Command command)
{
Expand Down Expand Up @@ -136,6 +122,7 @@ public async Task<IDomainResult<string>> HandleAsync(Command command)
var userId = await this.CreateKeycloakUser(party.FirstName, party.LastName, createdUser.UserPrincipalName);
if (userId == null)
{
this.logger.LogKeycloakUserCreationError(command.PartyId, createdUser.UserPrincipalName);
return DomainResult.Failed<string>();
}
await this.keycloakClient.UpdateUser(userId.Value, user => user.SetOpId(party.OpId!));
Expand All @@ -146,7 +133,7 @@ public async Task<IDomainResult<string>> HandleAsync(Command command)
PartyId = command.PartyId,
IdpId = createdUser.UserPrincipalName,
IdentityProvider = IdentityProviders.BCProvider,
DomainEvents = new List<IDomainEvent> { new CollegeLicenceUpdated(command.PartyId) }
DomainEvents = [new CollegeLicenceUpdated(command.PartyId)]
});

await this.context.SaveChangesAsync();
Expand All @@ -162,7 +149,7 @@ public async Task<IDomainResult<string>> HandleAsync(Command command)
Enabled = true,
FirstName = firstName,
LastName = lastName,
Username = this.GenerateMohKeycloakUsername(userPrincipalName)
Username = GenerateMohKeycloakUsername(userPrincipalName)
};
return await this.keycloakClient.CreateUser(newUser);
}
Expand All @@ -171,19 +158,9 @@ public async Task<IDomainResult<string>> HandleAsync(Command command)
/// The expected Ministry of Health Keycloak username for this user. The schema is {IdentityProviderIdentifier}@{IdentityProvider}.
/// Most of our Credentials come to us from Keycloak and so the username is saved as-is in the column IdpId.
/// However, we create BC Provider Credentials directly; so the User Principal Name is saved to the database without the suffix.
/// There are also two inconsistencies with how the MOH Keycloak handles BCP usernames:
/// 1. The username suffix is @bcp rather than @bcprovider_aad.
/// 2. This suffix is only added in Test and Production; there is no suffix at all for BCP Users in the Dev Keycloak.
/// Note that the username suffix for BC Provider is actually @bcp rather than @bcprovider_aad.
/// </summary>
private string GenerateMohKeycloakUsername(string userPrincipalName)
{
if (this.keycloakAdministrationUrl.Host == "user-management-dev.api.hlth.gov.bc.ca")
{
return userPrincipalName;
}

return userPrincipalName + "@bcp";
}
private static string GenerateMohKeycloakUsername(string userPrincipalName) => userPrincipalName + "@bcp";

private async Task SendBCProviderCreationEmail(string partyEmail, string userPrincipalName)
{
Expand All @@ -207,6 +184,6 @@ public static partial class BCProviderCreateLoggingExtensions
[LoggerMessage(2, LogLevel.Error, "Failed to create BC Provider for Party {partyId}, one or more requirements were not met. Party state: {state}.")]
public static partial void LogInvalidState(this ILogger<BCProviderCreate.CommandHandler> logger, int partyId, object state);

[LoggerMessage(3, LogLevel.Error, "Error when attempting to create a Keycloak User for Party {partyId} with username {username}.")]
public static partial void LogKeycloakUserCreationError(this ILogger<BCProviderCreate.CommandHandler> logger, int partyId, string username);
[LoggerMessage(3, LogLevel.Error, "Error when attempting to create a Keycloak User for Party {partyId} from User Principal Name {userPrincipalName}.")]
public static partial void LogKeycloakUserCreationError(this ILogger<BCProviderCreate.CommandHandler> logger, int partyId, string userPrincipalName);
}
4 changes: 2 additions & 2 deletions charts/webapi/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ingress:

resources:
limits:
cpu: 100m
cpu: 50m
memory: 200Mi
requests:
cpu: 15m
Expand Down Expand Up @@ -110,7 +110,7 @@ fluentbit:
runAsUser: 1001
resources:
limits:
cpu: 100m
cpu: 50m
memory: 64Mi
requests:
cpu: 10m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@

.content-header h1 {
font-size: 40px;
line-height: 1.1;
}

.breadcrumb {
Expand Down Expand Up @@ -233,6 +234,7 @@

.content-header h1 {
font-size: 40px;
line-height: 1.1;
}

.content-header {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</nav>
<div class="content-box">
<header>
<h2>BC Provider account information</h2>
<h1>BC Provider account information</h1>
</header>
<div class="content">
<h3>
Expand Down Expand Up @@ -200,7 +200,7 @@ <h3>You get more out of OneHealthID when you sign in with BC Provider.</h3>
</div>
<div class="password-splash">
<div class="password-splash-content">
<div class="text-box">
<div class="text-box" >
<div>
<span class="lets">Let's get started</span>
</div>
Expand Down Expand Up @@ -244,6 +244,11 @@ <h3>You get more out of OneHealthID when you sign in with BC Provider.</h3>

<ng-template #passwordForm>
<form novalidate [formGroup]="formState.form" (ngSubmit)="onSubmit()">
<div class="mobile-image">
<img
ngSrc="/assets/images/bcprovider-account-1000x1103.webp"
fill />
</div>
<h2>Create an account</h2>
<div class="form-content">
<div class="field">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ ol {
--header-margin: unset;
--avatar-size: 4rem;
--content-padding: var(--gap);
--password-splash-display: none;
--password-splash-display: unset;
}
.viewport-medium {
--header-margin: var(--gap) 0 0;
--content-padding: var(--gap) 0;
--password-splash-display: unset;
--password-splash: {
flex: 1;
}
}
.viewport-medium,
.viewport-large {
--header-margin: var(--gap) 0 0;
--content-padding: var(--gap) 0;
Expand Down Expand Up @@ -111,10 +118,11 @@ ol {
}
& header {
margin: var(--header-margin);
& h2 {
margin: 0;
padding: calc(var(--gap) / 2) calc(var(--gap) * 2);
background-color: pidp.$grey-10;
& h1 {
color: #036;
font-size: 3.125rem;
font-weight: 700;
margin-bottom: 0;
}
}
& .content {
Expand Down Expand Up @@ -396,6 +404,11 @@ ol {
& .help-link {
font-size: 0.75rem;
}
& .mobile-image {
& img {
display: none;
}
}
}
.viewport-all.dialog-box {
padding: 24px;
Expand Down Expand Up @@ -443,13 +456,13 @@ ol {
.breadcrumb {
margin: 0px 20px 0px 20px;

img{
img {
margin-right: 2px;
}
span {
font-size: 0.8rem;
}
.home-text{
.home-text {
display: none;
}
fa-icon {
Expand All @@ -475,6 +488,27 @@ ol {
}
}
}
& .mobile-image {
& img {
display: block;
max-width: 100%;
height: auto;
position: relative !important;
}
}
& .form-card {
display: block !important;
}
& .password-splash {
& .password-splash-content {
& .text-box {
display: none !important;
}
& .image {
display: none !important;
}
}
}
}
.viewport-small {
.breadcrumb {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</nav>
<div class="content-box">
<header>
<h2>BC Provider Account Information</h2>
<h1>BC Provider Account Information</h1>
</header>
<div class="content">
<section class="error-card" [class.show-card]="showErrorCard">
Expand Down Expand Up @@ -82,6 +82,11 @@ <h2>BC Provider Account Information</h2>

<ng-template #passwordForm>
<form novalidate [formGroup]="formState.form" (ngSubmit)="onSubmit()">
<div class="mobile-image">
<img
src="/assets/images/bcprovider-account-1000x1103.webp"
fill/>
</div>
<h2>Password reset</h2>
<div class="username">
<h4><strong>Provided username</strong></h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,43 @@
margin-top: 20px;
}
}
& .mobile-image {
& img {
display: block !important;
max-width: 100%;
height: auto;
position: relative !important;
}
}
& .form-card {
display: block !important;
}
& .password-splash {
& .password-splash-content {
& .text-box {
display: none !important;
}
& .image {
display: none !important;
}
}
}
}

.viewport-all {
--header-margin: unset;
--avatar-size: 4rem;
--content-padding: var(--gap);
--password-splash-display: none;
--password-splash-display: unset;
}

.viewport-medium {
--header-margin: var(--gap) 0 0;
--content-padding: var(--gap) 0;
--password-splash-display: unset;
--password-splash: {
flex: 1;
}
}

.viewport-medium,
Expand Down Expand Up @@ -70,10 +100,11 @@

& header {
margin: var(--header-margin);
& h2 {
margin: 0;
padding: calc(var(--gap) / 2) calc(var(--gap) * 2);
background-color: pidp.$grey-10;
& h1 {
color: #036;
font-size: 3.125rem;
font-weight: 700;
margin-bottom: 0;
}
}
& .content {
Expand Down Expand Up @@ -230,6 +261,11 @@
margin-top: var(--gap);
}
}
& .mobile-image {
& img {
display: none;
}
}
}
.viewport-all.dialog-box {
padding: 24px;
Expand Down Expand Up @@ -308,3 +344,13 @@
}
}
}

.viewport-small,
.viewport-xsmall {
& header {
& h1 {
font-size: 40px;
line-height: 1.1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ul>
</nav>
<header>
<h2 class="title">Enrolment</h2>
<h1 class="title">Enrolment</h1>
</header>

<div class="content">
Expand Down
Loading

0 comments on commit ef0ee87

Please sign in to comment.