Commit e2622393 authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

If user is set as internal admin, permit read action

parent 654c43aa
......@@ -4,7 +4,7 @@ subprojects {
apply plugin: 'maven-publish'
sourceCompatibility = 1.7
version = '0.60.0-SNAPSHOT'
version = '0.70.0-SNAPSHOT'
ext {
springVersion = '4.0.4.RELEASE'
......
......@@ -10,6 +10,7 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.client.HttpClientErrorException;
import de.thm.arsnova.connector.dao.ConnectorDao;
import de.thm.arsnova.connector.services.InternalUserService;
public class RepoPermissionEvaluator implements PermissionEvaluator {
......@@ -20,6 +21,9 @@ public class RepoPermissionEvaluator implements PermissionEvaluator {
@Autowired
ConnectorDao dao;
@Autowired
InternalUserService internalUserService;
@Override
public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) {
return false;
......@@ -34,6 +38,8 @@ public class RepoPermissionEvaluator implements PermissionEvaluator {
UserDetails ud = (UserDetails)authentication.getPrincipal();
if (isAdmin(ud)) return true;
try {
switch (targetType) {
case "membership":
......@@ -55,4 +61,8 @@ public class RepoPermissionEvaluator implements PermissionEvaluator {
}
return false;
}
private boolean isAdmin(UserDetails user) {
return internalUserService.getUser(user.getUsername()).isAdmin();
}
}
package de.thm.arsnova.connector.config;
import java.sql.SQLException;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import de.thm.arsnova.connector.dao.ConnectorDao;
import de.thm.arsnova.connector.dao.DummyConnectorDaoImpl;
......@@ -12,16 +9,6 @@ import de.thm.arsnova.connector.services.ConnectorServiceImpl;
public class DummyTestConfig {
@Bean(name = "dataSource")
public DriverManagerDataSource dataSource() throws SQLException {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
dataSource.setUrl("jdbc:hsqldb:mem:testdb");
dataSource.setUsername("test");
dataSource.setPassword("");
return dataSource;
}
@Bean
public ConnectorDao connectorDao() {
return new DummyConnectorDaoImpl();
......
package de.thm.arsnova.connector.config;
import java.sql.SQLException;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import de.thm.arsnova.connector.dao.ConnectorDao;
import de.thm.arsnova.connector.dao.MoodleConnectorDaoImpl;
......@@ -12,16 +9,6 @@ import de.thm.arsnova.connector.services.ConnectorServiceImpl;
public class MoodleTestConfig {
@Bean(name = "dataSource")
public DriverManagerDataSource dataSource() throws SQLException {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
dataSource.setUrl("jdbc:hsqldb:mem:testdb");
dataSource.setUsername("test");
dataSource.setPassword("");
return dataSource;
}
@Bean
public ConnectorDao connectorDao() {
return new MoodleConnectorDaoImpl();
......
package de.thm.arsnova.connector.config;
import java.sql.SQLException;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import de.thm.arsnova.connector.dao.ConnectorDao;
import de.thm.arsnova.connector.dao.StudipConnectorDaoImpl;
......@@ -12,16 +9,6 @@ import de.thm.arsnova.connector.services.ConnectorServiceImpl;
public class StudipTestConfig {
@Bean(name = "dataSource")
public DriverManagerDataSource dataSource() throws SQLException {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
dataSource.setUrl("jdbc:hsqldb:mem:testdb");
dataSource.setUsername("test");
dataSource.setPassword("");
return dataSource;
}
@Bean
public ConnectorDao connectorDao() {
return new StudipConnectorDaoImpl();
......
......@@ -10,12 +10,13 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import de.thm.arsnova.connector.config.DummyTestConfig;
import de.thm.arsnova.connector.config.RepositoryTestConfig;
import de.thm.arsnova.connector.model.Courses;
import de.thm.arsnova.connector.model.Membership;
import de.thm.arsnova.connector.model.UserRole;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( classes = {DummyTestConfig.class} )
@ContextConfiguration( classes = {DummyTestConfig.class, RepositoryTestConfig.class} )
public class ConnectorServiceDummyTest {
@Autowired
......
......@@ -27,12 +27,13 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import de.thm.arsnova.connector.config.MoodleTestConfig;
import de.thm.arsnova.connector.config.RepositoryTestConfig;
import de.thm.arsnova.connector.model.Courses;
import de.thm.arsnova.connector.model.Membership;
import de.thm.arsnova.connector.model.UserRole;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( classes = {MoodleTestConfig.class} )
@ContextConfiguration( classes = {MoodleTestConfig.class, RepositoryTestConfig.class} )
public class ConnectorServiceMoodleTest {
@Autowired
......
......@@ -26,13 +26,14 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import de.thm.arsnova.connector.config.RepositoryTestConfig;
import de.thm.arsnova.connector.config.StudipTestConfig;
import de.thm.arsnova.connector.model.Courses;
import de.thm.arsnova.connector.model.Membership;
import de.thm.arsnova.connector.model.UserRole;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( classes = {StudipTestConfig.class} )
@ContextConfiguration( classes = {StudipTestConfig.class, RepositoryTestConfig.class} )
public class ConnectorServiceStudipTest {
@Autowired
......
......@@ -16,7 +16,7 @@ import de.thm.arsnova.connector.config.RepositoryTestConfig;
import de.thm.arsnova.connector.persistence.domain.EnabledCategory;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( classes = {RepositoryTestConfig.class} )
@ContextConfiguration( classes = {RepositoryTestConfig.class, RepositoryTestConfig.class} )
public class EnabledCategoryServiceTest {
@Autowired
......
......@@ -28,12 +28,13 @@ import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.util.NestedServletException;
import de.thm.arsnova.connector.config.DummyTestConfig;
import de.thm.arsnova.connector.config.RepositoryTestConfig;
import de.thm.arsnova.connector.config.SecurityTestConfig;
import de.thm.arsnova.connector.config.WebConfig;
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = { DummyTestConfig.class, SecurityTestConfig.class, WebConfig.class})
@ContextConfiguration(classes = { DummyTestConfig.class, SecurityTestConfig.class, WebConfig.class, RepositoryTestConfig.class})
public class WebDomainIntegrationTest {
private MockMvc mockMvc;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment