use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.
the class EnterpriseSecurityModule method setup.
@Override
public void setup(Dependencies dependencies) throws KernelException {
Config config = dependencies.config();
Procedures procedures = dependencies.procedures();
LogProvider logProvider = dependencies.logService().getUserLogProvider();
JobScheduler jobScheduler = dependencies.scheduler();
FileSystemAbstraction fileSystem = dependencies.fileSystem();
LifeSupport life = dependencies.lifeSupport();
SecurityLog securityLog = SecurityLog.create(config, dependencies.logService().getInternalLog(GraphDatabaseFacade.class), fileSystem, jobScheduler);
life.add(securityLog);
boolean allowTokenCreate = config.get(SecuritySettings.allow_publisher_create_token);
PredefinedRolesBuilder.setAllowPublisherTokenCreate(allowTokenCreate);
procedures.writerCreateToken(allowTokenCreate);
EnterpriseAuthAndUserManager authManager = newAuthManager(config, logProvider, securityLog, fileSystem, jobScheduler);
life.add(dependencies.dependencySatisfier().satisfyDependency(authManager));
// Register procedures
procedures.registerComponent(SecurityLog.class, (ctx) -> securityLog, false);
procedures.registerComponent(EnterpriseAuthManager.class, ctx -> authManager, false);
procedures.registerComponent(EnterpriseSecurityContext.class, ctx -> asEnterprise(ctx.get(SECURITY_CONTEXT)), true);
if (config.get(SecuritySettings.native_authentication_enabled) || config.get(SecuritySettings.native_authorization_enabled)) {
procedures.registerComponent(EnterpriseUserManager.class, ctx -> authManager.getUserManager(asEnterprise(ctx.get(SECURITY_CONTEXT))), true);
if (config.get(SecuritySettings.auth_providers).size() > 1) {
procedures.registerProcedure(UserManagementProcedures.class, true, Optional.of("%s only applies to native users."));
} else {
procedures.registerProcedure(UserManagementProcedures.class, true);
}
} else {
procedures.registerComponent(EnterpriseUserManager.class, ctx -> EnterpriseUserManager.NOOP, true);
}
procedures.registerProcedure(SecurityProcedures.class, true);
}
use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.
the class ProcedureInteractionTestBase method configuredSetup.
void configuredSetup(Map<String, String> config) throws Throwable {
neo = setUpNeoServer(config);
Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
procedures.registerProcedure(ClassWithProcedures.class);
procedures.registerFunction(ClassWithFunctions.class);
userManager = neo.getLocalUserManager();
userManager.newUser("noneSubject", "abc", false);
userManager.newUser("pwdSubject", "abc", true);
userManager.newUser("adminSubject", "abc", false);
userManager.newUser("schemaSubject", "abc", false);
userManager.newUser("writeSubject", "abc", false);
userManager.newUser("readSubject", "123", false);
// Currently admin role is created by default
userManager.addRoleToUser(ADMIN, "adminSubject");
userManager.addRoleToUser(ARCHITECT, "schemaSubject");
userManager.addRoleToUser(PUBLISHER, "writeSubject");
userManager.addRoleToUser(READER, "readSubject");
userManager.newRole(EMPTY_ROLE);
noneSubject = neo.login("noneSubject", "abc");
pwdSubject = neo.login("pwdSubject", "abc");
readSubject = neo.login("readSubject", "123");
writeSubject = neo.login("writeSubject", "abc");
schemaSubject = neo.login("schemaSubject", "abc");
adminSubject = neo.login("adminSubject", "abc");
assertEmpty(schemaSubject, "CREATE (n) SET n:A:Test:NEWNODE:VeryUniqueLabel:Node " + "SET n.id = '2', n.square = '4', n.name = 'me', n.prop = 'a', n.number = '1' DELETE n");
assertEmpty(writeSubject, "UNWIND range(0,2) AS number CREATE (:Node {number:number, name:'node'+number})");
}
use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.
the class ConfiguredProceduresTestBase method shouldSetAllowedToConfigSetting.
@Test
public void shouldSetAllowedToConfigSetting() throws Throwable {
configuredSetup(stringMap(SecuritySettings.default_allowed.name(), "nonEmpty"));
Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
ProcedureSignature numNodes = procedures.procedure(new QualifiedName(new String[] { "test" }, "numNodes"));
assertThat(Arrays.asList(numNodes.allowed()), containsInAnyOrder("nonEmpty"));
}
use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.
the class ConfiguredProceduresTestBase method shouldSetAllowedToConfigSettingForUDF.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void shouldSetAllowedToConfigSettingForUDF() throws Throwable {
configuredSetup(stringMap(SecuritySettings.default_allowed.name(), "nonEmpty"));
Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
UserFunctionSignature funcSig = procedures.function(new QualifiedName(new String[] { "test" }, "nonAllowedFunc")).get();
assertThat(Arrays.asList(funcSig.allowed()), containsInAnyOrder("nonEmpty"));
}
use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.
the class ConfiguredProceduresTestBase method shouldNotSetProcedureAllowedIfSettingNotSetForUDF.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void shouldNotSetProcedureAllowedIfSettingNotSetForUDF() throws Throwable {
configuredSetup(defaultConfiguration());
Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
UserFunctionSignature funcSig = procedures.function(new QualifiedName(new String[] { "test" }, "nonAllowedFunc")).get();
assertThat(Arrays.asList(funcSig.allowed()), empty());
}
Aggregations