Search in sources :

Example 1 with EnterpriseAuthAndUserManager

use of org.neo4j.server.security.enterprise.auth.EnterpriseAuthAndUserManager in project neo4j by neo4j.

the class LdapAuthIT method shouldBeAbleToLoginNativelyAndAuthorizeWithLdap.

@Test
public void shouldBeAbleToLoginNativelyAndAuthorizeWithLdap() throws Throwable {
    // Given
    restartNeo4jServerWithOverriddenSettings(settings -> {
        settings.put(SecuritySettings.auth_providers, SecuritySettings.NATIVE_REALM_NAME + "," + SecuritySettings.LDAP_REALM_NAME);
        settings.put(SecuritySettings.native_authentication_enabled, "true");
        settings.put(SecuritySettings.native_authorization_enabled, "false");
        settings.put(SecuritySettings.ldap_authentication_enabled, "false");
        settings.put(SecuritySettings.ldap_authorization_enabled, "true");
    });
    // When
    String ldapReaderUser = "neo";
    String nativePassword = "nativePassword";
    // this is ugly, but cannot be resolved until embedded gets security
    GraphDatabaseFacade gds = (GraphDatabaseFacade) server.graphDatabaseService();
    EnterpriseAuthAndUserManager authManager = gds.getDependencyResolver().resolveDependency(EnterpriseAuthAndUserManager.class);
    authManager.getUserManager(EnterpriseSecurityContext.AUTH_DISABLED).newUser(ldapReaderUser, nativePassword, false);
    // Then
    // login user 'neo' with native auth provider and test that LDAP authorization gives correct permission
    testAuthWithReaderUser(ldapReaderUser, nativePassword, null);
}
Also used : EnterpriseAuthAndUserManager(org.neo4j.server.security.enterprise.auth.EnterpriseAuthAndUserManager) GraphDatabaseFacade(org.neo4j.kernel.impl.factory.GraphDatabaseFacade) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 GraphDatabaseFacade (org.neo4j.kernel.impl.factory.GraphDatabaseFacade)1 EnterpriseAuthAndUserManager (org.neo4j.server.security.enterprise.auth.EnterpriseAuthAndUserManager)1