patrik-marton commented on code in PR #12846: URL: https://github.com/apache/kafka/pull/12846#discussion_r1024994387
########## connect/basic-auth-extension/src/main/java/org/apache/kafka/connect/rest/basic/auth/extension/JaasBasicAuthFilter.java: ########## @@ -174,4 +153,84 @@ public void handle(Callback[] callbacks) throws UnsupportedCallbackException { )); } } + + private void setSecurityContextForRequest(ContainerRequestContext requestContext, BasicAuthenticationCredential credential) { + requestContext.setSecurityContext(new SecurityContext() { + @Override + public Principal getUserPrincipal() { + return () -> credential.getUsername(); + } + + @Override + public boolean isUserInRole(String role) { + return false; + } + + @Override + public boolean isSecure() { + return requestContext.getUriInfo().getRequestUri().getScheme().equalsIgnoreCase("https"); + } + + @Override + public String getAuthenticationScheme() { + return BASIC_AUTH; + } + }); + } + + + public static class BasicAuthenticationCredential { + private String username; + private String password; + + public BasicAuthenticationCredential(String authorizationHeader) { + final char colon = ':'; + final char space = ' '; + final String authType = "basic"; Review Comment: Since these are only used inside the constructor, I moved them inside the method where they cannot be static. Using the SecurityContext.BASIC_AUTH would make sense, thanks. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org