Spring Security
  1. Spring Security
  2. SEC-1443

Jsr250Voter will return access denied for allowed roles

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.2
    • Fix Version/s: 3.0.3, 3.1.0.M1
    • Component/s: Core
    • Labels:
      None

      Description

      Method vote() from Jsr250Voter.java will return ACCESS_DENIED if the FIRST role from definition does not exists in authentication.getAuthorities() list.

      public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> definition) {
      for (ConfigAttribute attribute : definition) {
      //...

      if (supports(attribute)) {
      // Attempt to find a matching granted authority
      for (GrantedAuthority authority : authentication.getAuthorities()) {
      if (attribute.getAttribute().equals(authority.getAuthority()))

      { return ACCESS_GRANTED; }

      }
      // No match - deny access
      return ACCESS_DENIED; // <-------- will return ACCESS_DENIED too soon
      }
      }
      return ACCESS_ABSTAIN;
      }

        Activity

        Hide
        Luke Taylor added a comment -

        Thanks for spotting this. I've modified the voter to deny access only if no matching role is found. If no JSR-250 attributes are found, it will abstain.

        Show
        Luke Taylor added a comment - Thanks for spotting this. I've modified the voter to deny access only if no matching role is found. If no JSR-250 attributes are found, it will abstain.

          People

          • Assignee:
            Luke Taylor
            Reporter:
            Andrei Ciobanu
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: