Permanently disable Swagger API docs
This commit is contained in:
@@ -14,7 +14,6 @@ public class AppProperties {
|
|||||||
private String bookdropFolder;
|
private String bookdropFolder;
|
||||||
private String version;
|
private String version;
|
||||||
private RemoteAuth remoteAuth;
|
private RemoteAuth remoteAuth;
|
||||||
private Swagger swagger = new Swagger();
|
|
||||||
private Boolean forceDisableOidc = false;
|
private Boolean forceDisableOidc = false;
|
||||||
private Telemetry telemetry = new Telemetry();
|
private Telemetry telemetry = new Telemetry();
|
||||||
|
|
||||||
@@ -39,12 +38,6 @@ public class AppProperties {
|
|||||||
private String groupsDelimiter = "\\s+"; // Default to whitespace for backward compatibility
|
private String groupsDelimiter = "\\s+"; // Default to whitespace for backward compatibility
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public static class Swagger {
|
|
||||||
private boolean enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public static class Telemetry {
|
public static class Telemetry {
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
package org.booklore.config;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.models.Components;
|
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
|
||||||
import io.swagger.v3.oas.models.info.Contact;
|
|
||||||
import io.swagger.v3.oas.models.info.Info;
|
|
||||||
import io.swagger.v3.oas.models.info.License;
|
|
||||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
|
||||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
|
||||||
import io.swagger.v3.oas.models.servers.Server;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class OpenApiConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public OpenAPI customOpenAPI() {
|
|
||||||
final String securitySchemeName = "bearerAuth";
|
|
||||||
|
|
||||||
return new OpenAPI()
|
|
||||||
.info(new Info()
|
|
||||||
.title("Booklore API")
|
|
||||||
.version("1.0")
|
|
||||||
.description("Booklore is a personal library management system. This API allows you to manage books, libraries, users, shelves, and more.")
|
|
||||||
.contact(new Contact()
|
|
||||||
.name("Booklore")
|
|
||||||
.url("https://github.com/booklore-app/booklore"))
|
|
||||||
.license(new License()
|
|
||||||
.name("GNU General Public License v3.0")
|
|
||||||
.url("https://www.gnu.org/licenses/gpl-3.0.html"))
|
|
||||||
)
|
|
||||||
.addServersItem(new Server().url("/").description("Current server"))
|
|
||||||
.addSecurityItem(new SecurityRequirement().addList(securitySchemeName))
|
|
||||||
.components(new Components().addSecuritySchemes(securitySchemeName,
|
|
||||||
new SecurityScheme()
|
|
||||||
.name(securitySchemeName)
|
|
||||||
.type(SecurityScheme.Type.HTTP)
|
|
||||||
.scheme("bearer")
|
|
||||||
.bearerFormat("JWT")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.booklore.config.security;
|
package org.booklore.config.security;
|
||||||
|
|
||||||
import org.booklore.config.AppProperties;
|
|
||||||
import org.booklore.config.security.filter.*;
|
import org.booklore.config.security.filter.*;
|
||||||
import org.booklore.config.security.service.OpdsUserDetailsService;
|
import org.booklore.config.security.service.OpdsUserDetailsService;
|
||||||
import jakarta.servlet.DispatcherType;
|
import jakarta.servlet.DispatcherType;
|
||||||
@@ -35,13 +34,6 @@ public class SecurityConfig {
|
|||||||
|
|
||||||
private final OpdsUserDetailsService opdsUserDetailsService;
|
private final OpdsUserDetailsService opdsUserDetailsService;
|
||||||
private final DualJwtAuthenticationFilter dualJwtAuthenticationFilter;
|
private final DualJwtAuthenticationFilter dualJwtAuthenticationFilter;
|
||||||
private final AppProperties appProperties;
|
|
||||||
|
|
||||||
private static final String[] SWAGGER_ENDPOINTS = {
|
|
||||||
"/api/v1/swagger-ui.html",
|
|
||||||
"/api/v1/swagger-ui/**",
|
|
||||||
"/api/v1/api-docs/**"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final String[] COMMON_PUBLIC_ENDPOINTS = {
|
private static final String[] COMMON_PUBLIC_ENDPOINTS = {
|
||||||
"/ws/**", // WebSocket connections (auth handled in WebSocketAuthInterceptor)
|
"/ws/**", // WebSocket connections (auth handled in WebSocketAuthInterceptor)
|
||||||
@@ -200,9 +192,6 @@ public class SecurityConfig {
|
|||||||
@Order(8)
|
@Order(8)
|
||||||
public SecurityFilterChain jwtApiSecurityChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain jwtApiSecurityChain(HttpSecurity http) throws Exception {
|
||||||
List<String> publicEndpoints = new ArrayList<>(Arrays.asList(COMMON_PUBLIC_ENDPOINTS));
|
List<String> publicEndpoints = new ArrayList<>(Arrays.asList(COMMON_PUBLIC_ENDPOINTS));
|
||||||
if (appProperties.getSwagger().isEnabled()) {
|
|
||||||
publicEndpoints.addAll(Arrays.asList(SWAGGER_ENDPOINTS));
|
|
||||||
}
|
|
||||||
http
|
http
|
||||||
.securityMatcher("/api/**", "/komga/**", "/ws/**")
|
.securityMatcher("/api/**", "/komga/**", "/ws/**")
|
||||||
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
|
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ app:
|
|||||||
path-config: '/app/data'
|
path-config: '/app/data'
|
||||||
bookdrop-folder: '/bookdrop'
|
bookdrop-folder: '/bookdrop'
|
||||||
version: 'development'
|
version: 'development'
|
||||||
swagger:
|
|
||||||
enabled: ${SWAGGER_ENABLED:false}
|
|
||||||
remote-auth:
|
remote-auth:
|
||||||
enabled: ${REMOTE_AUTH_ENABLED:false}
|
enabled: ${REMOTE_AUTH_ENABLED:false}
|
||||||
create-new-users: ${REMOTE_AUTH_CREATE_NEW_USERS:true}
|
create-new-users: ${REMOTE_AUTH_CREATE_NEW_USERS:true}
|
||||||
@@ -70,11 +68,10 @@ spring:
|
|||||||
locations: classpath:db/migration
|
locations: classpath:db/migration
|
||||||
|
|
||||||
springdoc:
|
springdoc:
|
||||||
swagger-ui:
|
|
||||||
path: /api/v1/swagger-ui.html
|
|
||||||
persist-authorization: true
|
|
||||||
api-docs:
|
api-docs:
|
||||||
path: /api/v1/api-docs
|
enabled: false
|
||||||
|
swagger-ui:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
|
|||||||
Reference in New Issue
Block a user