Search in sources :

Example 1 with PasswordPolicy

use of org.neo4j.kernel.api.security.PasswordPolicy in project neo4j by neo4j.

the class BasicAuthenticationTest method setup.

@Before
public void setup() throws Throwable {
    UserRepository userRepository = new InMemoryUserRepository();
    PasswordPolicy policy = mock(PasswordPolicy.class);
    BasicAuthManager manager = new BasicAuthManager(userRepository, policy, Clocks.systemClock(), userRepository);
    authentication = new BasicAuthentication(manager, manager);
    manager.newUser("bob", "secret", true);
    manager.newUser("mike", "secret2", false);
}
Also used : UserRepository(org.neo4j.server.security.auth.UserRepository) InMemoryUserRepository(org.neo4j.server.security.auth.InMemoryUserRepository) BasicAuthManager(org.neo4j.server.security.auth.BasicAuthManager) PasswordPolicy(org.neo4j.kernel.api.security.PasswordPolicy) InMemoryUserRepository(org.neo4j.server.security.auth.InMemoryUserRepository) Before(org.junit.Before)

Example 2 with PasswordPolicy

use of org.neo4j.kernel.api.security.PasswordPolicy 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 PasswordPolicy

use of org.neo4j.kernel.api.security.PasswordPolicy in project neo4j by neo4j.

the class CommunitySecurityModule method setup.

@Override
public void setup(Dependencies dependencies) throws KernelException {
    Config config = dependencies.config();
    Procedures procedures = dependencies.procedures();
    LogProvider logProvider = dependencies.logService().getUserLogProvider();
    FileSystemAbstraction fileSystem = dependencies.fileSystem();
    final UserRepository userRepository = getUserRepository(config, logProvider, fileSystem);
    final UserRepository initialUserRepository = getInitialUserRepository(config, logProvider, fileSystem);
    final PasswordPolicy passwordPolicy = new BasicPasswordPolicy();
    procedures.writerCreateToken(true);
    BasicAuthManager authManager = new BasicAuthManager(userRepository, passwordPolicy, Clocks.systemClock(), initialUserRepository);
    dependencies.lifeSupport().add(dependencies.dependencySatisfier().satisfyDependency(authManager));
    procedures.registerComponent(UserManager.class, ctx -> authManager, false);
    procedures.registerProcedure(AuthProcedures.class);
}
Also used : LogProvider(org.neo4j.logging.LogProvider) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) PasswordPolicy(org.neo4j.kernel.api.security.PasswordPolicy) Procedures(org.neo4j.kernel.impl.proc.Procedures)

Example 4 with PasswordPolicy

use of org.neo4j.kernel.api.security.PasswordPolicy in project neo4j by neo4j.

the class InternalFlatFileRealmTest method assertSetUsersAndRolesNTimes.

private void assertSetUsersAndRolesNTimes(boolean usersChanged, boolean rolesChanged, int nSetUsers, int nSetRoles) throws Throwable {
    final UserRepository userRepository = mock(UserRepository.class);
    final RoleRepository roleRepository = mock(RoleRepository.class);
    final UserRepository initialUserRepository = mock(UserRepository.class);
    final UserRepository defaultAdminRepository = mock(UserRepository.class);
    final PasswordPolicy passwordPolicy = new BasicPasswordPolicy();
    AuthenticationStrategy authenticationStrategy = new RateLimitedAuthenticationStrategy(Clocks.systemClock(), 3);
    InternalFlatFileRealmIT.TestJobScheduler jobScheduler = new InternalFlatFileRealmIT.TestJobScheduler();
    InternalFlatFileRealm realm = new InternalFlatFileRealm(userRepository, roleRepository, passwordPolicy, authenticationStrategy, jobScheduler, initialUserRepository, defaultAdminRepository);
    when(userRepository.getPersistedSnapshot()).thenReturn(new ListSnapshot<>(10L, Collections.emptyList(), usersChanged));
    when(userRepository.getUserByName(any())).thenReturn(new User.Builder().build());
    when(roleRepository.getPersistedSnapshot()).thenReturn(new ListSnapshot<>(10L, Collections.emptyList(), rolesChanged));
    when(roleRepository.getRoleByName(anyString())).thenReturn(new RoleRecord(""));
    realm.init();
    realm.start();
    jobScheduler.scheduledRunnable.run();
    verify(userRepository, times(nSetUsers)).setUsers(any());
    verify(roleRepository, times(nSetRoles)).setRoles(any());
}
Also used : RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) AuthenticationStrategy(org.neo4j.server.security.auth.AuthenticationStrategy) RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) UserRepository(org.neo4j.server.security.auth.UserRepository) InMemoryUserRepository(org.neo4j.server.security.auth.InMemoryUserRepository) PasswordPolicy(org.neo4j.kernel.api.security.PasswordPolicy) BasicPasswordPolicy(org.neo4j.server.security.auth.BasicPasswordPolicy) BasicPasswordPolicy(org.neo4j.server.security.auth.BasicPasswordPolicy)

Aggregations

PasswordPolicy (org.neo4j.kernel.api.security.PasswordPolicy)4 UserRepository (org.neo4j.server.security.auth.UserRepository)3 Before (org.junit.Before)2 AuthenticationStrategy (org.neo4j.server.security.auth.AuthenticationStrategy)2 BasicPasswordPolicy (org.neo4j.server.security.auth.BasicPasswordPolicy)2 InMemoryUserRepository (org.neo4j.server.security.auth.InMemoryUserRepository)2 RateLimitedAuthenticationStrategy (org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy)2 File (java.io.File)1 EphemeralFileSystemAbstraction (org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1 Config (org.neo4j.kernel.configuration.Config)1 Procedures (org.neo4j.kernel.impl.proc.Procedures)1 LogProvider (org.neo4j.logging.LogProvider)1 BasicAuthManager (org.neo4j.server.security.auth.BasicAuthManager)1 FileUserRepository (org.neo4j.server.security.auth.FileUserRepository)1