summaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2026-03-10 08:15:49 +0100
committerGitHub2026-03-10 07:15:49 +0000
commit48f6124e2cc27476dba8ebfb398c1b4ad8875164 (patch)
tree31e61e69f024c67719e78957d572bca8bebd5a0d /src/main/kotlin
parentf6710623259e80d7c296ce949b34a9f179f5387c (diff)
fix: ignore token users with existing username (#257)
This will ignore token usernames with the same username as an existing user.
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/security/TokenService.kt13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/security/TokenService.kt b/src/main/kotlin/dev/dnpm/etl/processor/security/TokenService.kt
index fdaa7d2..fd75446 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/security/TokenService.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/security/TokenService.kt
@@ -20,6 +20,7 @@
package dev.dnpm.etl.processor.security
import jakarta.annotation.PostConstruct
+import org.slf4j.LoggerFactory
import java.time.Instant
import java.util.*
import org.springframework.data.annotation.Id
@@ -36,12 +37,18 @@ class TokenService(
private val tokenRepository: TokenRepository,
) {
+ private val logger = LoggerFactory.getLogger(TokenService::class.java)
+
@PostConstruct
fun setup() {
tokenRepository.findAll().forEach {
- userDetailsManager.createUser(
- User.withUsername(it.username).password(it.password).roles("MTBFILE").build()
- )
+ if (!userDetailsManager.userExists(it.username)) {
+ userDetailsManager.createUser(
+ User.withUsername(it.username).password(it.password).roles("MTBFILE").build()
+ )
+ } else {
+ logger.error("User ${it.username} already exists - cannot use token - skipping!")
+ }
}
}