[
https://issues.apache.org/jira/browse/KNOX-2212?focusedWorklogId=394440&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-394440
]
ASF GitHub Bot logged work on KNOX-2212:
----------------------------------------
Author: ASF GitHub Bot
Created on: 27/Feb/20 20:14
Start Date: 27/Feb/20 20:14
Worklog Time Spent: 10m
Work Description: moresandeep commented on pull request #274: KNOX-2212 -
Token permissiveness
URL: https://github.com/apache/knox/pull/274#discussion_r385347313
##########
File path:
gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenStateService.java
##########
@@ -310,4 +325,30 @@ protected boolean needsEviction(final String token)
throws UnknownTokenException
return tokenExpirations.keySet().stream().collect(Collectors.toList());
}
+ /**
+ * A function that returns the JWT token expiration. This is only called when
+ * gateway.knox.token.permissive.failure.enabled property is set to true.
+ *
+ * @param token token to be verified and saved
+ */
+ protected long getJWTTokenExpiration(final String token) {
+ if (!isValidIdentifier(token)) {
+ throw new IllegalArgumentException("Token data cannot be null.");
+ }
+ JWT jwt;
+ try {
+ jwt = new JWTToken(token);
+ } catch (final ParseException e) {
+ log.errorParsingToken(e.toString());
+ throw new IllegalArgumentException(e);
Review comment:
So to fix this I can think of either of two ways
1. We would need to update the method signature for `getTokenExpiration()`
to throw `UnknownTokenException` and `IllegalArgumentException`. Now this
change would cause updating a lot of method signatures which I am hesitant to
do as it affects a lot of parts that we know work well.
2. `getJWTTokenExpiration()` method can throw `UnknownTokenException`. We do
not need to check if the token is not null here (since it was done by calling
method currently using it) so we can get rid of one of two
`IllegalArgumentException`. And then wrap the `ParseException` into
`UnknownTokenException` which I am not sure is right.
@risdenk @pzampino thoughts ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 394440)
Time Spent: 3h 10m (was: 3h)
> TokenStateService should fail permissively
> ------------------------------------------
>
> Key: KNOX-2212
> URL: https://issues.apache.org/jira/browse/KNOX-2212
> Project: Apache Knox
> Issue Type: Bug
> Components: Server
> Affects Versions: 1.4.0
> Reporter: Philip Zampino
> Assignee: Sandeep More
> Priority: Major
> Time Spent: 3h 10m
> Remaining Estimate: 0h
>
> While unlikely, it's possible that the TokenStateService may be presented
> with a token, for which it has no state, but which can be verified as a valid
> (origin, expiration, etc...) token. In these cases, rather than rejecting the
> token for lack of server-managed state, the token's state should be recorded,
> and the associated operation permitted.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)