use of org.neo4j.server.security.auth.FileUserRepository 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.server.security.auth.FileUserRepository in project neo4j by neo4j.
the class SetDefaultAdminCommandIT method insertUser.
private void insertUser(String username, boolean initial) throws Throwable {
File userFile = getAuthFile(initial ? CommunitySecurityModule.INITIAL_USER_STORE_FILENAME : CommunitySecurityModule.USER_STORE_FILENAME);
FileUserRepository userRepository = new FileUserRepository(fileSystem, userFile, NullLogProvider.getInstance());
userRepository.start();
userRepository.create(new User.Builder(username, Credential.INACCESSIBLE).build());
assertTrue(userRepository.getAllUsernames().contains(username));
userRepository.stop();
userRepository.shutdown();
}
use of org.neo4j.server.security.auth.FileUserRepository in project neo4j by neo4j.
the class SetDefaultAdminCommand method execute.
@Override
public void execute() {
Config config = loadNeo4jConfig();
try {
Path adminIniFile = CommunitySecurityModule.getUserRepositoryFile(config).getParent().resolve(ADMIN_INI);
if (ctx.fs().fileExists(adminIniFile)) {
ctx.fs().deleteFile(adminIniFile);
}
UserRepository admins = new FileUserRepository(ctx.fs(), adminIniFile, NullLogProvider.getInstance());
admins.init();
admins.start();
admins.create(new User.Builder(username, LegacyCredential.INACCESSIBLE).build());
admins.stop();
admins.shutdown();
} catch (Exception e) {
throw new RuntimeException(e);
}
ctx.out().println("default admin user set to '" + username + "'");
}
use of org.neo4j.server.security.auth.FileUserRepository in project neo4j by neo4j.
the class SetInitialPasswordCommandTest method assertAuthIniFile.
private void assertAuthIniFile(String password) throws Throwable {
assertTrue(fileSystem.fileExists(authInitFile));
FileUserRepository userRepository = new FileUserRepository(fileSystem, authInitFile, NullLogProvider.getInstance());
userRepository.start();
User neo4j = userRepository.getUserByName(AuthManager.INITIAL_USER_NAME);
assertNotNull(neo4j);
assertTrue(neo4j.credentials().matchesPassword(UTF8.encode(password)));
assertFalse(neo4j.hasFlag(User.PASSWORD_CHANGE_REQUIRED));
}
use of org.neo4j.server.security.auth.FileUserRepository in project neo4j by neo4j.
the class SetDefaultAdminCommandIT method assertAdminIniFile.
private void assertAdminIniFile(String username) throws Throwable {
Path adminIniFile = homeDir.resolve("data").resolve("dbms").resolve(SetDefaultAdminCommand.ADMIN_INI);
Assertions.assertTrue(fileSystem.fileExists(adminIniFile));
FileUserRepository userRepository = new FileUserRepository(fileSystem, adminIniFile, NullLogProvider.getInstance());
userRepository.start();
assertThat(userRepository.getAllUsernames()).contains(username);
userRepository.stop();
userRepository.shutdown();
}
Aggregations