generated from it-at-m/oss-repository-en-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/sprint' into sprint
# Conflicts: # docs/README.md
- Loading branch information
Showing
17 changed files
with
186 additions
and
6 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
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
33 changes: 33 additions & 0 deletions
33
src/main/java/de/muenchen/mobidam/config/NoSecurityConfiguration.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,33 @@ | ||
/* | ||
* Copyright (c): it@M - Dienstleister für Informations- und Telekommunikationstechnik | ||
* der Landeshauptstadt München, 2022 | ||
*/ | ||
package de.muenchen.mobidam.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; | ||
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; | ||
|
||
@Configuration | ||
@Profile("no-security") | ||
@EnableWebSecurity | ||
public class NoSecurityConfiguration { | ||
|
||
/** | ||
* Disable security. | ||
*/ | ||
@Bean | ||
public SecurityFilterChain securityFilterChain(final HttpSecurity http) throws Exception { | ||
http | ||
.headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)) | ||
.authorizeHttpRequests(request -> request.requestMatchers(AntPathRequestMatcher.antMatcher("/**")).permitAll().anyRequest().permitAll()) | ||
.csrf(AbstractHttpConfigurer::disable); | ||
return http.build(); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/de/muenchen/mobidam/config/SecurityConfiguration.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,52 @@ | ||
/* | ||
* Copyright (c): it@M - Dienstleister für Informations- und Telekommunikationstechnik | ||
* der Landeshauptstadt München, 2022 | ||
*/ | ||
package de.muenchen.mobidam.config; | ||
|
||
import static org.springframework.security.config.Customizer.withDefaults; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; | ||
|
||
/** | ||
* The central class for configuration of all security aspects. | ||
*/ | ||
@Configuration | ||
@Profile("!no-security") | ||
@EnableWebSecurity | ||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) | ||
@RequiredArgsConstructor | ||
public class SecurityConfiguration { | ||
|
||
@Bean | ||
public SecurityFilterChain securityFilterChain(final HttpSecurity http) throws Exception { | ||
|
||
return http | ||
.authorizeHttpRequests((requests) -> requests.requestMatchers(AntPathRequestMatcher.antMatcher("/**"), | ||
// allow access to /actuator/info | ||
AntPathRequestMatcher.antMatcher("/actuator/info"), | ||
// allow access to /actuator/health for OpenShift Health Check | ||
AntPathRequestMatcher.antMatcher("/actuator/health"), | ||
// allow access to /actuator/health/liveness for OpenShift Liveness Check | ||
AntPathRequestMatcher.antMatcher("/actuator/health/liveness"), | ||
// allow access to /actuator/health/readiness for OpenShift Readiness Check | ||
AntPathRequestMatcher.antMatcher("/actuator/health/readiness"), | ||
// allow access to /actuator/metrics for Prometheus monitoring in OpenShift | ||
AntPathRequestMatcher.antMatcher("/actuator/metrics")) | ||
.permitAll()) | ||
.authorizeHttpRequests((requests) -> requests.requestMatchers(AntPathRequestMatcher.antMatcher("/**")) | ||
.authenticated()) | ||
.oauth2ResourceServer(oauth2 -> oauth2 | ||
.jwt(withDefaults())) | ||
.build(); | ||
|
||
} | ||
} |
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,13 @@ | ||
/* | ||
* Copyright (c): it@M - Dienstleister für Informations- und Telekommunikationstechnik | ||
* der Landeshauptstadt München, 2022 | ||
*/ | ||
package de.muenchen.mobidam; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class TestConstants { | ||
public static final String SPRING_NO_SECURITY_PROFILE = "no-security"; | ||
} |
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
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
Oops, something went wrong.