1
0
mirror of https://github.com/bitwarden/server synced 2025-12-12 14:23:38 +00:00

Generate valid keys using rust

This commit is contained in:
Hinton
2025-07-31 10:20:53 +02:00
parent 072f9f2278
commit 75f11f68ac
7 changed files with 108 additions and 40 deletions

View File

@@ -1,7 +1,10 @@
using Bit.Infrastructure.EntityFramework.Repositories;
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Infrastructure.EntityFramework.Repositories;
using Bit.Seeder.Recipes;
using CommandDotNet;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Bit.DbSeederUtility;
@@ -26,14 +29,17 @@ public class Program
// Create service provider with necessary services
var services = new ServiceCollection();
ServiceCollectionExtension.ConfigureServices(services);
services.TryAddScoped<IPasswordHasher<User>, PasswordHasher<User>>();
var serviceProvider = services.BuildServiceProvider();
// Get a scoped DB context
using var scope = serviceProvider.CreateScope();
var scopedServices = scope.ServiceProvider;
var db = scopedServices.GetRequiredService<DatabaseContext>();
var passwordHasher = scopedServices.GetRequiredService<IPasswordHasher<User>>();
var recipe = new OrganizationWithUsersRecipe(db);
var recipe = new OrganizationWithUsersRecipe(db, passwordHasher);
recipe.Seed(name, users, domain);
}
}