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);
}
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();
}
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);
}
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());
}
Aggregations