Skip to content

Commit

Permalink
Merge pull request Onlineberatung#70 from Onlineberatung/VIC-1891_Fix…
Browse files Browse the repository at this point in the history
…_Swagger_UI_after_CVEs_fixes

fix:VIC-1891 Fix Swagger UI after CVEs fixes
  • Loading branch information
idrissnaji authored Nov 11, 2022
2 parents 61465b1 + 0584625 commit e732ab8
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 37 deletions.
18 changes: 3 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
<!-- force at least version 2.16 due to https://logging.apache.org/log4j/2.x/security.html -->
<log4j.version>2.17.1</log4j.version>
<jackson-databind-nullable.version>0.2.3</jackson-databind-nullable.version>
<springfox-bean-validators.version>3.0.0</springfox-bean-validators.version>
<springfox-swagger-ui.version>3.0.0</springfox-swagger-ui.version>
<springfox-swagger2.version>3.0.0</springfox-swagger2.version>
<spring-security.version>5.7.5</spring-security.version>
<openapi-generator-maven-plugin.version>5.1.1</openapi-generator-maven-plugin.version>
<springfox-boot-starter.version>3.0.0</springfox-boot-starter.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -77,18 +75,8 @@
<!-- SpringFox: generate YAML file from POJOs and generate documentation -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${springfox-bean-validators.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-swagger-ui.version}</version>
<artifactId>springfox-boot-starter</artifactId>
<version>${springfox-boot-starter.version}</version>
</dependency>

<!-- Keycloak dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class CustomSwaggerPathWebMvcConfigurer implements WebMvcConfigurer {

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler(docuPath + "/swagger-ui/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
registry.addResourceHandler(docuPath + "/**")
.addResourceLocations("classpath:/META-INF/resources/");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
* Provides the SpringFox (API documentation generation) configuration.
*/
@Configuration
@EnableSwagger2
@Import(BeanValidatorPluginsConfiguration.class)
public class SpringFoxConfig {

Expand All @@ -47,7 +45,7 @@ public class SpringFoxConfig {
// without authorization
public static final String[] WHITE_LIST =
new String[] {"/mails/docs", "/mails/docs/**", "/v2/api-docs", "/configuration/ui",
"/swagger-resources/**", "/configuration/security", "/swagger-ui.html", "/webjars/**"};
"/swagger-resources/**", "/configuration/security", "/swagger-ui", "/swagger-ui/**", "/webjars/**"};

@Bean
public Docket apiDocket() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.caritas.cob.liveservice.api.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import springfox.documentation.annotations.ApiIgnore;
import springfox.documentation.swagger.web.ApiResourceController;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

@Controller
@ApiIgnore
@RequestMapping(value = "${springfox.docuPath}" + "/swagger-resources")
public class CustomSwaggerApiResourceController extends ApiResourceController {

public static final String SWAGGER_UI_BASE_URL = "/liveevent/docs";

public CustomSwaggerApiResourceController(SwaggerResourcesProvider swaggerResources) {
super(swaggerResources, SWAGGER_UI_BASE_URL);
}

}

This file was deleted.

1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ springfox.docuContactEmail=
springfox.docuLicense=Apache 2.0
springfox.docuLicenseUrl=http://www.apache.org/licenses/LICENSE-2.0.html
springfox.docuPath=/liveevent/docs
springfox.documentation.swagger.v2.path=${springfox.docuPath}/v2/api-docs

live.event.retry.send.cron=*/5 * * * * ?
live.event.retry.amount=5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import com.fasterxml.jackson.databind.ObjectMapper;
import de.caritas.cob.liveservice.api.controller.CustomSwaggerApiResourceController;
import de.caritas.cob.liveservice.api.model.LiveEventMessage;
import de.caritas.cob.liveservice.api.model.VideoCallRequestDTO;
import de.caritas.cob.liveservice.websocket.model.WebSocketUserSession;
Expand All @@ -31,6 +32,7 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.messaging.simp.stomp.StompSession;
import org.springframework.messaging.simp.stomp.StompSession.Subscription;
import org.springframework.test.context.TestPropertySource;
Expand All @@ -40,6 +42,9 @@
@TestPropertySource(properties = "spring.profiles.active=testing")
class LiveServiceApplicationIT extends StompClientIntegrationTest {

@MockBean
private CustomSwaggerApiResourceController customSwaggerApiResourceController;

@Autowired
private SocketUserRegistry socketUserRegistry;

Expand Down

0 comments on commit e732ab8

Please sign in to comment.