alopresto commented on a change in pull request #3482: NIFI-6280 - Broke out
the matching for /access/knox/** and /access/oi…
URL: https://github.com/apache/nifi/pull/3482#discussion_r285300783
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/main/java/org/apache/nifi/web/security/jwt/JwtAuthenticationFilter.java
##########
@@ -43,15 +46,27 @@ public Authentication attemptAuthentication(final
HttpServletRequest request) {
// TODO: Refactor request header extraction logic to shared utility as
it is duplicated in AccessResource
// get the principal out of the user token
- final String authorization = request.getHeader(AUTHORIZATION);
+ final String authentication = request.getHeader(AUTHORIZATION);
- // if there is no authorization header, we don't know the user
- if (authorization == null || !StringUtils.startsWith(authorization,
BEARER)) {
+ // if there is no authorization (authentication) header, we don't know
the user
+ if (authentication == null || !validJwtFormat(authentication)) {
return null;
} else {
// Extract the Base64 encoded token from the Authorization header
- final String token = StringUtils.substringAfterLast(authorization,
" ");
+ final String token = getTokenFromHeader(authentication);
return new JwtAuthenticationRequestToken(token,
request.getRemoteAddr());
}
}
+
+ private boolean validJwtFormat(String authenticationHeader) {
Review comment:
Please add Javadoc and rename the parameter to `authorizationHeader`.
Boolean methods are usually named `isValidJwtFormat()`.
----------------------------------------------------------------
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]
With regards,
Apache Git Services