Compare commits

..

No commits in common. "feature/test" and "master" have entirely different histories.

7 changed files with 16 additions and 26 deletions

View File

@ -20,7 +20,7 @@ COPY eeg_frontend/openapi.yaml ./
RUN npx openapi-generator-cli generate -i ./openapi.yaml -g typescript-angular -o ./src/app/api
COPY eeg_frontend/ ./
RUN npm run build -- --configuration staging
RUN npm run build -- --configuration production
# ---- Stage 2: Build Spring Boot Backend ----
FROM maven:3.9-eclipse-temurin-21 AS backend-build
@ -65,8 +65,12 @@ USER eeg
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8080/actuator/health || exit 1
ENTRYPOINT ["java", \
"-XX:+UseContainerSupport", \
"-XX:MaxRAMPercentage=75.0", \
"-Djava.security.egd=file:/dev/./urandom", \
"-jar", "app.jar"]
"-jar", "app.jar", \
"--spring.profiles.active=prod"]

View File

@ -28,4 +28,4 @@ foreach ($f in $Files) {
"`n" | Out-File -Append $OutFile -Encoding UTF8
}
Write-Host "Erfolgreich! Der Kontext für Backend und Frontend wurde in '$OutFile' gespeichert.."
Write-Host "Erfolgreich! Der Kontext für Backend und Frontend wurde in '$OutFile' gespeichert."

View File

@ -23,7 +23,6 @@ import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;
import org.springframework.security.oauth2.jwt.NimbusJwtEncoder;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
import org.springframework.security.oauth2.server.resource.web.HeaderBearerTokenResolver;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
@ -31,6 +30,7 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import javax.crypto.spec.SecretKeySpec;
import java.util.Arrays;
import java.util.List;
@Configuration
@EnableWebSecurity
@ -62,7 +62,6 @@ public class SecurityConfig {
.anyRequest().denyAll()
)
.oauth2ResourceServer(oauth2 -> oauth2
.bearerTokenResolver(new HeaderBearerTokenResolver("X-Access-Token"))
.jwt(jwt -> jwt.jwtAuthenticationConverter(jwtAuthenticationConverter()))
);
@ -95,7 +94,7 @@ public class SecurityConfig {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.stream(corsOrigins.split(",")).map(String::trim).toList());
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"));
configuration.setAllowedHeaders(Arrays.asList("Authorization", "Content-Type", "X-Access-Token"));
configuration.setAllowedHeaders(Arrays.asList("Authorization", "Content-Type"));
configuration.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);

View File

@ -12,7 +12,7 @@ spring:
jwt:
secret: dev-only-secret-do-not-use-in-production-2025
app:
cors-origins: http://localhost:4200,https://preview.coolify.mueller-dev.com
cors-origins: http://localhost:4200
eda:
simulation:
consent-delay-ms: 3000

View File

@ -48,15 +48,6 @@
],
"outputHashing": "all"
},
"staging": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.staging.ts"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
@ -71,9 +62,6 @@
"production": {
"buildTarget": "eeg_frontend:build:production"
},
"staging": {
"buildTarget": "eeg_frontend:build:staging"
},
"development": {
"buildTarget": "eeg_frontend:build:development"
}

View File

@ -3,11 +3,14 @@ import {HttpInterceptorFn} from '@angular/common/http';
export const jwtInterceptor: HttpInterceptorFn = (req, next) => {
const token = localStorage.getItem('token');
// If a token exists, clone the request and add the Authorization header
if (token) {
const authReq = req.clone({
headers: req.headers.set('X-Access-Token', token)
const clonedRequest = req.clone({
setHeaders: {
Authorization: `Bearer ${token}`
}
});
return next(authReq);
return next(clonedRequest);
}
return next(req);

View File

@ -1,4 +0,0 @@
export const environment = {
production: false,
apiUrl: 'https://preview.coolify.mueller-dev.com'
};