mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
Allow CE users to attempt GDC requests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8754 GitOrigin-RevId: 26a364a6c9d5788d4b06a84942ba9953be104ab7
This commit is contained in:
parent
27a02cf2bc
commit
7ce1093683
@ -9,11 +9,10 @@ import Control.Exception.Safe (throwIO)
|
||||
import Control.Monad.Trans.Control
|
||||
import Data.Aeson qualified as J
|
||||
import Data.Text.Extended ((<>>))
|
||||
import Hasura.Backends.DataConnector.API.V0
|
||||
import Hasura.Backends.DataConnector.Adapter.Execute (DataConnectorPreparedQuery (..), encodePreparedQueryToJsonText)
|
||||
import Hasura.Backends.DataConnector.Adapter.Types (SourceConfig (..))
|
||||
import Hasura.Backends.DataConnector.Agent.Client (AgentClientContext (..), AgentClientT, AgentLicenseKey (..), runAgentClientT)
|
||||
import Hasura.Base.Error (QErr, throw401)
|
||||
import Hasura.Base.Error (QErr (..))
|
||||
import Hasura.CredentialCache
|
||||
import Hasura.EncJSON (EncJSON)
|
||||
import Hasura.GraphQL.Execute.Backend (DBStepInfo (..), OnBaseMonad (..), arResult)
|
||||
@ -66,9 +65,11 @@ runDBQuery' requestId query fieldName _userInfo logger licenseKeyCacheMaybe Sour
|
||||
-- TODO: If the license key has expired or is otherwise invalid, request a key refresh
|
||||
pure key
|
||||
|
||||
case (_cLicensing _scCapabilities, agentAuthKey) of
|
||||
(Just _, Nothing) -> throw401 "EE License Key Required."
|
||||
_ -> do
|
||||
-- TODO: Re-introduce this case statement once we no longer want to
|
||||
-- allow CE to attempt GDC requests.
|
||||
-- case (_cLicensing _scCapabilities, agentAuthKey) of
|
||||
-- (Just _, Nothing) -> throw401 "EE License Key Required."
|
||||
-- _ -> do
|
||||
void $ HGL.logQueryLog logger $ mkQueryLog query fieldName queryRequest requestId
|
||||
withElapsedTime
|
||||
. Tracing.newSpan ("Data Connector backend query for root field " <>> fieldName)
|
||||
@ -106,9 +107,11 @@ runDBQueryExplain' licenseKeyCacheMaybe (DBStepInfo _ SourceConfig {..} _ action
|
||||
(key, _requestKeyRefresh) <- liftIO $ atomically $ getCredential licenseKeyCache
|
||||
-- TODO: If the license key has expired or is otherwise invalid, request a key refresh
|
||||
pure key
|
||||
case (_cLicensing _scCapabilities, agentAuthKey) of
|
||||
(Just _, Nothing) -> throw401 "EE License Key Required."
|
||||
_ ->
|
||||
-- TODO: Re-introduce this case statement once we no longer want to
|
||||
-- allow CE to attempt GDC requests.
|
||||
-- case (_cLicensing _scCapabilities, agentAuthKey) of
|
||||
-- (Just _, Nothing) -> throw401 "EE License Key Required."
|
||||
-- _ ->
|
||||
flip runAgentClientT (AgentClientContext nullLogger _scEndpoint _scManager _scTimeoutMicroseconds agentAuthKey)
|
||||
. fmap arResult
|
||||
$ runOnBaseMonad action
|
||||
@ -137,9 +140,12 @@ runDBMutation' requestId query fieldName _userInfo logger licenseKeyCacheMaybe S
|
||||
(key, _requestKeyRefresh) <- liftIO $ atomically $ getCredential licenseKeyCache
|
||||
-- TODO: If the license key has expired or is otherwise invalid, request a key refresh
|
||||
pure key
|
||||
case (_cLicensing _scCapabilities, agentAuthKey) of
|
||||
(Just _, Nothing) -> throw401 "EE License Key Required."
|
||||
_ -> do
|
||||
|
||||
-- TODO: Re-introduce this case statement once we no longer want to
|
||||
-- allow CE to attempt GDC requests.
|
||||
-- case (_cLicensing _scCapabilities, agentAuthKey) of
|
||||
-- (Just _, Nothing) -> throw401 "EE License Key Required."
|
||||
-- _ -> do
|
||||
void $ HGL.logQueryLog logger $ mkQueryLog query fieldName queryRequest requestId
|
||||
withElapsedTime
|
||||
. Tracing.newSpan ("Data Connector backend mutation for root field " <>> fieldName)
|
||||
|
@ -83,4 +83,6 @@ throwClientError' :: (MonadIO m, MonadTrace m, MonadError QErr m) => ClientError
|
||||
throwClientError' err = do
|
||||
AgentClientContext {..} <- askClientContext
|
||||
logClientError _accLogger err
|
||||
throw500 $ "Error in Data Connector backend: " <> Hasura.HTTP.serializeServantClientErrorMessage err
|
||||
case err of
|
||||
FailureResponse _ r | responseStatusCode r == HTTP.status401 -> throw401 "EE License Key Required."
|
||||
_ -> throw500 $ "Error in Data Connector backend: " <> Hasura.HTTP.serializeServantClientErrorMessage err
|
||||
|
Loading…
Reference in New Issue
Block a user