Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apollo
Commits
e4d41dad
Unverified
Commit
e4d41dad
authored
May 02, 2020
by
lzj
Committed by
GitHub
May 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ClientAuthenticationFilter.checkTimestamp (#3029)
parent
c81dd6d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/filter/ClientAuthenticationFilter.java
...ollo/configservice/filter/ClientAuthenticationFilter.java
+1
-1
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/filter/ClientAuthenticationFilterTest.java
.../configservice/filter/ClientAuthenticationFilterTest.java
+16
-0
No files found.
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/filter/ClientAuthenticationFilter.java
View file @
e4d41dad
...
...
@@ -89,7 +89,7 @@ public class ClientAuthenticationFilter implements Filter {
}
long
x
=
System
.
currentTimeMillis
()
-
requestTimeMillis
;
return
x
<=
TIMESTAMP_INTERVAL
;
return
x
>=
-
TIMESTAMP_INTERVAL
&&
x
<=
TIMESTAMP_INTERVAL
;
}
private
boolean
checkAuthorization
(
String
authorization
,
List
<
String
>
availableSecrets
,
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/filter/ClientAuthenticationFilterTest.java
View file @
e4d41dad
...
...
@@ -67,6 +67,22 @@ public class ClientAuthenticationFilterTest {
verify
(
filterChain
,
never
()).
doFilter
(
request
,
response
);
}
@Test
public
void
testRequestTimeOneMinFasterThenCurrentTime
()
throws
Exception
{
String
appId
=
"someAppId"
;
List
<
String
>
secrets
=
Lists
.
newArrayList
(
"someSecret"
);
String
oneMinAfterTimestamp
=
Long
.
toString
(
System
.
currentTimeMillis
()
+
61
*
1000
);
when
(
accessKeyUtil
.
extractAppIdFromRequest
(
any
())).
thenReturn
(
appId
);
when
(
accessKeyUtil
.
findAvailableSecret
(
appId
)).
thenReturn
(
secrets
);
when
(
request
.
getHeader
(
Signature
.
HTTP_HEADER_TIMESTAMP
)).
thenReturn
(
oneMinAfterTimestamp
);
clientAuthenticationFilter
.
doFilter
(
request
,
response
,
filterChain
);
verify
(
response
).
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
"RequestTimeTooSkewed"
);
verify
(
filterChain
,
never
()).
doFilter
(
request
,
response
);
}
@Test
public
void
testUnauthorized
()
throws
Exception
{
String
appId
=
"someAppId"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment