mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
perf: Supports dynamic access paths
This commit is contained in:
committed by
fit2cloud-chenyw
parent
9112d2f6f0
commit
c78fc5d88b
@@ -28,7 +28,9 @@ class Settings(BaseSettings):
|
||||
extra="ignore",
|
||||
)
|
||||
PROJECT_NAME: str = "SQLBot"
|
||||
API_V1_STR: str = "/api/v1"
|
||||
#CONTEXT_PATH: str = "/sqlbot"
|
||||
CONTEXT_PATH: str = ""
|
||||
API_V1_STR: str = CONTEXT_PATH + "/api/v1"
|
||||
SECRET_KEY: str = secrets.token_urlsafe(32)
|
||||
# 60 minutes * 24 hours * 8 days = 8 days
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
|
||||
|
||||
@@ -67,6 +67,13 @@ class WhitelistChecker:
|
||||
prefix = settings.API_V1_STR
|
||||
if path.startswith(prefix):
|
||||
path = path[len(prefix):]
|
||||
|
||||
context_prefix = settings.CONTEXT_PATH
|
||||
if context_prefix and path.startswith(context_prefix):
|
||||
path = path[len(context_prefix):]
|
||||
|
||||
if not path:
|
||||
path = '/'
|
||||
if path in self.whitelist:
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user