Search in sources :

Example 1 with AuthManager

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

the class AuthorizationEnabledFilter method authenticate.

private SecurityContext authenticate(String username, String password) throws InvalidAuthTokenException {
    AuthManager authManager = authManagerSupplier.get();
    Map<String, Object> authToken = newBasicAuthToken(username, password);
    return authManager.login(authToken);
}
Also used : AuthManager(org.neo4j.kernel.api.security.AuthManager)

Example 2 with AuthManager

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

the class AuthorizationEnabledFilter method authenticate.

private LoginContext authenticate(String username, String password, ClientConnectionInfo connectionInfo) throws InvalidAuthTokenException {
    AuthManager authManager = authManagerSupplier.get();
    Map<String, Object> authToken = newBasicAuthToken(username, password != null ? UTF8.encode(password) : null);
    return authManager.login(authToken, connectionInfo);
}
Also used : AuthManager(org.neo4j.kernel.api.security.AuthManager)

Example 3 with AuthManager

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

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