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

[fix] API version check comes before method check #4152

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3-bug-fixes/PR-4152
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed API version check. It has now precedence over other checks like e.g. method check.
12 changes: 11 additions & 1 deletion libs/wire-api/src/Wire/API/VersionInfo.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE RecordWildCards #-}

-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2022 Wire Swiss GmbH <opensource@wire.com>
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
Loading