mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-11-10 10:29:12 +03:00
fcef6e5cb2
## Description This PR is in reference to #2449 (support IP blacklisting for multitenant) *RFC Update: Add support for IPv6 blocking* ### Solution and Design Using [http-client-restricted](https://hackage.haskell.org/package/http-client-restricted) package, we're creating the HTTP manager with restricting capabilities. The IPs can be supplied from the CLI arguments as `--ipv4BlocklistCidrs cidr1, cidr2...` or `--disableDefaultIPv4Blocklist` for a default IP list. The new manager will block all requests to the provided CIDRs. We are extracting the error message string to show the end-user that given IP is blocked from being set as a webhook. There are 2 ways to extract the error message "connection to IP address is blocked". Given below are the responses from event trigger to a blocked IP for these implementations: - 6d74fde316f61e246c861befcca5059d33972fa7 - We return the error message string as a HTTPErr(HOther) from `Hasura/Eventing/HTTP.hs`. ``` { "data": { "message": "blocked connection to private IP address " }, "version": "2", "type": "client_error" } ``` - 88e17456345cbb449a5ecd4877c84c9f319dbc25 - We case match on HTTPExceptionContent for InternaException in `Hasura/HTTP.hs` and extract the error message string from it. (this is implemented as it handles all the cases where pro engine makes webhook requests) ``` { "data": { "message": { "type": "http_exception", "message": "blocked connection to private IP address ", "request": { "secure": false, "path": "/webhook", "responseTimeout": "ResponseTimeoutMicro 60000000", "queryString": "", "method": "POST", "requestHeaders": { "Content-Type": "application/json", "X-B3-ParentSpanId": "5ae6573edb2a6b36", "X-B3-TraceId": "29ea7bd6de6ebb8f", "X-B3-SpanId": "303137d9f1d4f341", "User-Agent": "hasura-graphql-engine/cerebushttp-ip-blacklist-a793a0e41-dirty" }, "host": "139.59.90.109", "port": 8000 } } }, "version": "2", "type": "client_error" } ``` ### Steps to test and verify The restricted IPs can be used as webhooks in event triggers, and hasura will return an error message in reponse. ### Limitations, known bugs & workarounds - The `http-client-restricted` has a needlessly complex interface, and puts effort into implementing proxy support which we don't want, so we've inlined a stripped down version. - Performance constraint: As the blocking is checked for each request, if a long list of blocked CIDRs is supplied, iterating through all of them is not what we would prefer. Using trie is suggested to overcome this. (Added to RFC) - Calls to Lux endpoints are inconsistent: We use either the http manager from the ProServeCtx which is unrestricted, or the http manager from the ServeCtx which is restricted (the latter through the instances for MonadMetadataApiAuthorization and UserAuthentication). (The failure scenario here would be: cloud sets PRO_ENDPOINT to something that resolves to an internal address, and then restricted requests to those endpoints fail, causing auth to fail on user requests. This is about HTTP requests to lux auth endpoints.) ## Changelog - ✅ `CHANGELOG.md` is updated with user-facing content relevant to this PR. ## Affected components - ✅ Server - ✅ Tests PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3186 Co-authored-by: Robert <132113+robx@users.noreply.github.com> GitOrigin-RevId: 5bd2de2d028bc416b02c99e996c7bebce56fb1e7
103 lines
3.1 KiB
Plaintext
103 lines
3.1 KiB
Plaintext
-- Global project configuration.
|
|
--
|
|
-- This file can be overridden with cabal.project.local (see e.g. cabal.project.dev)
|
|
--
|
|
-- If you need to switch between several local configurations you can also
|
|
-- create a symlink to this file with a different name, e.g.:
|
|
-- $ ln -s cabal.project cabal.project.myconfig
|
|
-- $ ln -s cabal.project.freeze cabal.project.myconfig.freeze
|
|
-- ...and then create a new set of overrides in:
|
|
-- cabal.project.myconfig.local
|
|
-- ...and then invoke cabal with
|
|
-- $ cabal new-build --project-file=cabal.project.myconfig
|
|
--
|
|
-- See: https://www.haskell.org/cabal/users-guide/nix-local-build.html#configuring-builds-with-cabal-project
|
|
|
|
with-compiler: ghc-8.10.7
|
|
|
|
-- package-level parallelism:
|
|
jobs: $ncpus
|
|
|
|
packages: server
|
|
|
|
constraints:
|
|
-- Ensure we don't end up with a freeze file that forces an incompatible
|
|
-- version in CI for `Setup.hs` scripts.
|
|
setup.Cabal <3.4
|
|
|
|
-- https://github.com/andrewthad/haskell-ip/issues/79
|
|
allow-newer: ip:attoparsec
|
|
|
|
package *
|
|
-- NOTE: this gets applied to both local (hasura) packages and dependencies,
|
|
-- but optimizations for local hasura packages are overridden/controlled
|
|
-- via the 'optimize-hasura' flag.
|
|
optimization: 2
|
|
-- For tooling, e.g. 'weeder', and IDE-like stuff:
|
|
ghc-options: -fwrite-ide-info
|
|
|
|
haddock-html: true
|
|
haddock-hoogle: true
|
|
haddock-hyperlink-source: true
|
|
haddock-quickjump: true
|
|
|
|
package graphql-engine
|
|
ghc-options: -j
|
|
haddock-options: "--show-all"
|
|
|
|
source-repository-package
|
|
type: git
|
|
location: https://github.com/hasura/kriti-lang.git
|
|
tag: v0.3.1
|
|
|
|
source-repository-package
|
|
type: git
|
|
location: https://github.com/hasura/pg-client-hs.git
|
|
tag: f28738e18b7038627fb59b93dbc67929fe427c57
|
|
|
|
source-repository-package
|
|
type: git
|
|
location: https://github.com/hasura/graphql-parser-hs.git
|
|
tag: 36212bcc3815434a1bc25dc96f091a783b880ca4
|
|
|
|
source-repository-package
|
|
type: git
|
|
location: https://github.com/hasura/ci-info-hs.git
|
|
tag: be578a01979fc95137cc2c84827f9fafb99df60f
|
|
|
|
source-repository-package
|
|
type: git
|
|
location: https://github.com/hasura/pool.git
|
|
tag: bc4c3f739a8fb8ec4444336a34662895831c9acf
|
|
|
|
source-repository-package
|
|
type: git
|
|
location: https://github.com/fpco/odbc.git
|
|
tag: 3d80ffdd4a2879f0debecabb56d834d2d898212b
|
|
|
|
package odbc
|
|
ghc-options: -Wwarn
|
|
-- Our CI compiles with -Werror, which is also applied to those packages
|
|
-- while it's fine for packages we maintain, we can't actually enforce
|
|
-- that third-party packages are warning-free, hence this -Wno-error.
|
|
-- When the changes in odbc are released, we can instead depend on
|
|
-- the hackage version, and remove it from this list of packages.
|
|
|
|
source-repository-package
|
|
type: git
|
|
location: https://github.com/hasura/ekg-core.git
|
|
tag: ac51c3834e242833e9735394295cbcaa583233f8
|
|
|
|
source-repository-package
|
|
type: git
|
|
location: https://github.com/hasura/ekg-json.git
|
|
tag: 84990712c165d7e3e76b2b289640ef8b5033f12f
|
|
|
|
-- This is v1.2.3.2 with https://github.com/haskell/text/pull/348
|
|
-- cherry-picked. When 1.3 is released we can move from this fork.
|
|
source-repository-package
|
|
type: git
|
|
location: https://github.com/hasura/text.git
|
|
tag: 874c3164fadf39a83382359d2b6ce941a3e134da
|
|
|