Correct hardcoded postgrest_test_authenticator (#1743)
Also remove panic from Config and correct io test not running
This commit is contained in:
@@ -58,7 +58,6 @@ import Development.GitRev (gitHash)
|
||||
import Numeric (readOct, showOct)
|
||||
import Paths_postgrest (version)
|
||||
import System.Environment (getEnvironment)
|
||||
import System.IO.Error (IOError)
|
||||
import System.Posix.Types (FileMode)
|
||||
|
||||
import Control.Applicative
|
||||
@@ -334,14 +333,12 @@ readAppConfig :: [(Text, Text)] -> Environment -> Maybe FilePath -> IO (Either T
|
||||
readAppConfig dbSettings env optPath = do
|
||||
-- Now read the actual config file
|
||||
conf <- case optPath of
|
||||
Just cfgPath -> C.load cfgPath `catches`
|
||||
[ Handler (\(ex :: IOError) -> panic $ "Cannot open config file: " <> show ex)
|
||||
, Handler (\(C.ParseError err) -> panic $ "Error parsing config file: " <> err)
|
||||
]
|
||||
-- Both C.ParseError and IOError are shown here
|
||||
Just cfgPath -> mapLeft show <$> (try $ C.load cfgPath :: IO (Either SomeException C.Config))
|
||||
-- if no filename provided, start with an empty map to read config from environment
|
||||
Nothing -> return M.empty
|
||||
Nothing -> return $ Right M.empty
|
||||
|
||||
pure $ mapLeft ("Error in config: " <>) $ C.runParser parseConfig conf
|
||||
pure $ mapLeft ("Error in config: " <>) $ C.runParser parseConfig =<< conf
|
||||
|
||||
where
|
||||
parseConfig =
|
||||
|
||||
@@ -202,7 +202,7 @@ dbSettingsStatement = H.Statement sql HE.noParams decodeSettings False
|
||||
sql = [q|
|
||||
with
|
||||
role_setting as (
|
||||
select unnest(setconfig) as setting from pg_catalog.pg_db_role_setting where setrole = 'postgrest_test_authenticator'::regrole::oid
|
||||
select unnest(setconfig) as setting from pg_catalog.pg_db_role_setting where setrole = current_user::regrole::oid
|
||||
),
|
||||
kv_settings as (
|
||||
select split_part(setting, '=', 1) as key, split_part(setting, '=', 2) as value from role_setting
|
||||
|
||||
Reference in New Issue
Block a user