mirror of
https://github.com/gotson/komga.git
synced 2025-01-08 11:47:47 +08:00
refactor: address deprecations
This commit is contained in:
parent
a7ae8c75b3
commit
225f58f81c
@ -39,7 +39,7 @@ class KomgaSettingsProvider(
|
|||||||
rememberMeKey = getRandomRememberMeKey()
|
rememberMeKey = getRandomRememberMeKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRandomRememberMeKey() = RandomStringUtils.randomAlphanumeric(32)
|
private fun getRandomRememberMeKey() = RandomStringUtils.secure().nextAlphanumeric(32)
|
||||||
|
|
||||||
var rememberMeDuration: Duration =
|
var rememberMeDuration: Duration =
|
||||||
(serverSettingsDao.getSettingByKey(Settings.REMEMBER_ME_DURATION.name, Int::class.java) ?: 365).days
|
(serverSettingsDao.getSettingByKey(Settings.REMEMBER_ME_DURATION.name, Int::class.java) ?: 365).days
|
||||||
|
@ -18,7 +18,7 @@ import javax.sql.DataSource
|
|||||||
// taken from https://github.com/spring-projects/spring-boot/blob/v3.1.4/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java
|
// taken from https://github.com/spring-projects/spring-boot/blob/v3.1.4/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java
|
||||||
// as advised in https://docs.spring.io/spring-boot/docs/3.1.4/reference/htmlsingle/#howto.data-access.configure-jooq-with-multiple-datasources
|
// as advised in https://docs.spring.io/spring-boot/docs/3.1.4/reference/htmlsingle/#howto.data-access.configure-jooq-with-multiple-datasources
|
||||||
@Configuration
|
@Configuration
|
||||||
class JooqConfiguration {
|
class KomgaJooqConfiguration {
|
||||||
@Bean("dslContext")
|
@Bean("dslContext")
|
||||||
@Primary
|
@Primary
|
||||||
fun mainDslContext(
|
fun mainDslContext(
|
@ -7,11 +7,12 @@ import org.gotson.komga.infrastructure.configuration.KomgaSettingsProvider
|
|||||||
import org.gotson.komga.infrastructure.kobo.KoboHeaders.X_KOBO_SYNCTOKEN
|
import org.gotson.komga.infrastructure.kobo.KoboHeaders.X_KOBO_SYNCTOKEN
|
||||||
import org.gotson.komga.infrastructure.web.getCurrentRequest
|
import org.gotson.komga.infrastructure.web.getCurrentRequest
|
||||||
import org.gotson.komga.language.contains
|
import org.gotson.komga.language.contains
|
||||||
|
import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder
|
||||||
|
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings
|
||||||
import org.springframework.http.HttpHeaders
|
import org.springframework.http.HttpHeaders
|
||||||
import org.springframework.http.HttpMethod
|
import org.springframework.http.HttpMethod
|
||||||
import org.springframework.http.HttpStatusCode
|
import org.springframework.http.HttpStatusCode
|
||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.http.client.ReactorNettyClientRequestFactory
|
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
import org.springframework.util.LinkedMultiValueMap
|
import org.springframework.util.LinkedMultiValueMap
|
||||||
import org.springframework.web.client.RestClient
|
import org.springframework.web.client.RestClient
|
||||||
@ -32,11 +33,11 @@ class KoboProxy(
|
|||||||
RestClient.builder()
|
RestClient.builder()
|
||||||
.baseUrl("https://storeapi.kobo.com")
|
.baseUrl("https://storeapi.kobo.com")
|
||||||
.requestFactory(
|
.requestFactory(
|
||||||
ReactorNettyClientRequestFactory().apply {
|
ClientHttpRequestFactoryBuilder.reactor().build(
|
||||||
setConnectTimeout(1.minutes.toJavaDuration())
|
ClientHttpRequestFactorySettings.defaults()
|
||||||
setReadTimeout(1.minutes.toJavaDuration())
|
.withReadTimeout(1.minutes.toJavaDuration())
|
||||||
setExchangeTimeout(1.minutes.toJavaDuration())
|
.withConnectTimeout(1.minutes.toJavaDuration()),
|
||||||
},
|
),
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class KomgaOAuth2UserServiceConfiguration(
|
|||||||
private fun tryCreateNewUser(email: String) =
|
private fun tryCreateNewUser(email: String) =
|
||||||
if (komgaProperties.oauth2AccountCreation) {
|
if (komgaProperties.oauth2AccountCreation) {
|
||||||
logger.info { "Creating new user from OAuth2 login: $email" }
|
logger.info { "Creating new user from OAuth2 login: $email" }
|
||||||
userLifecycle.createUser(KomgaUser(email, RandomStringUtils.randomAlphanumeric(12), roleAdmin = false))
|
userLifecycle.createUser(KomgaUser(email, RandomStringUtils.secure().nextAlphanumeric(12), roleAdmin = false))
|
||||||
} else {
|
} else {
|
||||||
throw OAuth2AuthenticationException("ERR_1025")
|
throw OAuth2AuthenticationException("ERR_1025")
|
||||||
}
|
}
|
||||||
|
@ -228,8 +228,8 @@ class KoboController(
|
|||||||
* Return dummy data to keep the device happy.
|
* Return dummy data to keep the device happy.
|
||||||
*/
|
*/
|
||||||
return AuthDto(
|
return AuthDto(
|
||||||
accessToken = RandomStringUtils.randomAlphanumeric(24),
|
accessToken = RandomStringUtils.secure().nextAlphanumeric(24),
|
||||||
refreshToken = RandomStringUtils.randomAlphanumeric(24),
|
refreshToken = RandomStringUtils.secure().nextAlphanumeric(24),
|
||||||
trackingId = UUID.randomUUID().toString(),
|
trackingId = UUID.randomUUID().toString(),
|
||||||
userKey = body.get("UserKey")?.asText() ?: "",
|
userKey = body.get("UserKey")?.asText() ?: "",
|
||||||
)
|
)
|
||||||
@ -688,7 +688,7 @@ class KoboController(
|
|||||||
if (!thumbnailBookRepository.existsById(thumbnailId) && koboProxy.isEnabled()) {
|
if (!thumbnailBookRepository.existsById(thumbnailId) && koboProxy.isEnabled()) {
|
||||||
ResponseEntity
|
ResponseEntity
|
||||||
.status(HttpStatus.TEMPORARY_REDIRECT)
|
.status(HttpStatus.TEMPORARY_REDIRECT)
|
||||||
.location(UriComponentsBuilder.fromHttpUrl(koboProxy.imageHostUrl).buildAndExpand(thumbnailId, width, height).toUri())
|
.location(UriComponentsBuilder.fromUriString(koboProxy.imageHostUrl).buildAndExpand(thumbnailId, width, height).toUri())
|
||||||
.build()
|
.build()
|
||||||
} else {
|
} else {
|
||||||
val poster = bookLifecycle.getThumbnailBytesByThumbnailId(thumbnailId) ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
|
val poster = bookLifecycle.getThumbnailBytesByThumbnailId(thumbnailId) ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
|
||||||
|
@ -416,7 +416,7 @@ class Opds2Controller(
|
|||||||
@PathVariable(name = "id", required = false) libraryId: String?,
|
@PathVariable(name = "id", required = false) libraryId: String?,
|
||||||
@Parameter(hidden = true) page: Pageable,
|
@Parameter(hidden = true) page: Pageable,
|
||||||
): FeedDto {
|
): FeedDto {
|
||||||
val (library, authorizedLibraryIds) = checkLibraryAccess(libraryId, principal)
|
val (library, _) = checkLibraryAccess(libraryId, principal)
|
||||||
|
|
||||||
val entries =
|
val entries =
|
||||||
seriesDtoRepository.findAll(
|
seriesDtoRepository.findAll(
|
||||||
|
@ -50,6 +50,6 @@ class InitialUsersProdConfiguration {
|
|||||||
@Bean
|
@Bean
|
||||||
fun initialUsers(): List<KomgaUser> =
|
fun initialUsers(): List<KomgaUser> =
|
||||||
listOf(
|
listOf(
|
||||||
KomgaUser("admin@example.org", RandomStringUtils.randomAlphanumeric(12), roleAdmin = true),
|
KomgaUser("admin@example.org", RandomStringUtils.secure().nextAlphanumeric(12), roleAdmin = true),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ management:
|
|||||||
roles: ADMIN
|
roles: ADMIN
|
||||||
show-details: when_authorized
|
show-details: when_authorized
|
||||||
shutdown:
|
shutdown:
|
||||||
enabled: true
|
access: unrestricted
|
||||||
info:
|
info:
|
||||||
java:
|
java:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
Loading…
Reference in New Issue
Block a user