-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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 ClientAuthenticationFilter.checkTimestamp #3029
fix ClientAuthenticationFilter.checkTimestamp #3029
Conversation
@@ -89,7 +89,7 @@ private boolean checkTimestamp(String timestamp) { | |||
} | |||
|
|||
long x = System.currentTimeMillis() - requestTimeMillis; | |||
return x <= TIMESTAMP_INTERVAL; | |||
return x >= -TIMESTAMP_INTERVAL && x <= TIMESTAMP_INTERVAL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a unit test for this logic in case it is mistakenly modified in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit Test 已添加
Codecov Report
@@ Coverage Diff @@
## master #3029 +/- ##
=========================================
Coverage 51.25% 51.25%
- Complexity 2230 2231 +1
=========================================
Files 432 432
Lines 13382 13382
Branches 1374 1374
=========================================
Hits 6859 6859
Misses 6047 6047
Partials 476 476
Continue to review full report at Codecov.
|
66bf44e
to
fea27c7
Compare
fea27c7
to
0b42e5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
why not make TIMESTAMP_INTERVAL configable,1 minute is too strick |
@zhaolin81 I think it's better to make it configurable. |
agreed,i can't enable this func cause my app and apollo config server's time diff 2minutes.
…------------------ 原始邮件 ------------------
发件人: "ctripcorp/apollo" <[email protected]>;
发送时间: 2020年8月22日(星期六) 下午2:48
收件人: "ctripcorp/apollo"<[email protected]>;
抄送: "鱼,鱼熟了"<[email protected]>;"Mention"<[email protected]>;
主题: Re: [ctripcorp/apollo] fix ClientAuthenticationFilter.checkTimestamp (#3029)
@zhaolin81 I think it's better to make it configurable.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Sorry to see this PR now. This implement was written by me, I once realized that I don't agree with this PR solution. Maybe we can polish this logic soon. |
What's the purpose of this PR
return false when timestamp - currentTimeMills > 60 seconds
Which issue(s) this PR fixes:
Fixes #
Brief changelog
replace the code x <= TIMESTAMP_INTERVAL with x >= -TIMESTAMP_INTERVAL && x <= TIMESTAMP_INTERVAL
Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean test
to make sure this pull request doesn't break anything.