Search in sources :

Example 1 with RateLimitedAuthenticationStrategy

use of org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy in project neo4j by neo4j.

the class FlatFileStressBase method setup.

@Before
public void setup() throws Throwable {
    Config config = Config.defaults();
    LogProvider logProvider = NullLogProvider.getInstance();
    JobScheduler jobScheduler = new NoopJobScheduler();
    userRepository = CommunitySecurityModule.getUserRepository(config, logProvider, getFileSystem());
    roleRepository = EnterpriseSecurityModule.getRoleRepository(config, logProvider, getFileSystem());
    flatFileRealm = new InternalFlatFileRealm(userRepository, roleRepository, new BasicPasswordPolicy(), new RateLimitedAuthenticationStrategy(Clock.systemUTC(), 3), jobScheduler, CommunitySecurityModule.getInitialUserRepository(config, logProvider, getFileSystem()), EnterpriseSecurityModule.getDefaultAdminRepository(config, logProvider, getFileSystem()));
    flatFileRealm.init();
    flatFileRealm.start();
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) Config(org.neo4j.kernel.configuration.Config) InternalFlatFileRealm(org.neo4j.server.security.enterprise.auth.InternalFlatFileRealm) BasicPasswordPolicy(org.neo4j.server.security.auth.BasicPasswordPolicy) Before(org.junit.Before)

Example 2 with RateLimitedAuthenticationStrategy

use of org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy in project neo4j by neo4j.

the class InternalFlatFileRealmIT method setup.

@Before
public void setup() throws Throwable {
    fs = new EvilFileSystem(new EphemeralFileSystemAbstraction());
    userStoreFile = new File("dbms", "auth");
    roleStoreFile = new File("dbms", "roles");
    final UserRepository userRepository = new FileUserRepository(fs, userStoreFile, logProvider);
    final RoleRepository roleRepository = new FileRoleRepository(fs, roleStoreFile, logProvider);
    final UserRepository initialUserRepository = CommunitySecurityModule.getInitialUserRepository(Config.defaults(), logProvider, fs);
    final UserRepository defaultAdminRepository = EnterpriseSecurityModule.getDefaultAdminRepository(Config.defaults(), logProvider, fs);
    final PasswordPolicy passwordPolicy = new BasicPasswordPolicy();
    AuthenticationStrategy authenticationStrategy = new RateLimitedAuthenticationStrategy(Clocks.systemClock(), 3);
    realm = new InternalFlatFileRealm(userRepository, roleRepository, passwordPolicy, authenticationStrategy, true, true, jobScheduler, initialUserRepository, defaultAdminRepository);
    realm.init();
    realm.start();
}
Also used : FileUserRepository(org.neo4j.server.security.auth.FileUserRepository) RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) UserRepository(org.neo4j.server.security.auth.UserRepository) FileUserRepository(org.neo4j.server.security.auth.FileUserRepository) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) AuthenticationStrategy(org.neo4j.server.security.auth.AuthenticationStrategy) RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) PasswordPolicy(org.neo4j.kernel.api.security.PasswordPolicy) BasicPasswordPolicy(org.neo4j.server.security.auth.BasicPasswordPolicy) File(java.io.File) BasicPasswordPolicy(org.neo4j.server.security.auth.BasicPasswordPolicy) Before(org.junit.Before)

Example 3 with RateLimitedAuthenticationStrategy

use of org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy in project neo4j by neo4j.

the class PersonalUserManagerTest method setup.

@Before
public void setup() {
    evilUserManager = new EvilUserManager(new InternalFlatFileRealm(new InMemoryUserRepository(), new InMemoryRoleRepository(), new BasicPasswordPolicy(), new RateLimitedAuthenticationStrategy(Clock.systemUTC(), 3), new InternalFlatFileRealmIT.TestJobScheduler(), new InMemoryUserRepository(), new InMemoryUserRepository()));
    log = spy(Log.class);
    userManager = new PersonalUserManager(evilUserManager, SecurityContext.AUTH_DISABLED, new SecurityLog(log));
}
Also used : RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) Log(org.neo4j.logging.Log) SecurityLog(org.neo4j.server.security.enterprise.log.SecurityLog) SecurityLog(org.neo4j.server.security.enterprise.log.SecurityLog) InMemoryUserRepository(org.neo4j.server.security.auth.InMemoryUserRepository) BasicPasswordPolicy(org.neo4j.server.security.auth.BasicPasswordPolicy) Before(org.junit.Before)

Example 4 with RateLimitedAuthenticationStrategy

use of org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy in project neo4j by neo4j.

the class LdapCachingTest method setup.

@Before
public void setup() throws Throwable {
    SecurityLog securityLog = mock(SecurityLog.class);
    InternalFlatFileRealm internalFlatFileRealm = new InternalFlatFileRealm(new InMemoryUserRepository(), new InMemoryRoleRepository(), new BasicPasswordPolicy(), new RateLimitedAuthenticationStrategy(Clock.systemUTC(), 3), mock(JobScheduler.class), new InMemoryUserRepository(), new InMemoryUserRepository());
    testRealm = new TestRealm(getLdapConfig(), securityLog, new SecureHasher());
    List<Realm> realms = listOf(internalFlatFileRealm, testRealm);
    fakeTicker = new FakeTicker();
    authManager = new MultiRealmAuthManager(internalFlatFileRealm, realms, new ShiroCaffeineCache.Manager(fakeTicker::read, 100, 10), securityLog, false);
    authManager.init();
    authManager.start();
    authManager.getUserManager().newUser("mike", "123", false);
    authManager.getUserManager().newUser("mats", "456", false);
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) SecurityLog(org.neo4j.server.security.enterprise.log.SecurityLog) InMemoryUserRepository(org.neo4j.server.security.auth.InMemoryUserRepository) FakeTicker(com.google.common.testing.FakeTicker) BasicPasswordPolicy(org.neo4j.server.security.auth.BasicPasswordPolicy) Realm(org.apache.shiro.realm.Realm) Before(org.junit.Before)

Example 5 with RateLimitedAuthenticationStrategy

use of org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy 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)

Aggregations

RateLimitedAuthenticationStrategy (org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy)9 BasicPasswordPolicy (org.neo4j.server.security.auth.BasicPasswordPolicy)7 InMemoryUserRepository (org.neo4j.server.security.auth.InMemoryUserRepository)5 Before (org.junit.Before)4 UserRepository (org.neo4j.server.security.auth.UserRepository)4 Config (org.neo4j.configuration.Config)2 PasswordPolicy (org.neo4j.kernel.api.security.PasswordPolicy)2 JobScheduler (org.neo4j.kernel.impl.util.JobScheduler)2 AuthenticationStrategy (org.neo4j.server.security.auth.AuthenticationStrategy)2 SecurityLog (org.neo4j.server.security.enterprise.log.SecurityLog)2 BasicSystemGraphRealm (org.neo4j.server.security.systemgraph.BasicSystemGraphRealm)2 FakeTicker (com.google.common.testing.FakeTicker)1 File (java.io.File)1 Realm (org.apache.shiro.realm.Realm)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1 SecureHasher (org.neo4j.cypher.internal.security.SecureHasher)1 DefaultSystemGraphComponent (org.neo4j.dbms.database.DefaultSystemGraphComponent)1 DefaultSystemGraphInitializer (org.neo4j.dbms.database.DefaultSystemGraphInitializer)1 SystemGraphComponents (org.neo4j.dbms.database.SystemGraphComponents)1