Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Commit

Permalink
Merge pull request #28 from catenax-ng/DCMFOSS/72_Fixed
Browse files Browse the repository at this point in the history
DCMFOSS/72_Keycloak_integration_fixed
  • Loading branch information
carslen authored Oct 12, 2023
2 parents 7307473 + 8f93d14 commit dbb9d8e
Show file tree
Hide file tree
Showing 84 changed files with 2,049 additions and 464 deletions.
175 changes: 94 additions & 81 deletions DEPENDENCIES_BACKEND

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions DEPENDENCIES_FRONTEND
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ npm/npmjs/-/react-native/0.72.3, MIT, approved, clearlydefined
npm/npmjs/-/react-popper/2.3.0, MIT, approved, clearlydefined
npm/npmjs/-/react-refresh/0.11.0, MIT, approved, clearlydefined
npm/npmjs/-/react-refresh/0.4.3, MIT, approved, clearlydefined
npm/npmjs/-/react-router-dom/6.15.0, MIT, restricted, clearlydefined
npm/npmjs/-/react-router-dom/6.15.0, LicenseRef-scancode-google-cla AND MIT, restricted, #10907
npm/npmjs/-/react-router/6.15.0, MIT, approved, clearlydefined
npm/npmjs/-/react-scripts/5.0.1, MIT, approved, clearlydefined
npm/npmjs/-/react-shallow-renderer/16.15.0, MIT, approved, clearlydefined
Expand All @@ -912,7 +912,7 @@ npm/npmjs/-/recast/0.20.5, MIT, approved, clearlydefined
npm/npmjs/-/recast/0.21.5, MIT, approved, clearlydefined
npm/npmjs/-/recursive-readdir/2.2.3, MIT, approved, clearlydefined
npm/npmjs/-/redent/3.0.0, MIT, approved, clearlydefined
npm/npmjs/-/regenerate-unicode-properties/10.1.0, MIT, approved, clearlydefined
npm/npmjs/-/regenerate-unicode-properties/10.1.0, MIT, approved, #10903
npm/npmjs/-/regenerate/1.4.2, MIT, approved, clearlydefined
npm/npmjs/-/regenerator-runtime/0.13.11, MIT, approved, #4978
npm/npmjs/-/regenerator-transform/0.15.1, MIT, approved, #5001
Expand Down Expand Up @@ -1492,34 +1492,34 @@ npm/npmjs/@types/babel__core/7.20.1, MIT, approved, clearlydefined
npm/npmjs/@types/babel__generator/7.6.4, MIT, approved, clearlydefined
npm/npmjs/@types/babel__template/7.4.1, MIT, approved, clearlydefined
npm/npmjs/@types/babel__traverse/7.20.1, MIT, approved, #8935
npm/npmjs/@types/body-parser/1.19.2, MIT, approved, clearlydefined
npm/npmjs/@types/body-parser/1.19.2, MIT, approved, #10831
npm/npmjs/@types/bonjour/3.5.10, MIT, approved, clearlydefined
npm/npmjs/@types/connect-history-api-fallback/1.5.0, MIT, approved, #8395
npm/npmjs/@types/connect/3.4.35, MIT, approved, clearlydefined
npm/npmjs/@types/eslint-scope/3.7.4, MIT, approved, clearlydefined
npm/npmjs/@types/eslint-scope/3.7.4, MIT, approved, #10812
npm/npmjs/@types/eslint/8.44.0, MIT, approved, #9382
npm/npmjs/@types/estree/0.0.39, MIT, approved, clearlydefined
npm/npmjs/@types/estree/1.0.1, MIT, approved, #8266
npm/npmjs/@types/express-serve-static-core/4.17.35, MIT, approved, #6020
npm/npmjs/@types/express/4.17.17, MIT, approved, #5760
npm/npmjs/@types/graceful-fs/4.1.6, MIT, approved, clearlydefined
npm/npmjs/@types/html-minifier-terser/6.1.0, MIT, approved, clearlydefined
npm/npmjs/@types/http-errors/2.0.1, MIT, approved, clearlydefined
npm/npmjs/@types/http-errors/2.0.1, MIT, approved, #10815
npm/npmjs/@types/http-proxy/1.17.11, MIT, approved, #8414
npm/npmjs/@types/istanbul-lib-coverage/2.0.4, MIT, approved, clearlydefined
npm/npmjs/@types/istanbul-lib-report/3.0.0, MIT, approved, clearlydefined
npm/npmjs/@types/istanbul-reports/3.0.1, MIT, approved, clearlydefined
npm/npmjs/@types/jest/29.5.2, MIT, approved, clearlydefined
npm/npmjs/@types/json-schema/7.0.12, MIT, approved, clearlydefined
npm/npmjs/@types/json5/0.0.29, MIT, approved, clearlydefined
npm/npmjs/@types/mime/1.3.2, MIT, approved, clearlydefined
npm/npmjs/@types/mime/1.3.2, MIT, approved, #10834
npm/npmjs/@types/node/20.3.1, MIT, approved, clearlydefined
npm/npmjs/@types/parse-json/4.0.0, MIT, approved, clearlydefined
npm/npmjs/@types/prettier/2.7.3, MIT, approved, #9030
npm/npmjs/@types/prop-types/15.7.5, MIT, approved, clearlydefined
npm/npmjs/@types/q/1.5.5, MIT, approved, clearlydefined
npm/npmjs/@types/qs/6.9.7, MIT, approved, clearlydefined
npm/npmjs/@types/range-parser/1.2.4, MIT, approved, clearlydefined
npm/npmjs/@types/range-parser/1.2.4, MIT, approved, #10795
npm/npmjs/@types/react-datepicker/4.11.2, MIT, approved, clearlydefined
npm/npmjs/@types/react-dom/18.2.6, MIT, approved, #8256
npm/npmjs/@types/react-native/0.72.2, MIT, approved, #9862
Expand All @@ -1529,8 +1529,8 @@ npm/npmjs/@types/react/18.2.13, MIT, approved, #8234
npm/npmjs/@types/resolve/1.17.1, MIT, approved, clearlydefined
npm/npmjs/@types/retry/0.12.0, MIT, approved, clearlydefined
npm/npmjs/@types/scheduler/0.16.3, MIT, approved, #7582
npm/npmjs/@types/semver/7.5.0, MIT, approved, clearlydefined
npm/npmjs/@types/send/0.17.1, MIT, approved, clearlydefined
npm/npmjs/@types/semver/7.5.0, MIT, approved, #10842
npm/npmjs/@types/send/0.17.1, MIT, approved, #10832
npm/npmjs/@types/serve-index/1.9.1, MIT, approved, clearlydefined
npm/npmjs/@types/serve-static/1.15.2, MIT, approved, #9188
npm/npmjs/@types/sockjs/0.3.33, MIT, approved, clearlydefined
Expand Down
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM jboss/keycloak:latest
ENV DOCKERIZE_VERSION v0.6.1
USER root
RUN microdnf install -y jq wget

# Copy the scripts to the container
COPY keycloak/generate-secret.sh /config/generate-secret.sh

# Make the scripts executable
RUN chmod +x /config/generate-secret.sh

# Switch back to the jboss user
USER jboss
47 changes: 46 additions & 1 deletion demand-capacity-mgmt-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,33 @@
<spring-cloud.version>2020.0.3-SNAPSHOT</spring-cloud.version>

</properties>

<dependencies>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.18.1</version> <!-- Use the latest version -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down Expand Up @@ -108,6 +133,19 @@

<build>
<plugins>
<plugin>
<groupId>org.eclipse.dash</groupId>
<artifactId>license-tool-plugin</artifactId>
<version>1.0.3-SNAPSHOT</version>
<executions>
<execution>
<id>license-check</id>
<goals>
<goal>license-check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.hubspot.maven.plugins</groupId>
<artifactId>prettier-maven-plugin</artifactId>
Expand Down Expand Up @@ -161,6 +199,13 @@
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>dash-licenses-snapshots</id>
<url>https://repo.eclipse.org/content/repositories/dash-licenses-snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend;

import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import eclipse.tractusx.demand_capacity_mgmt_specification.api.CompanyApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.CompanyDto;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.CompanyService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import eclipse.tractusx.demand_capacity_mgmt_specification.api.DemandCategoryApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.DemandCategoryResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.DemandCategoryService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
import eclipse.tractusx.demand_capacity_mgmt_specification.api.FavoriteApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.FavoriteRequest;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.FavoriteResponse;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.UUID;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.FavoriteType;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.FavoriteService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.utils.CookieUtil;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -39,37 +41,42 @@ public class FavoriteController implements FavoriteApi {

private final FavoriteService favoriteService;

private HttpServletRequest request;

@Override
public ResponseEntity<FavoriteResponse> createFavorite(FavoriteRequest favoriteRequest) throws Exception {
FavoriteResponse response = favoriteService.createFavorite(favoriteRequest);
public ResponseEntity<FavoriteResponse> createFavorite(FavoriteRequest favoriteRequest) {
FavoriteResponse response = favoriteService.createFavorite(
favoriteRequest,
CookieUtil.getCookieUserID(request)
);
return ResponseEntity.status(200).body(response);
}

@Override
public ResponseEntity<Void> deleteFavoriteById(String id) throws Exception {
favoriteService.deleteFavorite(UUID.fromString(id));
public ResponseEntity<Void> deleteFavoriteById(String id) {
favoriteService.deleteFavorite(UUID.fromString(id), CookieUtil.getCookieUserID(request));
return ResponseEntity.status(200).build();
}

@Override
public ResponseEntity<List<FavoriteResponse>> getFavorite() throws Exception {
public ResponseEntity<List<FavoriteResponse>> getFavorite() {
List<FavoriteResponse> responseList = favoriteService.getAllFavorites();
return ResponseEntity.status(200).body(responseList);
}

@Override
public ResponseEntity<List<FavoriteResponse>> getFavoriteByType(String type) throws Exception {
public ResponseEntity<List<FavoriteResponse>> getFavoriteByType(String type) {
List<FavoriteResponse> responseList = favoriteService.getAllFavoritesByType(type);
return ResponseEntity.status(200).body(responseList);
}

@Override
public ResponseEntity<FavoriteResponse> updateFavorite(String id, String type, FavoriteRequest favoriteRequest)
throws Exception {
public ResponseEntity<FavoriteResponse> updateFavorite(String id, String type, FavoriteRequest favoriteRequest) {
FavoriteResponse response = favoriteService.updateFavorite(
UUID.fromString(id),
FavoriteType.valueOf(type),
favoriteRequest
favoriteRequest,
CookieUtil.getCookieUserID(request)
);
return ResponseEntity.status(200).body(response);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* ******************************************************************************
* Copyright (c) 2023 BMW AG
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
* *******************************************************************************
*/

package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.controllers;

import eclipse.tractusx.demand_capacity_mgmt_specification.api.KeycloakApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.IntrospectTokenResponse;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.User;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import jakarta.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.SecurityTokenService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
public class SecurityTokenController implements KeycloakApi {

private final SecurityTokenService securityTokenService;
private HttpServletRequest request;

@Override
public ResponseEntity<IntrospectTokenResponse> introspectToken(String authToken) {
return ResponseEntity.ok(securityTokenService.introspectToken(request));
}

@Override
public ResponseEntity<User> loginToken(String username, String password) {
return securityTokenService.generateUserResponseEntity(username, password, request);
}

@Override
public ResponseEntity<Void> logoutToken() {
return securityTokenService.generateLogoutResponseEntity(request);
}

@Override
public ResponseEntity<User> refreshToken(String refreshToken) {
return securityTokenService.generateUserRefreshedResponseEntity(refreshToken, request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import eclipse.tractusx.demand_capacity_mgmt_specification.api.UnitMeasureApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.UnitMeasure;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.UnityOfMeasureService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.controllers;

import eclipse.tractusx.demand_capacity_mgmt_specification.api.WeekBasedCapacityGroupApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.*;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedCapacityGroupDtoRequest;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedCapacityGroupDtoResponse;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedCapacityGroupRequest;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.WeekBasedCapacityGroupService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import eclipse.tractusx.demand_capacity_mgmt_specification.api.WeekBasedMaterialDemandApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedMaterialDemandRequestDto;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedMaterialDemandResponseDto;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.WeekBasedMaterialService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,10 @@

package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities;

import jakarta.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.*;

@Entity
@Table(name = "capacity_group")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,9 @@

package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities;

import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities;

import jakarta.persistence.*;
import java.util.UUID;
import javax.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@

package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities;

import jakarta.persistence.*;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down
Loading

0 comments on commit dbb9d8e

Please sign in to comment.