Commit 8038cdac authored by Stan Hu's avatar Stan Hu

Merge branch 'sh-geo-fix-iat' into 'master'

Fix broken time sync leeway with Geo

See merge request !2208
parents 9fd5c408 e07793bd
---
title: Fix broken time sync leeway with Geo
merge_request:
author:
...@@ -41,7 +41,7 @@ module Gitlab ...@@ -41,7 +41,7 @@ module Gitlab
encoded_message, encoded_message,
secret, secret,
true, true,
{ iat_leeway: IAT_LEEWAY, verify_iat: true, algorithm: 'HS256' } { leeway: IAT_LEEWAY, verify_iat: true, algorithm: 'HS256' }
) )
message = decoded.first message = decoded.first
......
...@@ -27,10 +27,16 @@ describe Gitlab::Geo::JwtRequestDecoder do ...@@ -27,10 +27,16 @@ describe Gitlab::Geo::JwtRequestDecoder do
expect(described_class.new(data).decode).to be_nil expect(described_class.new(data).decode).to be_nil
end end
it 'successfully decodes when clocks are off by IAT leeway' do
subject
Timecop.travel(30.seconds.ago) { expect(subject.decode).to eq(data) }
end
it 'returns nil when clocks are not in sync' do it 'returns nil when clocks are not in sync' do
allow(JWT).to receive(:decode).and_raise(JWT::InvalidIatError) subject
expect(subject.decode).to be_nil Timecop.travel(2.minutes.ago) { expect(subject.decode).to be_nil }
end end
it 'raises invalid decryption key error' do it 'raises invalid decryption key error' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment