Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add RoboForm importer (#1601)

Leendert de Borstba0357a7d5ad
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceRoboform.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceRoboform.razor
new file mode 100644
index 000000000..7884876ed
--- /dev/null
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceRoboform.razor
@@ -0,0 +1,25 @@
+@using AliasVault.ImportExport.Models
+@using AliasVault.ImportExport.Importers
+@using Microsoft.Extensions.Localization
+@inject NavigationManager NavigationManager
+@inject GlobalNotificationService GlobalNotificationService
+@inject IStringLocalizerFactory LocalizerFactory
+@inject ILogger<ImportServiceRoboform> Logger
+
+<ImportServiceCard
+ ServiceName="RoboForm"
+ Description="@Localizer["RoboformDescription"]"
+ LogoUrl="img/importers/roboform.svg"
+ ProcessFileCallback="ProcessFile">
+ <p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["RoboformInstructionsPart1"]</p>
+ <p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["RoboformInstructionsPart2"]</p>
+</ImportServiceCard>
+
+@code {
+ private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
+
+ private static async Task<List<ImportedCredential>> ProcessFile(string fileContents)
+ {
+ return await RoboformImporter.ImportFromCsvAsync(fileContents);
+ }
+}
diff --git a/apps/server/AliasVault.Client/wwwroot/img/importers/roboform.svg b/apps/server/AliasVault.Client/wwwroot/img/importers/roboform.svg
new file mode 100644
index 000000000..de24a2341
--- /dev/null
+++ b/apps/server/AliasVault.Client/wwwroot/img/importers/roboform.svg
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+ <!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
+<svg width="800px" height="800px" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
+ <style>
+ .st1{fill:#fff}
+ </style>
+ <g id="Icon">
+ <circle cx="512" cy="512" r="512" style="fill:#5bb254"/>
+ <path class="st1" d="M308 656c-28.3 0-52 25.1-52 56s23.7 56 52 56h408c28.3 0 52-25.1 52-56s-23.7-56-52-56H308zm392-400H324c-37.2 0-68 30.8-68 68v232c0 37.1 30.9 68 68 68h376c37.2 0 68-30.8 68-68V324c0-37.2-30.8-68-68-68zm12 276c0 19.9-16.1 36-36 36H348c-19.9 0-36-16.1-36-36V348c0-19.9 16.1-36 36-36h328c19.9 0 36 16.1 36 36v184z"/>
+ <path class="st1" d="M604.1 384.2c-30.2 0-54.6 24.5-54.6 54.6 0 30.2 24.5 54.6 54.6 54.6 30.2 0 54.6-24.5 54.6-54.6s-24.4-54.6-54.6-54.6m-181.4 0c-30.2 0-54.6 24.5-54.6 54.6 0 30.2 24.5 54.6 54.6 54.6 30.2 0 54.6-24.5 54.6-54.6s-24.4-54.6-54.6-54.6"/>
+ </g>
+</svg>
\ No newline at end of file
diff --git a/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj b/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
index 4a80949a6..c29a523a1 100644
--- a/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
+++ b/apps/server/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj
@@ -74,6 +74,7 @@
<EmbeddedResource Include="TestData\Exports\lastpass.csv" />
<EmbeddedResource Include="TestData\Exports\nordpass.csv" />
<EmbeddedResource Include="TestData\Exports\aliasvault_mobile_app_export.csv" />
+ <EmbeddedResource Include="TestData\Exports\roboform.csv" />
</ItemGroup>
</Project>
diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/roboform.csv b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/roboform.csv
new file mode 100644
index 000000000..376f772a4
--- /dev/null
+++ b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/roboform.csv
@@ -0,0 +1,5 @@
+Name,Url,MatchUrl,Login,Pwd,Note,Folder,RfFieldsV2
+Com,https://www.example.com.com,https://www.example.com,username1,password1,,,"User ID$,,,txt,username1","Password$,,,pwd,password1","Test,,,txt,Test"
+Example,https://www.example.com,https://www.example.com,exampleusername,examplepassword,Examplenote,,"User ID$,,,txt,exampleusername","Password$,,,pwd,examplepassword"
+Safenotename,,,,,Safenote content example here,
+Business,https://www.business.com,https://www.business.com,businessusername,businesspassword,,/Business,"User ID$,,,txt,businessusername","Password$,,,pwd,businesspassword"
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Importers/RoboformImporter.cs b/apps/server/Utilities/AliasVault.ImportExport/Importers/RoboformImporter.cs
new file mode 100644
index 000000000..71ce112e5
--- /dev/null
+++ b/apps/server/Utilities/AliasVault.ImportExport/Importers/RoboformImporter.cs
@@ -0,0 +1,86 @@
+//-----------------------------------------------------------------------
+// <copyright file="RoboformImporter.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.ImportExport.Importers;
+
+using AliasVault.ImportExport.Models;
+using AliasVault.ImportExport.Models.Imports;
+
+/// <summary>
+/// Imports credentials from RoboForm.
+/// </summary>
+public static class RoboformImporter
+{
+ /// <summary>
+ /// Imports RoboForm CSV file and converts contents to list of ImportedCredential model objects.
+ /// </summary>
+ /// <param name="fileContent">The content of the CSV file.</param>
+ /// <returns>The imported list of ImportedCredential objects.</returns>
+ public static async Task<List<ImportedCredential>> ImportFromCsvAsync(string fileContent)
+ {
+ var records = await BaseImporter.ImportCsvDataAsync<RoboformCsvRecord>(fileContent);
+
+ var credentials = new List<ImportedCredential>();
+ foreach (var record in records)
+ {
+ var itemType = DetermineItemType(record);
+
+ var credential = new ImportedCredential
+ {
+ ServiceName = record.Name,
+ ServiceUrls = BaseImporter.ParseUrls(record.Url),
+ Username = record.Login,
+ Password = record.Password,
+ Notes = record.Note,
+ FolderPath = NormalizeFolderPath(record.Folder),
+ ItemType = itemType,
+ };
+
+ credentials.Add(credential);
+ }
+
+ return credentials;
+ }
+
+ /// <summary>
+ /// Normalizes the folder path from RoboForm format.
+ /// RoboForm uses paths like "/Business" - we remove the leading slash.
+ /// </summary>
+ /// <param name="folder">The folder path from RoboForm.</param>
+ /// <returns>The normalized folder path, or null if empty.</returns>
+ private static string? NormalizeFolderPath(string? folder)
+ {
+ if (string.IsNullOrWhiteSpace(folder))
+ {
+ return null;
+ }
+
+ // Remove leading slash if present
+ var normalized = folder.TrimStart('/');
+ return string.IsNullOrWhiteSpace(normalized) ? null : normalized;
+ }
+
+ /// <summary>
+ /// Determines the item type based on the RoboForm record.
+ /// RoboForm marks secure notes by having no URL, login, or password.
+ /// </summary>
+ /// <param name="record">The RoboForm CSV record.</param>
+ /// <returns>The determined item type.</returns>
+ private static ImportedItemType DetermineItemType(RoboformCsvRecord record)
+ {
+ // If there's no URL, login, and password, it's likely a secure note
+ if (string.IsNullOrWhiteSpace(record.Url) &&
+ string.IsNullOrWhiteSpace(record.Login) &&
+ string.IsNullOrWhiteSpace(record.Password) &&
+ !string.IsNullOrWhiteSpace(record.Note))
+ {
+ return ImportedItemType.Note;
+ }
+
+ return ImportedItemType.Login;
+ }
+}
diff --git a/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/RoboformCsvRecord.cs b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/RoboformCsvRecord.cs
new file mode 100644
index 000000000..860dbb676
--- /dev/null
+++ b/apps/server/Utilities/AliasVault.ImportExport/Models/Imports/RoboformCsvRecord.cs
@@ -0,0 +1,66 @@
+//-----------------------------------------------------------------------
+// <copyright file="RoboformCsvRecord.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.ImportExport.Models.Imports;
+
+using CsvHelper.Configuration.Attributes;
+
+/// <summary>
+/// Represents a RoboForm CSV record that is being imported from a RoboForm CSV export file.
+/// </summary>
+public class RoboformCsvRecord
+{
+ /// <summary>
+ /// Gets or sets the name of the item.
+ /// </summary>
+ [Name("Name")]
+ public string Name { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the URL of the item.
+ /// </summary>
+ [Name("Url")]
+ public string? Url { get; set; }
+
+ /// <summary>
+ /// Gets or sets the match URL used for auto-fill matching.
+ /// </summary>
+ [Name("MatchUrl")]
+ public string? MatchUrl { get; set; }
+
+ /// <summary>
+ /// Gets or sets the login/username.
+ /// </summary>
+ [Name("Login")]
+ public string? Login { get; set; }
+
+ /// <summary>
+ /// Gets or sets the password.
+ /// </summary>
+ [Name("Pwd")]
+ public string? Password { get; set; }
+
+ /// <summary>
+ /// Gets or sets any notes.
+ /// </summary>
+ [Name("Note")]
+ public string? Note { get; set; }
+
+ /// <summary>
+ /// Gets or sets the folder path (e.g., "/Business").
+ /// </summary>
+ [Name("Folder")]
+ public string? Folder { get; set; }
+
+ /// <summary>
+ /// Gets or sets the RoboForm fields version 2 data.
+ /// This contains additional custom fields in a specific format.
+ /// </summary>
+ [Name("RfFieldsV2")]
+ [Optional]
+ public string? RfFieldsV2 { get; set; }
+}