use of org.neo4j.server.security.systemgraph.UserSecurityGraphComponent in project neo4j by neo4j.
the class BasicSystemGraphRealmIT method startSystemGraphRealm.
private void startSystemGraphRealm() throws Exception {
Config config = Config.defaults(DatabaseManagementSystemSettings.auth_store_directory, testDirectory.directory("data/dbms"));
var systemGraphComponents = new SystemGraphComponents();
systemGraphComponents.register(new DefaultSystemGraphComponent(config));
systemGraphComponents.register(new UserSecurityGraphComponent(Mockito.mock(AbstractSecurityLog.class), oldUsers, initialPassword, config));
var systemGraphSupplier = SystemGraphRealmHelper.makeSystemSupplier(dbManager);
systemGraphInitializer = new DefaultSystemGraphInitializer(systemGraphSupplier, systemGraphComponents);
systemGraphInitializer.start();
RateLimitedAuthenticationStrategy authStrategy = new RateLimitedAuthenticationStrategy(Clock.systemUTC(), config);
realm = new BasicSystemGraphRealm(realmHelper, authStrategy);
}
use of org.neo4j.server.security.systemgraph.UserSecurityGraphComponent in project neo4j by neo4j.
the class UserSecurityGraphComponentTest method setup.
@BeforeAll
static void setup() throws IOException, InvalidArgumentsException {
Config cfg = Config.newBuilder().set(auth_enabled, TRUE).set(allow_single_automatic_upgrade, FALSE).build();
dbms = new TestDatabaseManagementServiceBuilder(directory.homePath()).impermanent().setConfig(cfg).noOpSystemGraphInitializer().build();
system = (GraphDatabaseFacade) dbms.database(SYSTEM_DATABASE_NAME);
DependencyResolver resolver = system.getDependencyResolver();
systemGraphComponents = resolver.resolveDependency(SystemGraphComponents.class);
authManager = resolver.resolveDependency(AuthManager.class);
// Insert a custom SecurityUserComponent instead of the default one,
// in order to have a handle on it and to migrate a 3.5 user
systemGraphComponents.deregister(SECURITY_USER_COMPONENT);
UserRepository oldUsers = new InMemoryUserRepository();
User oldUser = new User.Builder("alice", credentialFor("secret")).withRequiredPasswordChange(false).build();
oldUsers.create(oldUser);
UserRepository initialPassword = new InMemoryUserRepository();
userSecurityGraphComponent = new UserSecurityGraphComponent(CommunitySecurityLog.NULL_LOG, oldUsers, initialPassword, Config.defaults());
systemGraphComponents.register(userSecurityGraphComponent);
// remove DBMS runtime component as it is not a subject of this test
systemGraphComponents.deregister(DBMS_RUNTIME_COMPONENT);
}
Aggregations