fix auth hook mode env var (fix #1270) (#1285)

Support HASURA_GRAPHQL_AUTH_HOOK_MODE env var for --auth-hook-mode flag.
Drop support for HASURA_GRAPHQL_AUTH_HOOK_TYPE env var in next major
update (beta/stable)
This commit is contained in:
Rakesh Emmadi 2019-01-04 12:12:36 +05:30 committed by Shahidh K Muhammed
parent 92ff16a605
commit 41e487d203

View File

@ -223,9 +223,15 @@ mkServeOptions rso = do
mkAuthHook (AuthHookG mUrl mType) = do
mUrlEnv <- withEnv mUrl $ fst authHookEnv
ty <- fromMaybe AHTGet <$> withEnv mType (fst authHookTypeEnv)
authModeM <- withEnv mType (fst authHookModeEnv)
ty <- maybe (authHookTyEnv mType) return authModeM
return (flip AuthHookG ty <$> mUrlEnv)
-- Also support HASURA_GRAPHQL_AUTH_HOOK_TYPE
-- TODO:- drop this in next major update
authHookTyEnv mType = fromMaybe AHTGet <$>
withEnv mType "HASURA_GRAPHQL_AUTH_HOOK_TYPE"
mkCorsConfig (CorsConfigG mDom isDis) = do
domEnv <- fromMaybe "*" <$> withEnv mDom (fst corsDomainEnv)
return $ CorsConfigG domEnv isDis
@ -303,7 +309,7 @@ serveCmdFooter =
envVarDoc = mkEnvVarDoc $ envVars <> eventEnvs
envVars =
[ servePortEnv, pgStripesEnv, pgConnsEnv, pgTimeoutEnv
, txIsoEnv, accessKeyEnv, authHookEnv , authHookTypeEnv
, txIsoEnv, accessKeyEnv, authHookEnv , authHookModeEnv
, jwtSecretEnv , unAuthRoleEnv, corsDomainEnv , enableConsoleEnv
]
@ -357,10 +363,10 @@ authHookEnv =
, "The authentication webhook, required to authenticate requests"
)
authHookTypeEnv :: (String, String)
authHookTypeEnv =
( "HASURA_GRAPHQL_AUTH_HOOK_TYPE"
, "The authentication webhook type (default: GET)"
authHookModeEnv :: (String, String)
authHookModeEnv =
( "HASURA_GRAPHQL_AUTH_HOOK_MODE"
, "The authentication webhook mode (default: GET)"
)
jwtSecretEnv :: (String, String)
@ -523,7 +529,7 @@ parseWebHook =
option (eitherReader readHookType)
( long "auth-hook-mode" <>
metavar "GET|POST" <>
help (snd authHookTypeEnv)
help (snd authHookModeEnv)
)