Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass full request path to the post auth webhook, maybe fix #8771 #10049

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion server/src-lib/Hasura/Server/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ setHeader :: (MonadIO m) => HTTP.Header -> Spock.ActionCtxT ctx m ()
setHeader (headerName, headerValue) =
Spock.setHeader (bsToTxt $ CI.original headerName) (bsToTxt headerValue)

createReqsText :: ByteString -> ByteString -> ReqsText
createReqsText operationName query = GQLSingleRequest gqlReq
where
gqlQueryText = GQLQueryText $ bsToTxt query
gqlOperationName = OperationName $ bsToTxt operationName
gqlReq = GQLReq (Just gqlOperationName) gqlQueryText Nothing

-- | Typeclass representing the metadata API authorization effect
class (Monad m) => MonadMetadataApiAuthorization m where
authorizeV1QueryApi ::
Expand Down Expand Up @@ -326,7 +333,9 @@ mkSpockAction appStateRef qErrEncoder qErrModifier apiHandler = do
let origHeaders = Wai.requestHeaders req
ipAddress = Wai.getSourceFromFallback req
pathInfo = Wai.rawPathInfo req
queryParams = Wai.rawQueryString req
propagators = getOtelTracesPropagator scOpenTelemetryConfig
requestInfo = createReqsText pathInfo queryParams

-- Bytes are actually read from the socket here. Time this.
(ioWaitTime, reqBody) <- withElapsedTime $ liftIO $ Wai.strictRequestBody req
Expand Down Expand Up @@ -369,7 +378,7 @@ mkSpockAction appStateRef qErrEncoder qErrModifier apiHandler = do
res <- lift $ runHandler (_lsLogger appEnvLoggers) handlerState handler
pure (res, userInfo, authHeaders, includeInternal, Nothing, extraUserInfo)
AHPost handler -> do
(userInfo, authHeaders, handlerState, includeInternal, extraUserInfo) <- getInfo Nothing
(userInfo, authHeaders, handlerState, includeInternal, extraUserInfo) <- getInfo requestInfo
(queryJSON, parsedReq) <-
runExcept (parseBody reqBody) `onLeft` \e -> do
logErrorAndResp (Just userInfo) requestId req (reqBody, Nothing) includeInternal origHeaders extraUserInfo (qErrModifier e)
Expand Down