[+] Find session when validating request

This commit is contained in:
Azalea
2024-02-26 00:32:38 -05:00
parent c9ffd3cd11
commit b89147120c
2 changed files with 19 additions and 6 deletions

View File

@@ -23,7 +23,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@Component
@ConditionalOnBean(AllNetSecureInit::class)
class TokenChecker(
val keyChipRepo: KeyChipRepo
val keyChipRepo: KeyChipRepo,
val keychipSessionService: KeychipSessionService,
) : HandlerInterceptor {
val log = LoggerFactory.getLogger(TokenChecker::class.java)
@@ -40,7 +41,8 @@ class TokenChecker(
// Check whether the token exists in the database
// The token can either be a keychip id (old method) or a session id (new method)
if (token.isNotBlank() && keyChipRepo.existsByKeychipId(token))
val session = keychipSessionService.find(token)
if (token.isNotBlank() && (keyChipRepo.existsByKeychipId(token) || session != null))
{
// Forward the request
val w = RewriteWrapper(req, token).apply { setAttribute("token", token) }