You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2022/08/25 08:28:28 UTC
[GitHub] [knox] zeroflag commented on a diff in pull request #623: KNOX-2794 - Added cookie auth support into JWT federation provider
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: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org