Search in sources :

Example 1 with BasicSystemGraphRealm

use of org.neo4j.server.security.systemgraph.BasicSystemGraphRealm in project neo4j by neo4j.

the class BasicSystemGraphRealmIT method startSystemGraphRealm.

private void startSystemGraphRealm() throws Exception {
    Config config = Config.defaults(DatabaseManagementSystemSettings.auth_store_directory, testDirectory.directory("data/dbms"));
    var systemGraphComponents = new SystemGraphComponents();
    systemGraphComponents.register(new DefaultSystemGraphComponent(config));
    systemGraphComponents.register(new UserSecurityGraphComponent(Mockito.mock(AbstractSecurityLog.class), oldUsers, initialPassword, config));
    var systemGraphSupplier = SystemGraphRealmHelper.makeSystemSupplier(dbManager);
    systemGraphInitializer = new DefaultSystemGraphInitializer(systemGraphSupplier, systemGraphComponents);
    systemGraphInitializer.start();
    RateLimitedAuthenticationStrategy authStrategy = new RateLimitedAuthenticationStrategy(Clock.systemUTC(), config);
    realm = new BasicSystemGraphRealm(realmHelper, authStrategy);
}
Also used : SystemGraphComponents(org.neo4j.dbms.database.SystemGraphComponents) DefaultSystemGraphInitializer(org.neo4j.dbms.database.DefaultSystemGraphInitializer) RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) DefaultSystemGraphComponent(org.neo4j.dbms.database.DefaultSystemGraphComponent) UserSecurityGraphComponent(org.neo4j.server.security.systemgraph.UserSecurityGraphComponent) Config(org.neo4j.configuration.Config) BasicSystemGraphRealm(org.neo4j.server.security.systemgraph.BasicSystemGraphRealm)

Example 2 with BasicSystemGraphRealm

use of org.neo4j.server.security.systemgraph.BasicSystemGraphRealm in project neo4j by neo4j.

the class SecurityContextDescriptionTest method setup.

@BeforeEach
void setup() throws Throwable {
    SystemGraphRealmHelper realmHelper = spy(new SystemGraphRealmHelper(null, new SecureHasher()));
    BasicSystemGraphRealm realm = new BasicSystemGraphRealm(realmHelper, new RateLimitedAuthenticationStrategy(Clocks.systemClock(), Config.defaults()));
    User user = new User.Builder("johan", credentialFor("bar")).withId("id").build();
    doReturn(user).when(realmHelper).getUser("johan");
    context = realm.login(authToken("johan", "bar"), EMBEDDED_CONNECTION).authorize(LoginContext.IdLookup.EMPTY, DEFAULT_DATABASE_NAME, CommunitySecurityLog.NULL_LOG);
}
Also used : User(org.neo4j.kernel.impl.security.User) SecureHasher(org.neo4j.cypher.internal.security.SecureHasher) BasicSystemGraphRealm(org.neo4j.server.security.systemgraph.BasicSystemGraphRealm) SystemGraphRealmHelper(org.neo4j.server.security.systemgraph.SystemGraphRealmHelper) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with BasicSystemGraphRealm

use of org.neo4j.server.security.systemgraph.BasicSystemGraphRealm in project neo4j by neo4j.

the class CommunitySecurityModule method setup.

@Override
public void setup() {
    Supplier<GraphDatabaseService> systemSupplier = () -> {
        DatabaseManager<?> databaseManager = globalDependencies.resolveDependency(DatabaseManager.class);
        return databaseManager.getDatabaseContext(NAMED_SYSTEM_DATABASE_ID).orElseThrow(() -> new RuntimeException("No database called `" + SYSTEM_DATABASE_NAME + "` was found.")).databaseFacade();
    };
    authManager = new BasicSystemGraphRealm(new SystemGraphRealmHelper(systemSupplier, new SecureHasher()), createAuthenticationStrategy(config));
    registerProcedure(globalDependencies.resolveDependency(GlobalProcedures.class), logProvider.getLog(getClass()), AuthProcedures.class, null);
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) DatabaseManager(org.neo4j.dbms.database.DatabaseManager) SecureHasher(org.neo4j.cypher.internal.security.SecureHasher) BasicSystemGraphRealm(org.neo4j.server.security.systemgraph.BasicSystemGraphRealm) SystemGraphRealmHelper(org.neo4j.server.security.systemgraph.SystemGraphRealmHelper) GlobalProcedures(org.neo4j.kernel.api.procedure.GlobalProcedures)

Example 4 with BasicSystemGraphRealm

use of org.neo4j.server.security.systemgraph.BasicSystemGraphRealm in project neo4j by neo4j.

the class BasicSystemGraphRealmTest method setUp.

@BeforeEach
void setUp() {
    authStrategy = mock(AuthenticationStrategy.class);
    realmHelper = spy(new SystemGraphRealmHelper(null, new SecureHasher()));
    realm = new BasicSystemGraphRealm(realmHelper, authStrategy);
}
Also used : SecureHasher(org.neo4j.cypher.internal.security.SecureHasher) BasicSystemGraphRealm(org.neo4j.server.security.systemgraph.BasicSystemGraphRealm) SystemGraphRealmHelper(org.neo4j.server.security.systemgraph.SystemGraphRealmHelper) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with BasicSystemGraphRealm

use of org.neo4j.server.security.systemgraph.BasicSystemGraphRealm in project neo4j by neo4j.

the class BasicAuthenticationTest method createAuthentication.

private static Authentication createAuthentication(int maxFailedAttempts) throws Exception {
    Config config = Config.defaults(GraphDatabaseSettings.auth_max_failed_attempts, maxFailedAttempts);
    SystemGraphRealmHelper realmHelper = spy(new SystemGraphRealmHelper(null, new SecureHasher()));
    BasicSystemGraphRealm realm = new BasicSystemGraphRealm(realmHelper, new RateLimitedAuthenticationStrategy(Clocks.systemClock(), config));
    Authentication authentication = new BasicAuthentication(realm);
    doReturn(new User.Builder("bob", credentialFor("secret")).withRequiredPasswordChange(true).build()).when(realmHelper).getUser("bob");
    doReturn(new User.Builder("mike", credentialFor("secret2")).build()).when(realmHelper).getUser("mike");
    return authentication;
}
Also used : RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) User(org.neo4j.kernel.impl.security.User) Config(org.neo4j.configuration.Config) SecureHasher(org.neo4j.cypher.internal.security.SecureHasher) BasicSystemGraphRealm(org.neo4j.server.security.systemgraph.BasicSystemGraphRealm) SystemGraphRealmHelper(org.neo4j.server.security.systemgraph.SystemGraphRealmHelper)

Aggregations

BasicSystemGraphRealm (org.neo4j.server.security.systemgraph.BasicSystemGraphRealm)5 SecureHasher (org.neo4j.cypher.internal.security.SecureHasher)4 SystemGraphRealmHelper (org.neo4j.server.security.systemgraph.SystemGraphRealmHelper)4 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Config (org.neo4j.configuration.Config)2 User (org.neo4j.kernel.impl.security.User)2 RateLimitedAuthenticationStrategy (org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy)2 DatabaseManager (org.neo4j.dbms.database.DatabaseManager)1 DefaultSystemGraphComponent (org.neo4j.dbms.database.DefaultSystemGraphComponent)1 DefaultSystemGraphInitializer (org.neo4j.dbms.database.DefaultSystemGraphInitializer)1 SystemGraphComponents (org.neo4j.dbms.database.SystemGraphComponents)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 GlobalProcedures (org.neo4j.kernel.api.procedure.GlobalProcedures)1 UserSecurityGraphComponent (org.neo4j.server.security.systemgraph.UserSecurityGraphComponent)1