Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,19 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.8.13</version>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
Expand Down
19 changes: 16 additions & 3 deletions ui/src/bamboo/config/DatabaseStartupConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package bamboo.config;

import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor;
import jakarta.persistence.EntityManagerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.support.DatabaseStartupValidator;
Expand All @@ -23,7 +27,16 @@ public DatabaseStartupValidator databaseStartupValidator(DataSource dataSource)
* until the database is ready.
*/
@Bean
public static EntityManagerFactoryDependsOnPostProcessor databaseStartupDependency() {
return new EntityManagerFactoryDependsOnPostProcessor("databaseStartupValidator");
public static BeanFactoryPostProcessor entityManagerFactoryDependsOnPostProcessor() {
return new BeanFactoryPostProcessor() {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
String[] beanNames = beanFactory.getBeanNamesForType(EntityManagerFactory.class);
for (String beanName : beanNames) {
BeanDefinition definition = beanFactory.getBeanDefinition(beanName);
definition.setDependsOn("databaseStartupValidator");
}
}
};
}
}
12 changes: 6 additions & 6 deletions ui/src/bamboo/config/MethodSecurityConfig.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package bamboo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;

/**
* Enables the @PreAuthorize and @PostAuthorize annotations.
*/
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration {
@EnableMethodSecurity
public class MethodSecurityConfig {
@Autowired private BambooPermissionEvaluator permissionEvaluator;

@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
@Bean
public MethodSecurityExpressionHandler methodSecurityExpressionHandler() {
DefaultMethodSecurityExpressionHandler expressionHandler =
new DefaultMethodSecurityExpressionHandler();
expressionHandler.setPermissionEvaluator(permissionEvaluator);
Expand Down
30 changes: 14 additions & 16 deletions ui/src/bamboo/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import java.time.Instant;
import java.util.*;

import static org.springframework.security.web.util.matcher.AntPathRequestMatcher.antMatcher;

@Configuration
public class SecurityConfig {
private static final Logger log = LoggerFactory.getLogger(SecurityConfig.class);
Expand All @@ -42,25 +40,25 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.jwtAuthenticationConverter(jwt -> new JwtAuthenticationToken(jwt, mapClaimsToAuthorities(jwt.getClaims())))));
http.authorizeHttpRequests(authorize -> authorize
// static content
.requestMatchers(antMatcher("/webjars/**")).permitAll()
.requestMatchers(antMatcher("/assets/**")).permitAll()
.requestMatchers("/webjars/**").permitAll()
.requestMatchers("/assets/**").permitAll()

// api: solr indexer
.requestMatchers(antMatcher("/collections/*/warcs/json")).permitAll()
.requestMatchers(antMatcher("/collections/*/warcs/sync")).permitAll()
.requestMatchers(antMatcher("/warcs/*/text")).permitAll()
.requestMatchers("/collections/*/warcs/json").permitAll()
.requestMatchers("/collections/*/warcs/sync").permitAll()
.requestMatchers("/warcs/*/text").permitAll()
// api: wayback
.requestMatchers(antMatcher("/warcs/*")).permitAll()
.requestMatchers(antMatcher("/healthcheck")).permitAll()
.requestMatchers("/warcs/*").permitAll()
.requestMatchers("/healthcheck").permitAll()

.requestMatchers(antMatcher("/")).hasRole(Role.STDUSER.name())
.requestMatchers(antMatcher("/series")).permitAll()
.requestMatchers(antMatcher("/series/**")).permitAll()
.requestMatchers(antMatcher("/crawls/**")).permitAll()
.requestMatchers("/").hasRole(Role.STDUSER.name())
.requestMatchers("/series").permitAll()
.requestMatchers("/series/**").permitAll()
.requestMatchers("/crawls/**").permitAll()

.requestMatchers(antMatcher("/data/**")).permitAll()
.requestMatchers(antMatcher("/api/v2/**")).permitAll()
.requestMatchers(antMatcher("/api/**")).hasRole(Role.PANADMIN.name())
.requestMatchers("/data/**").permitAll()
.requestMatchers("/api/v2/**").permitAll()
.requestMatchers("/api/**").hasRole(Role.PANADMIN.name())

.anyRequest().hasRole(Role.PANADMIN.name()));
} else {
Expand Down
2 changes: 1 addition & 1 deletion ui/test/bamboo/WebTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.DynamicPropertyRegistry;
Expand Down
Loading