From da99f6f1222585b7dac26fe66f8b1461a5d2325e Mon Sep 17 00:00:00 2001 From: Leif Battermann Date: Mon, 15 Jul 2024 14:16:06 +0000 Subject: [PATCH 1/2] fix api version check, hack to check version header before method --- libs/wire-api/src/Wire/API/VersionInfo.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/wire-api/src/Wire/API/VersionInfo.hs b/libs/wire-api/src/Wire/API/VersionInfo.hs index b7267028b60..590dd7b380d 100644 --- a/libs/wire-api/src/Wire/API/VersionInfo.hs +++ b/libs/wire-api/src/Wire/API/VersionInfo.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE RecordWildCards #-} + -- This file is part of the Wire Server implementation. -- -- Copyright (C) 2022 Wire Swiss GmbH @@ -72,7 +74,7 @@ instance route _ ctx action = route (Proxy @api) ctx $ - fmap const action `addHeaderCheck` withRequest headerCheck + action `addVersionCheck` withRequest headerCheck where headerCheck :: Wai.Request -> DelayedIO () headerCheck req = do @@ -85,6 +87,14 @@ instance when (v >= demote @n) $ delayedFail err404 + -- this hack makes sure that the version check is executed before the method check + addVersionCheck :: Delayed env b -> DelayedIO () -> Delayed env b + addVersionCheck Delayed {..} new = + Delayed + { capturesD = \env -> capturesD env <* new, + .. + } + hoistServerWithContext _ ctx f = hoistServerWithContext (Proxy @api) ctx f From 7dc304839f1b3f6d276f7f5fcb0160555977448f Mon Sep 17 00:00:00 2001 From: Leif Battermann Date: Mon, 15 Jul 2024 14:25:50 +0000 Subject: [PATCH 2/2] changelog --- changelog.d/3-bug-fixes/PR-4152 | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/3-bug-fixes/PR-4152 diff --git a/changelog.d/3-bug-fixes/PR-4152 b/changelog.d/3-bug-fixes/PR-4152 new file mode 100644 index 00000000000..76f53d73ce4 --- /dev/null +++ b/changelog.d/3-bug-fixes/PR-4152 @@ -0,0 +1 @@ +Fixed API version check. It has now precedence over other checks like e.g. method check.