Skip to content

Commit

Permalink
PB-34204_22-Create-RELEASE_NOTESmd-in-the-windows-app-repos_Pierre-Co…
Browse files Browse the repository at this point in the history
…lart
  • Loading branch information
scadra committed Jul 26, 2024
1 parent 26011ce commit 32ee0d3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
14 changes: 14 additions & 0 deletions passbolt/Controllers/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public async Task BackgroundNavigationStarting(WebView2 sender, CoreWebView2Navi

if (currentAccountMetaData != null)
{
//When the application start the main controller save the metadata and init the httpservice trusted domain
this.httpService.setTrustedDomain(currentAccountMetaData.domain);
//If the credential locker is not empty we launch the authentication applications.
await LocalFolderService.Instance.CreateRenderedIndex("index-auth.html", "rendered-auth", "ext_authentication.min.css", currentAccountMetaData.domain);
await LocalFolderService.Instance.CreateBackgroundIndex("index-auth.html", "background-auth", currentAccountMetaData.domain);
Expand All @@ -101,6 +103,18 @@ public async Task BackgroundNavigationStarting(WebView2 sender, CoreWebView2Navi
await this.LoadWebviews();
this.SetWebviewSettings(webviewBackground);
}
//When credentials are saved from import and we navigate to auth application we init the trusted domain to check API calls
if(currentAccountMetaData == null && this.backgroundNavigationService.IsAuthApplication(args.Uri))
{
currentAccountMetaData = await this.credentialLockerService.GetAccountMetadata();
this.httpService.setTrustedDomain(currentAccountMetaData.domain);
}
//In case of we are facing to an authentication error during import we delete trusted domain from the HTTPServices
if (currentAccountMetaData != null && this.backgroundNavigationService.IsImportApplication(args.Uri))
{
currentAccountMetaData = null;
this.httpService.unSetTrustedDomain();
}
}

/// <summary>
Expand Down
22 changes: 21 additions & 1 deletion passbolt/Services/HttpService/HttpService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public HttpService()
/// <param name="sender"></param>
/// <param name="webviewRequest"></param>
/// <exception cref="UnauthorizedAPICallException"></exception>
public async void CheckAPICall(CoreWebView2 sender, CoreWebView2WebResourceRequestedEventArgs webviewRequest)
public void CheckAPICall(CoreWebView2 sender, CoreWebView2WebResourceRequestedEventArgs webviewRequest)
{
if(this.trustedDomain == null)
{
Expand All @@ -70,6 +70,26 @@ public async void CheckAPICall(CoreWebView2 sender, CoreWebView2WebResourceReque
{
throw new UnauthorizedAPICallException();
}
}

/// <summary>
/// Init the trusted domain if this one is not set yet
/// </summary>
/// <param name="trustedDomainFromMetadata"></param>
public void setTrustedDomain(String trustedDomainFromMetadata)
{
// Only init trustedDomain if not set yet
if(this.trustedDomain == null)
{
this.trustedDomain = trustedDomainFromMetadata;
}
}
/// <summary>
/// Unset the trusted domain
/// </summary>
public void unSetTrustedDomain()
{
this.trustedDomain = null;
}

/// <summary>
Expand Down
13 changes: 11 additions & 2 deletions passbolt/Services/NavigationService/BackgroundNavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,17 @@ public void SetPreviousNavigation(string url)
public bool IsAuthApplication(string url)
{
return url == $"https://{this.trustedUrl}/Background/index-auth.html";
}

}

/// <summary>
/// Check if background webview is running the import file
/// </summary>
/// <returns></returns>
public bool IsImportApplication(string url)
{
return url == $"https://{this.trustedUrl}/Background/index-import.html";
}

/// <summary>
/// Check navigation history to verify if workspace loading comes from importation
/// </summary>
Expand Down

0 comments on commit 32ee0d3

Please sign in to comment.