From dc2109a2543ae99240eaaf22ab63614e7c41c550 Mon Sep 17 00:00:00 2001 From: rakeshkky Date: Wed, 2 Jan 2019 14:06:49 +0530 Subject: [PATCH] fix auth hook mode env var, (fix #1270) 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) --- server/src-lib/Hasura/Server/Init.hs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/server/src-lib/Hasura/Server/Init.hs b/server/src-lib/Hasura/Server/Init.hs index c37cc9cab78ac..d26f1a2c1f38e 100644 --- a/server/src-lib/Hasura/Server/Init.hs +++ b/server/src-lib/Hasura/Server/Init.hs @@ -220,9 +220,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 @@ -300,7 +306,7 @@ serveCmdFooter = envVarDoc = mkEnvVarDoc $ envVars <> eventEnvs envVars = [ servePortEnv, pgStripesEnv, pgConnsEnv, pgTimeoutEnv - , txIsoEnv, accessKeyEnv, authHookEnv , authHookTypeEnv + , txIsoEnv, accessKeyEnv, authHookEnv , authHookModeEnv , jwtSecretEnv , unAuthRoleEnv, corsDomainEnv , enableConsoleEnv ] @@ -354,10 +360,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) @@ -520,7 +526,7 @@ parseWebHook = option (eitherReader readHookType) ( long "auth-hook-mode" <> metavar "GET|POST" <> - help (snd authHookTypeEnv) + help (snd authHookModeEnv) )