mirror of
https://github.com/gotson/komga.git
synced 2025-01-07 03:07:16 +08:00
refactor: address deprecations
This commit is contained in:
parent
a7ae8c75b3
commit
225f58f81c
@ -39,7 +39,7 @@ class KomgaSettingsProvider(
|
||||
rememberMeKey = getRandomRememberMeKey()
|
||||
}
|
||||
|
||||
private fun getRandomRememberMeKey() = RandomStringUtils.randomAlphanumeric(32)
|
||||
private fun getRandomRememberMeKey() = RandomStringUtils.secure().nextAlphanumeric(32)
|
||||
|
||||
var rememberMeDuration: Duration =
|
||||
(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
|
||||
// as advised in https://docs.spring.io/spring-boot/docs/3.1.4/reference/htmlsingle/#howto.data-access.configure-jooq-with-multiple-datasources
|
||||
@Configuration
|
||||
class JooqConfiguration {
|
||||
class KomgaJooqConfiguration {
|
||||
@Bean("dslContext")
|
||||
@Primary
|
||||
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.web.getCurrentRequest
|
||||
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.HttpMethod
|
||||
import org.springframework.http.HttpStatusCode
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.http.client.ReactorNettyClientRequestFactory
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.util.LinkedMultiValueMap
|
||||
import org.springframework.web.client.RestClient
|
||||
@ -32,11 +33,11 @@ class KoboProxy(
|
||||
RestClient.builder()
|
||||
.baseUrl("https://storeapi.kobo.com")
|
||||
.requestFactory(
|
||||
ReactorNettyClientRequestFactory().apply {
|
||||
setConnectTimeout(1.minutes.toJavaDuration())
|
||||
setReadTimeout(1.minutes.toJavaDuration())
|
||||
setExchangeTimeout(1.minutes.toJavaDuration())
|
||||
},
|
||||
ClientHttpRequestFactoryBuilder.reactor().build(
|
||||
ClientHttpRequestFactorySettings.defaults()
|
||||
.withReadTimeout(1.minutes.toJavaDuration())
|
||||
.withConnectTimeout(1.minutes.toJavaDuration()),
|
||||
),
|
||||
)
|
||||
.build()
|
||||
|
||||
|
@ -73,7 +73,7 @@ class KomgaOAuth2UserServiceConfiguration(
|
||||
private fun tryCreateNewUser(email: String) =
|
||||
if (komgaProperties.oauth2AccountCreation) {
|
||||
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 {
|
||||
throw OAuth2AuthenticationException("ERR_1025")
|
||||
}
|
||||
|
@ -228,8 +228,8 @@ class KoboController(
|
||||
* Return dummy data to keep the device happy.
|
||||
*/
|
||||
return AuthDto(
|
||||
accessToken = RandomStringUtils.randomAlphanumeric(24),
|
||||
refreshToken = RandomStringUtils.randomAlphanumeric(24),
|
||||
accessToken = RandomStringUtils.secure().nextAlphanumeric(24),
|
||||
refreshToken = RandomStringUtils.secure().nextAlphanumeric(24),
|
||||
trackingId = UUID.randomUUID().toString(),
|
||||
userKey = body.get("UserKey")?.asText() ?: "",
|
||||
)
|
||||
@ -688,7 +688,7 @@ class KoboController(
|
||||
if (!thumbnailBookRepository.existsById(thumbnailId) && koboProxy.isEnabled()) {
|
||||
ResponseEntity
|
||||
.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()
|
||||
} else {
|
||||
val poster = bookLifecycle.getThumbnailBytesByThumbnailId(thumbnailId) ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
|
||||
|
@ -416,7 +416,7 @@ class Opds2Controller(
|
||||
@PathVariable(name = "id", required = false) libraryId: String?,
|
||||
@Parameter(hidden = true) page: Pageable,
|
||||
): FeedDto {
|
||||
val (library, authorizedLibraryIds) = checkLibraryAccess(libraryId, principal)
|
||||
val (library, _) = checkLibraryAccess(libraryId, principal)
|
||||
|
||||
val entries =
|
||||
seriesDtoRepository.findAll(
|
||||
|
@ -50,6 +50,6 @@ class InitialUsersProdConfiguration {
|
||||
@Bean
|
||||
fun initialUsers(): List<KomgaUser> =
|
||||
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
|
||||
show-details: when_authorized
|
||||
shutdown:
|
||||
enabled: true
|
||||
access: unrestricted
|
||||
info:
|
||||
java:
|
||||
enabled: true
|
||||
|
Loading…
Reference in New Issue
Block a user