mirror of
https://github.com/gotson/komga.git
synced 2025-12-06 16:42:24 +01:00
docs(api): add missing global security requirements
This commit is contained in:
parent
7f9dc5c97c
commit
51c4617cc4
7 changed files with 47 additions and 10 deletions
|
|
@ -14,22 +14,30 @@
|
||||||
"url": "https://komga.org"
|
"url": "https://komga.org"
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://demo.komga.org",
|
||||||
|
"description": "Demo server"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"url": "http://localhost:{port}",
|
"url": "http://localhost:{port}",
|
||||||
"description": "Local development server",
|
"description": "Local development server",
|
||||||
"variables": {
|
"variables": {
|
||||||
"port": {
|
"port": {
|
||||||
|
"default": "25600",
|
||||||
"enum": [
|
"enum": [
|
||||||
"8080",
|
"8080",
|
||||||
"25600"
|
"25600"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"default": "25600"
|
"security": [
|
||||||
}
|
{
|
||||||
}
|
"basicAuth": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "https://demo.komga.org",
|
"apiKey": []
|
||||||
"description": "Demo server"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
|
|
@ -2100,6 +2108,7 @@
|
||||||
"description": "Bad Request"
|
"description": "Bad Request"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security": [],
|
||||||
"summary": "Get Epub resource",
|
"summary": "Get Epub resource",
|
||||||
"tags": [
|
"tags": [
|
||||||
"WebPub Manifest"
|
"WebPub Manifest"
|
||||||
|
|
@ -2428,6 +2437,7 @@
|
||||||
"description": "Bad Request"
|
"description": "Bad Request"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security": [],
|
||||||
"summary": "Retrieve claim status",
|
"summary": "Retrieve claim status",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Claim server"
|
"Claim server"
|
||||||
|
|
@ -2476,6 +2486,7 @@
|
||||||
"description": "Bad Request"
|
"description": "Bad Request"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security": [],
|
||||||
"summary": "Claim server",
|
"summary": "Claim server",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Claim server"
|
"Claim server"
|
||||||
|
|
@ -2600,6 +2611,7 @@
|
||||||
"description": "Bad Request"
|
"description": "Bad Request"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security": [],
|
||||||
"summary": "Retrieve global client settings",
|
"summary": "Retrieve global client settings",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Client settings"
|
"Client settings"
|
||||||
|
|
@ -3574,6 +3586,7 @@
|
||||||
"description": "Bad Request"
|
"description": "Bad Request"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security": [],
|
||||||
"summary": "Download CSS file",
|
"summary": "Download CSS file",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Fonts"
|
"Fonts"
|
||||||
|
|
@ -3624,6 +3637,7 @@
|
||||||
"description": "Bad Request"
|
"description": "Bad Request"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security": [],
|
||||||
"summary": "Download font file",
|
"summary": "Download font file",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Fonts"
|
"Fonts"
|
||||||
|
|
@ -4238,6 +4252,7 @@
|
||||||
"description": "Bad Request"
|
"description": "Bad Request"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security": [],
|
||||||
"summary": "List registered OAuth2 providers",
|
"summary": "List registered OAuth2 providers",
|
||||||
"tags": [
|
"tags": [
|
||||||
"OAuth2"
|
"OAuth2"
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import io.swagger.v3.oas.models.info.Info
|
||||||
import io.swagger.v3.oas.models.info.License
|
import io.swagger.v3.oas.models.info.License
|
||||||
import io.swagger.v3.oas.models.responses.ApiResponse
|
import io.swagger.v3.oas.models.responses.ApiResponse
|
||||||
import io.swagger.v3.oas.models.responses.ApiResponses
|
import io.swagger.v3.oas.models.responses.ApiResponses
|
||||||
|
import io.swagger.v3.oas.models.security.SecurityRequirement
|
||||||
import io.swagger.v3.oas.models.security.SecurityScheme
|
import io.swagger.v3.oas.models.security.SecurityScheme
|
||||||
import io.swagger.v3.oas.models.servers.Server
|
import io.swagger.v3.oas.models.servers.Server
|
||||||
import io.swagger.v3.oas.models.servers.ServerVariable
|
import io.swagger.v3.oas.models.servers.ServerVariable
|
||||||
|
|
@ -109,21 +110,29 @@ class OpenApiConfiguration(
|
||||||
).components(
|
).components(
|
||||||
Components()
|
Components()
|
||||||
.addSecuritySchemes(
|
.addSecuritySchemes(
|
||||||
"basicAuth",
|
SecuritySchemes.BASIC_AUTH,
|
||||||
SecurityScheme()
|
SecurityScheme()
|
||||||
.type(SecurityScheme.Type.HTTP)
|
.type(SecurityScheme.Type.HTTP)
|
||||||
.scheme("basic"),
|
.scheme("basic"),
|
||||||
).addSecuritySchemes(
|
).addSecuritySchemes(
|
||||||
"apiKey",
|
SecuritySchemes.API_KEY,
|
||||||
SecurityScheme()
|
SecurityScheme()
|
||||||
.type(SecurityScheme.Type.APIKEY)
|
.type(SecurityScheme.Type.APIKEY)
|
||||||
.`in`(SecurityScheme.In.HEADER)
|
.`in`(SecurityScheme.In.HEADER)
|
||||||
.name("X-API-Key"),
|
.name("X-API-Key"),
|
||||||
),
|
),
|
||||||
|
).security(
|
||||||
|
listOf(
|
||||||
|
SecurityRequirement().addList(SecuritySchemes.BASIC_AUTH),
|
||||||
|
SecurityRequirement().addList(SecuritySchemes.API_KEY),
|
||||||
|
),
|
||||||
).tags(tags)
|
).tags(tags)
|
||||||
.extensions(mapOf("x-tagGroups" to tagGroups))
|
.extensions(mapOf("x-tagGroups" to tagGroups))
|
||||||
.servers(
|
.servers(
|
||||||
listOf(
|
listOf(
|
||||||
|
Server()
|
||||||
|
.url("https://demo.komga.org")
|
||||||
|
.description("Demo server"),
|
||||||
Server()
|
Server()
|
||||||
.url("http://localhost:{port}")
|
.url("http://localhost:{port}")
|
||||||
.description("Local development server")
|
.description("Local development server")
|
||||||
|
|
@ -137,9 +146,6 @@ class OpenApiConfiguration(
|
||||||
._default("25600"),
|
._default("25600"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Server()
|
|
||||||
.url("https://demo.komga.org")
|
|
||||||
.description("Demo server"),
|
|
||||||
),
|
),
|
||||||
).path(
|
).path(
|
||||||
"/api/logout",
|
"/api/logout",
|
||||||
|
|
@ -249,6 +255,11 @@ class OpenApiConfiguration(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
object SecuritySchemes {
|
||||||
|
const val BASIC_AUTH = "basicAuth"
|
||||||
|
const val API_KEY = "apiKey"
|
||||||
|
}
|
||||||
|
|
||||||
object TagNames {
|
object TagNames {
|
||||||
const val DEPRECATED = "Deprecated"
|
const val DEPRECATED = "Deprecated"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package org.gotson.komga.interfaces.api
|
||||||
|
|
||||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||||
import io.swagger.v3.oas.annotations.Operation
|
import io.swagger.v3.oas.annotations.Operation
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirements
|
||||||
import jakarta.servlet.http.HttpServletRequest
|
import jakarta.servlet.http.HttpServletRequest
|
||||||
import org.apache.commons.io.FilenameUtils
|
import org.apache.commons.io.FilenameUtils
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
|
|
@ -255,6 +256,7 @@ class CommonBookController(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "Get Epub resource", description = "Return a resource from within an Epub book.", tags = [OpenApiConfiguration.TagNames.BOOK_WEBPUB])
|
@Operation(summary = "Get Epub resource", description = "Return a resource from within an Epub book.", tags = [OpenApiConfiguration.TagNames.BOOK_WEBPUB])
|
||||||
|
@SecurityRequirements
|
||||||
@GetMapping(
|
@GetMapping(
|
||||||
value = [
|
value = [
|
||||||
"api/v1/books/{bookId}/resource/{*resource}",
|
"api/v1/books/{bookId}/resource/{*resource}",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gotson.komga.interfaces.api.rest
|
package org.gotson.komga.interfaces.api.rest
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation
|
import io.swagger.v3.oas.annotations.Operation
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirements
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag
|
import io.swagger.v3.oas.annotations.tags.Tag
|
||||||
import jakarta.validation.constraints.Email
|
import jakarta.validation.constraints.Email
|
||||||
import jakarta.validation.constraints.NotBlank
|
import jakarta.validation.constraints.NotBlank
|
||||||
|
|
@ -24,6 +25,7 @@ import org.springframework.web.server.ResponseStatusException
|
||||||
@RequestMapping("api/v1/claim", produces = [MediaType.APPLICATION_JSON_VALUE])
|
@RequestMapping("api/v1/claim", produces = [MediaType.APPLICATION_JSON_VALUE])
|
||||||
@Tag(name = OpenApiConfiguration.TagNames.CLAIM)
|
@Tag(name = OpenApiConfiguration.TagNames.CLAIM)
|
||||||
@Validated
|
@Validated
|
||||||
|
@SecurityRequirements
|
||||||
class ClaimController(
|
class ClaimController(
|
||||||
private val userDetailsLifecycle: KomgaUserLifecycle,
|
private val userDetailsLifecycle: KomgaUserLifecycle,
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package org.gotson.komga.interfaces.api.rest
|
||||||
import io.swagger.v3.oas.annotations.Operation
|
import io.swagger.v3.oas.annotations.Operation
|
||||||
import io.swagger.v3.oas.annotations.media.Content
|
import io.swagger.v3.oas.annotations.media.Content
|
||||||
import io.swagger.v3.oas.annotations.media.ExampleObject
|
import io.swagger.v3.oas.annotations.media.ExampleObject
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirements
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag
|
import io.swagger.v3.oas.annotations.tags.Tag
|
||||||
import jakarta.validation.Valid
|
import jakarta.validation.Valid
|
||||||
import jakarta.validation.constraints.NotNull
|
import jakarta.validation.constraints.NotNull
|
||||||
|
|
@ -38,6 +39,7 @@ class ClientSettingsController(
|
||||||
) {
|
) {
|
||||||
@GetMapping("global/list")
|
@GetMapping("global/list")
|
||||||
@Operation(summary = "Retrieve global client settings", description = "For unauthenticated users, only settings with 'allowUnauthorized=true' will be returned.")
|
@Operation(summary = "Retrieve global client settings", description = "For unauthenticated users, only settings with 'allowUnauthorized=true' will be returned.")
|
||||||
|
@SecurityRequirements
|
||||||
fun getGlobalSettings(
|
fun getGlobalSettings(
|
||||||
@AuthenticationPrincipal principal: KomgaPrincipal?,
|
@AuthenticationPrincipal principal: KomgaPrincipal?,
|
||||||
): Map<String, ClientSettingDto> = clientSettingsDtoDao.findAllGlobal(principal == null)
|
): Map<String, ClientSettingDto> = clientSettingsDtoDao.findAllGlobal(principal == null)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package org.gotson.komga.interfaces.api.rest
|
||||||
|
|
||||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||||
import io.swagger.v3.oas.annotations.Operation
|
import io.swagger.v3.oas.annotations.Operation
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirements
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag
|
import io.swagger.v3.oas.annotations.tags.Tag
|
||||||
import org.apache.commons.io.FilenameUtils
|
import org.apache.commons.io.FilenameUtils
|
||||||
import org.gotson.komga.infrastructure.configuration.KomgaProperties
|
import org.gotson.komga.infrastructure.configuration.KomgaProperties
|
||||||
|
|
@ -91,6 +92,7 @@ class FontsController(
|
||||||
|
|
||||||
@GetMapping("resource/{fontFamily}/{fontFile}")
|
@GetMapping("resource/{fontFamily}/{fontFile}")
|
||||||
@Operation(summary = "Download font file")
|
@Operation(summary = "Download font file")
|
||||||
|
@SecurityRequirements
|
||||||
fun getFontFile(
|
fun getFontFile(
|
||||||
@PathVariable fontFamily: String,
|
@PathVariable fontFamily: String,
|
||||||
@PathVariable fontFile: String,
|
@PathVariable fontFile: String,
|
||||||
|
|
@ -113,6 +115,7 @@ class FontsController(
|
||||||
|
|
||||||
@GetMapping("resource/{fontFamily}/css", produces = ["text/css"])
|
@GetMapping("resource/{fontFamily}/css", produces = ["text/css"])
|
||||||
@Operation(summary = "Download CSS file", description = "Download a CSS file with the @font-face block for the font family. This is used by the Epub Reader to change fonts.")
|
@Operation(summary = "Download CSS file", description = "Download a CSS file with the @font-face block for the font family. This is used by the Epub Reader to change fonts.")
|
||||||
|
@SecurityRequirements
|
||||||
fun getFontFamilyAsCss(
|
fun getFontFamilyAsCss(
|
||||||
@PathVariable fontFamily: String,
|
@PathVariable fontFamily: String,
|
||||||
): ResponseEntity<Resource> {
|
): ResponseEntity<Resource> {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gotson.komga.interfaces.api.rest
|
package org.gotson.komga.interfaces.api.rest
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation
|
import io.swagger.v3.oas.annotations.Operation
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirements
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag
|
import io.swagger.v3.oas.annotations.tags.Tag
|
||||||
import org.gotson.komga.infrastructure.swagger.OpenApiConfiguration
|
import org.gotson.komga.infrastructure.swagger.OpenApiConfiguration
|
||||||
import org.springframework.http.MediaType
|
import org.springframework.http.MediaType
|
||||||
|
|
@ -12,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("api/v1/oauth2", produces = [MediaType.APPLICATION_JSON_VALUE])
|
@RequestMapping("api/v1/oauth2", produces = [MediaType.APPLICATION_JSON_VALUE])
|
||||||
@Tag(name = OpenApiConfiguration.TagNames.OAUTH2)
|
@Tag(name = OpenApiConfiguration.TagNames.OAUTH2)
|
||||||
|
@SecurityRequirements
|
||||||
class OAuth2Controller(
|
class OAuth2Controller(
|
||||||
clientRegistrationRepository: InMemoryClientRegistrationRepository?,
|
clientRegistrationRepository: InMemoryClientRegistrationRepository?,
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue