Skip to content
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/5-internal/test-z-timestamp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Assert the value of nginz's `zauth_timestamp` in test.
2 changes: 2 additions & 0 deletions integration/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
, transformers
, transformers-base
, unix
, unix-time
, unliftio
, uuid
, vector
Expand Down Expand Up @@ -183,6 +184,7 @@ mkDerivation {
transformers
transformers-base
unix
unix-time
unliftio
uuid
vector
Expand Down
1 change: 1 addition & 0 deletions integration/integration.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ library
, transformers
, transformers-base
, unix
, unix-time
, unliftio
, uuid
, vector
Expand Down
5 changes: 5 additions & 0 deletions integration/test/Test/NginxZAuthModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Control.Monad.Reader
import qualified Data.ByteString as BS
import Data.List.Extra
import Data.Streaming.Network
import Data.UnixTime
import qualified Network.HTTP.Client as HTTP
import Network.HTTP.Types
import Network.Socket (Socket)
Expand Down Expand Up @@ -49,6 +50,10 @@ testBearerToken = do
resp.status `shouldMatchInt` 200
resp.json %. "user" `shouldMatch` (alice %. "qualified_id.id")
resp.json %. "timestamp" `shouldNotMatch` ""
timestampI <- (resp.json %. "timestamp" >>= asString)
let timestampUnix = UnixTime ((fromInteger . read) timestampI) 0
now <- liftIO $ getUnixTime
assertBool "not in future" (timestampUnix > now)

-- Happy flow (zauth token encoded in AWS4_HMAC_SHA256)
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
proxy_set_header Z-Provider $zauth_provider;
proxy_set_header Z-Bot $zauth_bot;
proxy_set_header Z-Conversation $zauth_conversation;
proxy_set_header Z-Timestamp $zauth_timestamp;
proxy_set_header Request-Id $request_id;

# NOTE: This should only be used on endpoints where credentials are needed
Expand Down