准备可扩展类型系统工作,更合理的JOIN查询优化算法,并行查询
This commit is contained in:
1 parent
9758439b82
commit
274b7fcdcc
75 files changed
+3828
-1789
No files matched your search
@@ -12,11 +12,11 @@ import ChuSQL.Core.Protocol (SchemaColumn (..), TableInfo (..))
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
|
||||
-- 账号表(系统表 __chusql_users)的结构定义,SQL 会话与 Web 管理端共用。
|
||||
-- 账号表(系统表 __system_users)的结构定义,SQL 会话与 Web 管理端共用。
|
||||
|
||||
-- | 账号表的名字:网页里像普通表一样浏览与编辑,但写入走账号命令
|
||||
accountTableName :: String
|
||||
accountTableName = "__chusql_users"
|
||||
accountTableName = "__system_users"
|
||||
|
||||
-- | 这张表是不是账号表
|
||||
isAccountTable :: Text -> Bool
|
||||
|
||||
@@ -4,21 +4,17 @@ module ChuSQL.Interface.Config (
|
||||
WebConfig (..),
|
||||
defaultWebConfig,
|
||||
defaultUser,
|
||||
defaultPassword,
|
||||
usingDefaultCredentials,
|
||||
loadWebConfigAt,
|
||||
resolveCredential,
|
||||
legacyPasswordKey,
|
||||
resolveStaticDir,
|
||||
staticDirCandidates,
|
||||
rootUserName,
|
||||
canonicalSettingKeys,
|
||||
resolvePlainPassword,
|
||||
ServerConfig (..),
|
||||
defaultServerConfig,
|
||||
loadServerConfigAt,
|
||||
) where
|
||||
|
||||
import ChuSQL.Interface.Auth (Credential (..), hashPassword)
|
||||
import ChuSQL.Interface.TOML (readSection)
|
||||
import Data.Char (toLower)
|
||||
import qualified Data.Map.Strict as Map
|
||||
@@ -34,10 +30,6 @@ import Text.Read (readMaybe)
|
||||
defaultUser :: Text
|
||||
defaultUser = "root"
|
||||
|
||||
-- | 默认口令(只为方便本地测试;生产/对外必须覆盖)
|
||||
defaultPassword :: Text
|
||||
defaultPassword = "chusql"
|
||||
|
||||
-- | Web 管理端配置
|
||||
data WebConfig = WebConfig
|
||||
{ wcHost :: String
|
||||
@@ -106,26 +98,16 @@ keyAliases =
|
||||
, ("password_classes", "password-classes")
|
||||
]
|
||||
|
||||
-- | 这份配置用的还是内置默认口令吗
|
||||
usingDefaultCredentials :: Map.Map Text Text -> Bool
|
||||
usingDefaultCredentials saved = Map.notMember "password" saved
|
||||
-- | 配置文件的 [web] 分节里是否还留着明文口令键
|
||||
legacyPasswordKey :: FilePath -> IO Bool
|
||||
legacyPasswordKey path = Map.member "password" <$> readSection path "web"
|
||||
|
||||
-- | 设置文件里某个键的非空值
|
||||
nonEmptyValue :: Text -> Map.Map Text Text -> Maybe Text
|
||||
-- | 查一个键
|
||||
nonEmptyValue key saved = case T.strip <$> Map.lookup key saved of
|
||||
Just value | not (T.null value) -> Just value
|
||||
_ -> Nothing
|
||||
|
||||
-- | root 凭据:明文就哈希,留空免密,缺省用演示口令
|
||||
resolveCredential :: WebConfig -> Map.Map Text Text -> IO Credential
|
||||
resolveCredential cfg saved = do
|
||||
encoded <- case Map.lookup "password" saved of
|
||||
Just plain | not (T.null (T.strip plain)) -> hashPassword (T.strip plain)
|
||||
Just _ -> pure ""
|
||||
Nothing -> hashPassword defaultPassword
|
||||
pure (Credential (rootUserName cfg saved) encoded)
|
||||
|
||||
-- | 管理员名字:命令行 > 设置文件 > 内置默认
|
||||
rootUserName :: WebConfig -> Map.Map Text Text -> Text
|
||||
rootUserName cfg saved
|
||||
@@ -144,12 +126,6 @@ withStorage :: Map.Map Text Text -> WebConfig -> WebConfig
|
||||
withStorage storage cfg =
|
||||
cfg{wcDataDir = T.unpack <$> nonEmptyValue "data_dir" storage}
|
||||
|
||||
-- | 管理员明文口令,没配回落到演示口令,显式留空回空串
|
||||
resolvePlainPassword :: Map.Map Text Text -> Text
|
||||
resolvePlainPassword saved = case Map.lookup "password" saved of
|
||||
Just plain -> T.strip plain
|
||||
Nothing -> defaultPassword
|
||||
|
||||
-- | [web] 分区里的启动参数,缺失或坏值一律回到内置默认
|
||||
webConfigFromSection :: Map.Map Text Text -> WebConfig
|
||||
webConfigFromSection saved =
|
||||
|
||||
@@ -55,7 +55,6 @@ settingCatalogue =
|
||||
, item "max-rows" "Rows per query" "limits" "int" "1000" False False
|
||||
, item "max-sql-length" "Max SQL characters" "limits" "int" "20000" False False
|
||||
, item "user" "管理员账号(设置文件)" "auth" "text" "root" True True
|
||||
, item "password" "管理员口令(设置文件,明文)" "auth" "secret" "" True True
|
||||
, item "password-min-length" "口令最短长度" "auth" "int" "12" True False
|
||||
, item "password-classes" "口令字符类别数" "auth" "int" "2" True False
|
||||
, owned "data-dir" "Data directory" "storage" "text" "" "storage" "data_dir"
|
||||
@@ -117,7 +116,7 @@ isRootOnly key = maybe False siRootOnly (findItem key)
|
||||
|
||||
-- | 网页端不能改的键
|
||||
lockedKeys :: [Text]
|
||||
lockedKeys = ["user", "password"]
|
||||
lockedKeys = ["user"]
|
||||
|
||||
-- | 这项在界面上是不是只读
|
||||
isLockedSetting :: Text -> Bool
|
||||
|
||||
Reference in new issue
Block a user