Search in sources :

Example 1 with UserSecurityGraphComponent

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);
}
Also used : SystemGraphComponents(org.neo4j.dbms.database.SystemGraphComponents) DefaultSystemGraphInitializer(org.neo4j.dbms.database.DefaultSystemGraphInitializer) RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) DefaultSystemGraphComponent(org.neo4j.dbms.database.DefaultSystemGraphComponent) UserSecurityGraphComponent(org.neo4j.server.security.systemgraph.UserSecurityGraphComponent) Config(org.neo4j.configuration.Config) BasicSystemGraphRealm(org.neo4j.server.security.systemgraph.BasicSystemGraphRealm)

Example 2 with UserSecurityGraphComponent

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);
}
Also used : SystemGraphComponents(org.neo4j.dbms.database.SystemGraphComponents) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) InMemoryUserRepository(org.neo4j.server.security.auth.InMemoryUserRepository) UserRepository(org.neo4j.server.security.auth.UserRepository) User(org.neo4j.kernel.impl.security.User) UserSecurityGraphComponent(org.neo4j.server.security.systemgraph.UserSecurityGraphComponent) AuthManager(org.neo4j.kernel.api.security.AuthManager) Config(org.neo4j.configuration.Config) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) InMemoryUserRepository(org.neo4j.server.security.auth.InMemoryUserRepository) DependencyResolver(org.neo4j.common.DependencyResolver) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

Config (org.neo4j.configuration.Config)2 SystemGraphComponents (org.neo4j.dbms.database.SystemGraphComponents)2 UserSecurityGraphComponent (org.neo4j.server.security.systemgraph.UserSecurityGraphComponent)2 BeforeAll (org.junit.jupiter.api.BeforeAll)1 DependencyResolver (org.neo4j.common.DependencyResolver)1 DefaultSystemGraphComponent (org.neo4j.dbms.database.DefaultSystemGraphComponent)1 DefaultSystemGraphInitializer (org.neo4j.dbms.database.DefaultSystemGraphInitializer)1 AuthManager (org.neo4j.kernel.api.security.AuthManager)1 User (org.neo4j.kernel.impl.security.User)1 InMemoryUserRepository (org.neo4j.server.security.auth.InMemoryUserRepository)1 RateLimitedAuthenticationStrategy (org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy)1 UserRepository (org.neo4j.server.security.auth.UserRepository)1 BasicSystemGraphRealm (org.neo4j.server.security.systemgraph.BasicSystemGraphRealm)1 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)1