mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-13 15:17:27 +08:00
[+] Allow ftk as an auth token
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package icu.samnyan.aqua.sega.allnet
|
package icu.samnyan.aqua.sega.allnet
|
||||||
|
|
||||||
import ext.Str
|
import ext.Str
|
||||||
|
import icu.samnyan.aqua.net.FrontierProps
|
||||||
import jakarta.servlet.http.HttpServletRequest
|
import jakarta.servlet.http.HttpServletRequest
|
||||||
import jakarta.servlet.http.HttpServletRequestWrapper
|
import jakarta.servlet.http.HttpServletRequestWrapper
|
||||||
import jakarta.servlet.http.HttpServletResponse
|
import jakarta.servlet.http.HttpServletResponse
|
||||||
@@ -25,6 +26,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
|
|||||||
class TokenChecker(
|
class TokenChecker(
|
||||||
val keyChipRepo: KeyChipRepo,
|
val keyChipRepo: KeyChipRepo,
|
||||||
val keychipSessionService: KeychipSessionService,
|
val keychipSessionService: KeychipSessionService,
|
||||||
|
val frontierProps: FrontierProps,
|
||||||
) : HandlerInterceptor {
|
) : HandlerInterceptor {
|
||||||
val log = LoggerFactory.getLogger(TokenChecker::class.java)
|
val log = LoggerFactory.getLogger(TokenChecker::class.java)
|
||||||
|
|
||||||
@@ -41,8 +43,10 @@ class TokenChecker(
|
|||||||
|
|
||||||
// Check whether the token exists in the database
|
// Check whether the token exists in the database
|
||||||
// The token can either be a keychip id (old method) or a session id (new method)
|
// The token can either be a keychip id (old method) or a session id (new method)
|
||||||
|
// Or the frontier token
|
||||||
val session = keychipSessionService.find(token)
|
val session = keychipSessionService.find(token)
|
||||||
if (token.isNotBlank() && (keyChipRepo.existsByKeychipId(token) || session != null))
|
if (token.isNotBlank() && (keyChipRepo.existsByKeychipId(token) || session != null
|
||||||
|
|| (frontierProps.enabled && frontierProps.ftk == token)))
|
||||||
{
|
{
|
||||||
// Forward the request
|
// Forward the request
|
||||||
val w = RewriteWrapper(req, token).apply { setAttribute("token", token) }
|
val w = RewriteWrapper(req, token).apply { setAttribute("token", token) }
|
||||||
|
|||||||
Reference in New Issue
Block a user