Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/524#discussion_r96841464
  
    --- Diff: 
rest/rest-server/src/main/java/org/apache/brooklyn/rest/filter/BrooklynPropertiesSecurityFilter.java
 ---
    @@ -148,8 +148,11 @@ protected boolean authenticate(HttpServletRequest 
request) {
             String authorization = request.getHeader("Authorization");
             if (authorization != null) {
                 String userpass = new 
String(Base64.decodeBase64(authorization.substring(6)));
    -            user = userpass.substring(0, userpass.indexOf(":"));
    -            pass = userpass.substring(userpass.indexOf(":") + 1);
    +            int idxColon = userpass.indexOf(":");
    +            if (idxColon >= 0) {
    +                user = userpass.substring(0, idxColon);
    +                pass = userpass.substring(idxColon + 1);
    +            }
    --- End diff --
    
    previously you'd have got an index-out-of-bounds exception if the request 
had an invalid auth string without a colon (not likely perhaps but not 
impossible);  like this it will just leave user and pass empty and try to 
authenticate with them.  Would it be worth throwing a more explanatory 
exception here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to