Skip to content

Commit

Permalink
Klartax prod issues (#166)
Browse files Browse the repository at this point in the history
* Increased version to 1.1.16

* Changed cors configuration to set disabled first to prevent cors configuration exceptions

* Updated version to 1.17

* Replaced deprecated PostgreSQL94Dialect with PostgreSQLDialect

* spring.jpa.open-in-view ist standardmäßig aktiviert: behoben

* Excluded SecurityAutoConfiguration to prevent Spring from creating a default user

* Changed SecurityConfiguration to allow access to swagger

* Changed SecurityConfiguration to allow access to swagger

* Excluded AutoConfiguration for UserDetailsService

* Added RequestMatchers to address warnings for ignored paths

* Increased version to 1.19
  • Loading branch information
Mme-adorsys authored Feb 12, 2024
1 parent 906f9e6 commit 01d8e6a
Show file tree
Hide file tree
Showing 25 changed files with 65 additions and 63 deletions.
2 changes: 1 addition & 1 deletion keycloak-storage-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>de.adorsys.sts</groupId>
<artifactId>secure-token-service</artifactId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>

<artifactId>keycloak-storage-provider</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>de.adorsys.sts</groupId>
<artifactId>secure-token-service</artifactId>
<version>1.1.15</version>
<version>1.1.19</version>
<packaging>pom</packaging>

<name>SecureTokenService</name>
Expand Down
2 changes: 1 addition & 1 deletion sts-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.adorsys.sts</groupId>
<artifactId>secure-token-service</artifactId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>

<artifactId>sts-common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sts-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sts-keymanagement/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sts-keymanagement/sts-keymanagement-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sts-keymanagement</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions sts-keymanagement/sts-keymanagement-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sts-keymanagement</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -14,7 +14,7 @@
<dependency>
<groupId>de.adorsys.sts</groupId>
<artifactId>sts-keymanagement-api</artifactId>
<version>1.1.15</version>
<version>1.1.19</version>
</dependency>
<dependency>
<groupId>de.adorsys.sts</groupId>
Expand Down
2 changes: 1 addition & 1 deletion sts-persistence-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
spring:
liquibase:
default-schema: sts

flyway:
locations:
- classpath:/db/migration/flyway/postgres
Expand All @@ -10,4 +9,5 @@ spring:
url: jdbc:postgresql://localhost:5432/sts
jpa:
show-sql: false
database-platform: org.hibernate.dialect.PostgreSQL94Dialect
database-platform: org.hibernate.dialect.PostgreSQLDialect
open-in-view: false
2 changes: 1 addition & 1 deletion sts-persistence-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sts-pop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sts-resource-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sts-secret-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package de.adorsys.sts.secretserver;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;

@SpringBootApplication
@SpringBootApplication(exclude = {UserDetailsServiceAutoConfiguration.class, SecurityAutoConfiguration.class})
public class SecretServerApplication {
public static void main(String[] args) {
SpringApplication.run(SecretServerApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class CorsProperties {

private boolean disbaled;
private String[] allowedOrigins;
private String allowedHeaders;
private String[] allowedHeaders;
private String[] allowedMethods;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import de.adorsys.sts.filter.JWTAuthenticationFilter;
import de.adorsys.sts.token.authentication.TokenAuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
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.configuration.WebSecurityCustomizer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
Expand All @@ -23,32 +21,44 @@
public class SecurityConfiguration {


@Autowired
private CorsProperties corsProperties;
private final CorsProperties corsProperties;

public SecurityConfiguration(CorsProperties corsProperties) {
this.corsProperties = corsProperties;
}

@Bean
protected SecurityFilterChain securityFilterChain(HttpSecurity http, TokenAuthenticationService tokenAuthenticationService) throws Exception {
// @formatter:off
http
.cors()
.and()
.csrf()
.disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeHttpRequests((requests) ->requests.requestMatchers(HttpMethod.GET, "/pop").permitAll()
if (corsProperties.isDisbaled()) { // Achten Sie auf die korrekte Schreibweise von isDisabled(), falls es ein
// Tippfehler war.
http.cors().disable();
} else {
http.cors().configurationSource(request -> {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.setAllowedOrigins(Arrays.asList(corsProperties.getAllowedOrigins()));
corsConfiguration.setAllowedMethods(Arrays.asList(corsProperties.getAllowedMethods()));
corsConfiguration.setAllowedHeaders(Arrays.asList(corsProperties.getAllowedHeaders()));
return corsConfiguration;
});
}

http.csrf().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeHttpRequests((requests) -> requests
// Erlauben Sie den Zugriff auf Swagger-Dokumentation und UI-Ressourcen
.requestMatchers("/v2/api-docs", "/swagger-resources/**", "/swagger-ui.html", "/webjars/**").permitAll()
.requestMatchers("/cloudfoundryapplication/**").permitAll()
// Erlauben Sie den Zugriff auf andere spezifische Endpunkte
.requestMatchers(HttpMethod.GET, "/pop").permitAll()
.requestMatchers(HttpMethod.GET, "/actuator/**").permitAll()
.anyRequest().authenticated())
// Alle anderen Anfragen erfordern eine Authentifizierung
.anyRequest().authenticated()
);

;
// @formatter:on
// Fügt den JWTAuthenticationFilter vor dem UsernamePasswordAuthenticationFilter hinzu
http.addFilterBefore(new JWTAuthenticationFilter(tokenAuthenticationService), UsernamePasswordAuthenticationFilter.class);

if (corsProperties.isDisbaled()) {
http.cors().disable();
}

return http.build();
}

Expand All @@ -57,25 +67,12 @@ public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
Arrays.stream(corsProperties.getAllowedOrigins()).forEach(config::addAllowedOrigin);
config.addAllowedHeader(corsProperties.getAllowedHeaders());
Arrays.asList(corsProperties.getAllowedHeaders()).forEach(config::addAllowedHeader);
Arrays.stream(corsProperties.getAllowedMethods()).forEach(config::addAllowedMethod);

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);

return new CorsFilter(source);
}


@Bean
public WebSecurityCustomizer customize() {
return (web) -> web.ignoring().requestMatchers(
"/v2/api-docs",
"/swagger-resources",
"/swagger-resources/configuration/ui",
"/swagger-resources/configuration/security",
"/swagger-ui.html",
"/webjars/**"
);
}
}
8 changes: 5 additions & 3 deletions sts-secret-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ spring:
password: db_user@123
jpa:
show-sql: false
open-in-view: false
properties:
hibernate:
default_schema: sts
flyway:
enabled: false
locations:
- db/migration/flyway/h2
- db/migration/flyway/h2
liquibase:
enabled: true
change-log: classpath:/db/migration/liquibase/changelog.yml
Expand All @@ -26,10 +27,11 @@ spring:
- org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
- org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration

#Example values, do not use for production
cors:
disabled: false
allowedOrigins: "*"
allowedHeaders: "*"
allowedOrigins: localhost:8080, localhost:8081
allowedHeaders: Content-Type,Authorization,Accept,Origin,Referer,User-Agent
allowedMethods: GET,POST,PUT,DELETE

sts:
Expand Down
2 changes: 1 addition & 1 deletion sts-secret/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sts-server-info/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sts-service-component-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sts-simple-encryption/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sts-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sts-token-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void onJsonWebKeySetRetrieved(List<JWK> jwks) {
log.info("Retrieved {} keys from {}", jwks.size(), jwksUrl);
}

public static class JsonWebKeyRetrievalException extends RuntimeException {
protected static class JsonWebKeyRetrievalException extends RuntimeException {
public JsonWebKeyRetrievalException(Throwable cause) {
super(cause);
}
Expand Down
2 changes: 1 addition & 1 deletion sts-token/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>secure-token-service</artifactId>
<groupId>de.adorsys.sts</groupId>
<version>1.1.15</version>
<version>1.1.19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down

0 comments on commit 01d8e6a

Please sign in to comment.