zeroflag commented on code in PR #623:
URL: https://github.com/apache/knox/pull/623#discussion_r954662416
##########
gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTFederationFilter.java:
##########
@@ -229,6 +263,36 @@ private Pair<TokenType, String>
parseFromHTTPBasicCredentials(final String heade
return parsed;
}
+ /*
+ * Attempts to authenticate using session cookies.
+ */
+ private boolean authenticateWithCookies(HttpServletRequest request,
HttpServletResponse response, FilterChain chain)
+ throws NoValidCookiesException, ServletException, IOException {
+ final List<Cookie> relevantCookies =
CookieUtils.getCookiesForName(request, cookieName);
+ for (Cookie ssoCookie : relevantCookies) {
+ try {
+ final JWT token = new JWTToken(ssoCookie.getValue());
+ if (validateToken(request, response, chain, token)) {
+ final Subject subject = createSubjectFromToken(token);
+ continueWithEstablishedSecurityContext(subject, request, response,
chain);
+ // we found a valid cookie we don't need to keep checking anymore
+ return true;
+ }
+ } catch (ParseException | UnknownTokenException ignore) {
+ // Ignore the error since cookie was invalid
Review Comment:
We might need to consider logging this but otherwise LGTM
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]