Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-73009

SAML Group Attribute in Jenkins for Project-Based Matrix Authorization is not working as expected

      I'm currently working on integrating SAML 2.0 authentication with Jenkins, and I've encountered a challenge regarding the parsing of group attributes received in the SAML response. Here's a detailed overview of the situation and the specific problem I'm facing.

      Setup:

      • Successfully implemented SAML 2.0 authentication in Jenkins.
      • Upon authentication, user attributes such as first name, last name, email, and groups are retrieved from the SAML response.
      • The group attribute is formatted as a single string where multiple groups are concatenated and separated by " ^ ", like this "CN=Adgroup1,ou=groups,dc=example,dc=net^CN=Adgroup2,ou=groups,dc=example,dc=net^CN=Adgroup3,ou=groups,dc=example,dc=net"

      Issue Description:

      • I'm using the Project-Based Matrix Authorization Strategy in Jenkins to control access to specific jobs based on users' group memberships.
      • However, Jenkins is treating the entire group string as a single group during authorization checks.
      • The desired behavior is for Jenkins to parse and recognize individual groups (e.g., adgroup1, adgroup2, adgroup3) from the group attribute string.

      Constraints and Considerations:

      • Changes cannot be made to the SAML response format as it complies with standards and is managed by the Identity Provider (IDP).
      • The SAML response structure for the group attribute is as follows:

      <ns2:Attribute Name="Groups" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic"> ns2:AttributeValueCN=Adgroup1,ou=groups,dc=example,dc=net^CN=Adgroup2,ou=groups,dc=example,dc=net^CN=Adgroup3,ou=groups,dc=example,dc=net</ns2:AttributeValue> </ns2:Attribute>

      How can I configure Jenkins or modify the Project-Based Matrix Authorization Strategy to correctly parse and distinguish individual groups from the SAML group attribute string? I need a solution that accommodates the CN, ou, and dc details present in the group attribute format without modifying the SAML response itself. Any insights, suggestions, or specific configurations would be greatly appreciated. Thank you!

          [JENKINS-73009] SAML Group Attribute in Jenkins for Project-Based Matrix Authorization is not working as expected

          Nikhil created issue -
          Daniel Beck made changes -
          Component/s Original: matrix-auth-plugin [ 18131 ]
          Component/s Original: matrix-project-plugin [ 18765 ]
          Daniel Beck made changes -
          Assignee Original: Daniel Beck [ danielbeck ]
          Daniel Beck made changes -
          Assignee New: Ivan Fernandez Calvo [ ifernandezcalvo ]
          Daniel Beck made changes -
          Labels Original: SAML SAML2 group matrix-auth matrix-project New: SAML SAML2 group
          Ivan Fernandez Calvo made changes -
          Priority Original: Blocker [ 1 ] New: Minor [ 4 ]

          • The group attribute is formatted as a single string where multiple groups are concatenated and separated by " ^ ", like this "CN=Adgroup1,ou=groups,dc=example,dc=net^CN=Adgroup2,ou=groups,dc=example,dc=net^CN=Adgroup3,ou=groups,dc=example,dc=net"

          This is not standard. The groups field in SAML has its own field in the SAML response; it is a list of groups. Any other implementation is not standard and is not supported. There is no intention of implementing weird behaviors.

          Ivan Fernandez Calvo added a comment - The group attribute is formatted as a single string where multiple groups are concatenated and separated by " ^ ", like this "CN=Adgroup1,ou=groups,dc=example,dc=net^CN=Adgroup2,ou=groups,dc=example,dc=net^CN=Adgroup3,ou=groups,dc=example,dc=net" This is not standard. The groups field in SAML has its own field in the SAML response; it is a list of groups. Any other implementation is not standard and is not supported. There is no intention of implementing weird behaviors.
          Ivan Fernandez Calvo made changes -
          Resolution New: Won't Fix [ 2 ]
          Status Original: Open [ 1 ] New: Closed [ 6 ]

          Nikhil added a comment -

          Hi ifernandezcalvo , is there any way to handle this at jenkins end, like parsing the saml group attribute response in jenkins. can we do that? can you please help

          Nikhil added a comment - Hi ifernandezcalvo , is there any way to handle this at jenkins end, like parsing the saml group attribute response in jenkins. can we do that? can you please help

          Ivan Fernandez Calvo added a comment - - edited

          No, I rejected the idea a long time ago. The reason is that every company that does not send groups as it should could implement any kind of pattern in that group. It is not standard, and we will end up with a mess of code to manage 20 ways to send nonstandard groups with 20 ways to fail. So, I am not interested in supporting a nonstandard way to pass groups, and I will not maintain (accept) any code that makes that stuff. 

          There is no reason to not configure your IdP to use the standard way to send groups.

          Ivan Fernandez Calvo added a comment - - edited No, I rejected the idea a long time ago. The reason is that every company that does not send groups as it should could implement any kind of pattern in that group. It is not standard, and we will end up with a mess of code to manage 20 ways to send nonstandard groups with 20 ways to fail. So, I am not interested in supporting a nonstandard way to pass groups, and I will not maintain (accept) any code that makes that stuff.  There is no reason to not configure your IdP to use the standard way to send groups.

            ifernandezcalvo Ivan Fernandez Calvo
            nikhil_raj Nikhil
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: