Basic scaffolding of the frontend #2

Merged
ansv7779 merged 10 commits from basic-scaffolding-frontend into main 2025-06-04 07:55:52 +02:00
3 changed files with 23 additions and 0 deletions
Showing only changes of commit 525e76cd5b - Show all commits

View File

@ -18,6 +18,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>24</java.version> <java.version>24</java.version>
<springdoc.version>2.8.6</springdoc.version>
</properties> </properties>
<dependencies> <dependencies>
@ -29,6 +30,13 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId> <artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency> </dependency>
<!-- OpenAPI specification -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>${springdoc.version}</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -8,15 +8,25 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatchers;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
import se.su.dsv.studentportalen.bff.login.BFFAuthenticationEntryPoint; import se.su.dsv.studentportalen.bff.login.BFFAuthenticationEntryPoint;
import java.util.List; import java.util.List;
import static org.springframework.security.web.util.matcher.AntPathRequestMatcher.antMatcher;
@SpringBootApplication @SpringBootApplication
@EnableConfigurationProperties @EnableConfigurationProperties
@ConfigurationPropertiesScan @ConfigurationPropertiesScan
public class Studentportalen extends SpringBootServletInitializer { public class Studentportalen extends SpringBootServletInitializer {
private static final RequestMatcher DOCUMENTATION_MATCHER = RequestMatchers.anyOf(
antMatcher("/swagger"),
antMatcher("/swagger-ui/**"),
antMatcher("/v3/api-docs/**"));
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(Studentportalen.class, args); SpringApplication.run(Studentportalen.class, args);
} }
@ -32,6 +42,7 @@ public class Studentportalen extends SpringBootServletInitializer {
http.oauth2Login(login -> login http.oauth2Login(login -> login
.defaultSuccessUrl(frontendConfiguration.url(), true)); .defaultSuccessUrl(frontendConfiguration.url(), true));
http.authorizeHttpRequests(authorize -> authorize http.authorizeHttpRequests(authorize -> authorize
.requestMatchers(DOCUMENTATION_MATCHER).permitAll()
.anyRequest().authenticated()); .anyRequest().authenticated());
http.cors(cors -> cors http.cors(cors -> cors
.configurationSource(_ -> frontendOnlyCors(frontendConfiguration))); .configurationSource(_ -> frontendOnlyCors(frontendConfiguration)));

View File

@ -27,3 +27,7 @@ server.servlet.session:
same-site: strict same-site: strict
path: / path: /
name: __Host-JSESSIONID name: __Host-JSESSIONID
springdoc:
swagger-ui:
path: /swagger