-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrate user console + fix request handling for application
- Loading branch information
Showing
18 changed files
with
469 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "frontend/console"] | ||
path = frontend/console | ||
url = https://github.com/scc-digitalhub/digitalhub-console.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
application/src/main/java/it/smartcommunitylabdhub/core/config/WebConfig.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>it.smartcommunitylabdhub</groupId> | ||
<artifactId>dh-console</artifactId> | ||
<version>0.0.29</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.30</version> | ||
<scope>compile</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot</artifactId> | ||
<version>3.2.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<version>3.2.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-security</artifactId> | ||
<version>3.2.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-thymeleaf</artifactId> | ||
<version>3.2.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>it.smartcommunitylabdhub</groupId> | ||
<artifactId>dh-commons</artifactId> | ||
<version>0.0.29</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springdoc</groupId> | ||
<artifactId>springdoc-openapi-starter-common</artifactId> | ||
<version>2.2.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>it.smartcommunitylabdhub</groupId> | ||
<artifactId>digitalhub-core</artifactId> | ||
<version>${revision}</version> | ||
<relativePath>../</relativePath> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>it.smartcommunitylabdhub</groupId> | ||
<artifactId>dh-console</artifactId> | ||
<name>console</name> | ||
<description>DHCore console</description> | ||
|
||
<properties> | ||
<yarn.version>v1.22.19</yarn.version> | ||
<node.version>v18.17.1</node.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>${lombok.version}</version> | ||
<scope>compile</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot</artifactId> | ||
<version>${spring-boot.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<version>${spring-boot.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-security</artifactId> | ||
<version>${spring-boot.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-thymeleaf</artifactId> | ||
<version>${spring-boot.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>it.smartcommunitylabdhub</groupId> | ||
<artifactId>dh-commons</artifactId> | ||
<version>${revision}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springdoc</groupId> | ||
<artifactId>springdoc-openapi-starter-common</artifactId> | ||
<version>${springdoc.version}</version> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.github.eirslett</groupId> | ||
<artifactId>frontend-maven-plugin</artifactId> | ||
<version>1.15.0</version> | ||
|
||
<configuration> | ||
<nodeVersion>${node.version}</nodeVersion> | ||
<yarnVersion>${yarn.version}</yarnVersion> | ||
<installDirectory>${project.build.directory}</installDirectory> | ||
</configuration> | ||
<executions> | ||
|
||
<execution> | ||
<id>install-node-and-yarn</id> | ||
<goals> | ||
<goal>install-node-and-yarn</goal> | ||
</goals> | ||
</execution> | ||
|
||
<execution> | ||
<id>frontent-yarn-install</id> | ||
<goals> | ||
<goal>yarn</goal> | ||
</goals> | ||
<phase>generate-resources</phase> | ||
<configuration> | ||
<arguments>install</arguments> | ||
<workingDirectory>${project.basedir}/console</workingDirectory> | ||
</configuration> | ||
</execution> | ||
|
||
<execution> | ||
<id>frontend build</id> | ||
<goals> | ||
<goal>yarn</goal> | ||
</goals> | ||
<phase>prepare-package</phase> | ||
<configuration> | ||
<arguments>build:production</arguments> | ||
<workingDirectory>${project.basedir}/console</workingDirectory> | ||
</configuration> | ||
</execution> | ||
|
||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>frontend package</id> | ||
<goals> | ||
<goal>copy-resources</goal> | ||
</goals> | ||
<phase>prepare-package</phase> | ||
<configuration> | ||
<outputDirectory>${project.build.outputDirectory}/console</outputDirectory> | ||
<resources> | ||
<resource> | ||
<directory>${project.basedir}/console/dist</directory> | ||
<filtering>false</filtering> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
8 changes: 8 additions & 0 deletions
8
frontend/src/main/java/it/smartcommunitylabdhub/console/Keys.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package it.smartcommunitylabdhub.console; | ||
|
||
public class Keys { | ||
|
||
public static final String CONSOLE_CONTEXT = "/console"; | ||
|
||
private Keys() {} | ||
} |
68 changes: 68 additions & 0 deletions
68
frontend/src/main/java/it/smartcommunitylabdhub/console/config/ConsoleSecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package it.smartcommunitylabdhub.console.config; | ||
|
||
import it.smartcommunitylabdhub.commons.config.SecurityProperties; | ||
import it.smartcommunitylabdhub.console.Keys; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.http.SessionCreationPolicy; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; | ||
import org.springframework.security.web.util.matcher.RequestMatcher; | ||
import org.springframework.util.StringUtils; | ||
import org.springframework.web.cors.CorsConfiguration; | ||
import org.springframework.web.cors.CorsConfigurationSource; | ||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
|
||
@Configuration | ||
public class ConsoleSecurityConfig { | ||
|
||
@Autowired | ||
SecurityProperties properties; | ||
|
||
@Value("${security.api.cors.origins}") | ||
private String corsOrigins; | ||
|
||
public RequestMatcher getRequestMatcher() { | ||
return new AntPathRequestMatcher(Keys.CONSOLE_CONTEXT + "/**"); | ||
} | ||
|
||
@Bean("consoleSecurityFilterChain") | ||
public SecurityFilterChain apiSecurityFilterChain(HttpSecurity http) throws Exception { | ||
http | ||
.securityMatcher(getRequestMatcher()) | ||
.authorizeHttpRequests(auth -> { | ||
auth.anyRequest().permitAll(); | ||
}) | ||
//disable csrf | ||
.csrf(csrf -> csrf.disable()) | ||
// we don't want a session for these endpoints, each request should be evaluated | ||
.sessionManagement(management -> management.sessionCreationPolicy(SessionCreationPolicy.STATELESS)); | ||
|
||
// allow cors | ||
http.cors(cors -> { | ||
if (StringUtils.hasText(corsOrigins)) { | ||
cors.configurationSource(corsConfigurationSource(corsOrigins)); | ||
} else { | ||
cors.disable(); | ||
} | ||
}); | ||
|
||
return http.build(); | ||
} | ||
|
||
private CorsConfigurationSource corsConfigurationSource(String origins) { | ||
CorsConfiguration configuration = new CorsConfiguration(); | ||
configuration.setAllowedOriginPatterns(new ArrayList<>(StringUtils.commaDelimitedListToSet(origins))); | ||
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "PATCH")); | ||
configuration.setAllowedHeaders(Arrays.asList("*")); | ||
configuration.setExposedHeaders(Arrays.asList("authorization", "range")); | ||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
source.registerCorsConfiguration("/**", configuration); | ||
return source; | ||
} | ||
} |
Oops, something went wrong.