use of org.neo4j.kernel.api.security.SecurityContext in project neo4j by neo4j.
the class MultiRealmAuthManagerTest method defaultUserShouldHaveCorrectPermissions.
@Test
public void defaultUserShouldHaveCorrectPermissions() throws Throwable {
// Given
manager.start();
setMockAuthenticationStrategyResult("neo4j", "neo4j", AuthenticationResult.SUCCESS);
// When
SecurityContext securityContext = manager.login(authToken("neo4j", "neo4j"));
userManager.setUserPassword("neo4j", "1234", false);
securityContext.subject().logout();
setMockAuthenticationStrategyResult("neo4j", "1234", AuthenticationResult.SUCCESS);
securityContext = manager.login(authToken("neo4j", "1234"));
// Then
assertTrue(securityContext.mode().allowsReads());
assertTrue(securityContext.mode().allowsWrites());
assertTrue(securityContext.mode().allowsSchemaWrites());
}
use of org.neo4j.kernel.api.security.SecurityContext in project neo4j by neo4j.
the class MultiRealmAuthManagerTest method userWithArchitectRoleShouldHaveCorrectPermissions.
@Test
public void userWithArchitectRoleShouldHaveCorrectPermissions() throws Throwable {
// Given
createTestUsers();
manager.start();
// When
SecurityContext securityContext = manager.login(authToken("trinity", "abc123"));
// Then
assertTrue(securityContext.mode().allowsReads());
assertTrue(securityContext.mode().allowsWrites());
assertTrue(securityContext.mode().allowsSchemaWrites());
}
use of org.neo4j.kernel.api.security.SecurityContext in project neo4j by neo4j.
the class MultiRealmAuthManagerTest method userWithReaderRoleShouldHaveCorrectPermissions.
@Test
public void userWithReaderRoleShouldHaveCorrectPermissions() throws Throwable {
// Given
createTestUsers();
manager.start();
// When
SecurityContext securityContext = manager.login(authToken("neo", "abc123"));
// Then
assertTrue(securityContext.mode().allowsReads());
assertFalse(securityContext.mode().allowsWrites());
assertFalse(securityContext.mode().allowsSchemaWrites());
}
use of org.neo4j.kernel.api.security.SecurityContext in project neo4j by neo4j.
the class UserService method getUser.
@GET
@Path("/{username}")
public Response getUser(@PathParam("username") String username, @Context HttpServletRequest req) {
Principal principal = req.getUserPrincipal();
if (principal == null || !principal.getName().equals(username)) {
return output.notFound();
}
SecurityContext securityContext = getSecurityContextFromUserPrincipal(principal);
UserManager userManager = userManagerSupplier.getUserManager(securityContext);
try {
User user = userManager.getUser(username);
return output.ok(new AuthorizationRepresentation(user));
} catch (InvalidArgumentsException e) {
return output.notFound();
}
}
use of org.neo4j.kernel.api.security.SecurityContext in project neo4j by neo4j.
the class SecurityContextDescriptionTest method shouldMakeNiceDescriptionAuthDisabledAndRestricted.
@Test
public void shouldMakeNiceDescriptionAuthDisabledAndRestricted() throws Throwable {
SecurityContext disabled = SecurityContext.AUTH_DISABLED;
SecurityContext restricted = disabled.withMode(new RestrictedAccessMode(disabled.mode(), AccessMode.Static.READ));
assertThat(restricted.description(), equalTo("AUTH_DISABLED with FULL restricted to READ"));
}
Aggregations