• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • cli
    • None
    • Platform: All, OS: All

      After the changes in JENKINS-3796, container managed authentication no longer works for CLI.

      Make the necessary changes to maintain the extensibility provided in JENKINS-3796, but also allow container based auth.

          [JENKINS-6587] Allow CLI Container Managed Authentication

          jpederzolli added a comment -

          The reason for this issue is the following:

          The changes in JENKINS-3796 removed the passing of the Authentication object to the CliManagerImpl and made the CLI authentication more extensible. The one problem with it is that you need the Authentication to be passed into the CliManagerImpl class if one is using the LegacySecurityRealm (i.e. container auth). Without this issue being fixed, the CLI user will always be 'anonymous' if container based authentication is relied upon.

          A summary of the changes:

          1) Restore CliManager constructor to take an Authentication object which in turn will be passed on to the CLICommand implementation.
          2) Create an overloaded createCliAuthenticator method in SecurityRealm which takes an Authentication object
          3) Let it be up to the SecurityRealm implementation if createCliAuthenticator will consider the Authentication object when creating the CliAuthenticator
          4) Only the LegacySecurityRealm (currently at least) will override createCliAuthenticator(CLICommand command, Authentication auth) and use the Authentication object passed in for the creation of its CliAuthenticator. No other SecurityRealms will be affected by these changes.
          5) Update GroovyshCommand to include updates that appear to have been missed in JENKINS-3796 along with changes relative to this ticket.

          jpederzolli added a comment - The reason for this issue is the following: The changes in JENKINS-3796 removed the passing of the Authentication object to the CliManagerImpl and made the CLI authentication more extensible. The one problem with it is that you need the Authentication to be passed into the CliManagerImpl class if one is using the LegacySecurityRealm (i.e. container auth). Without this issue being fixed, the CLI user will always be 'anonymous' if container based authentication is relied upon. A summary of the changes: 1) Restore CliManager constructor to take an Authentication object which in turn will be passed on to the CLICommand implementation. 2) Create an overloaded createCliAuthenticator method in SecurityRealm which takes an Authentication object 3) Let it be up to the SecurityRealm implementation if createCliAuthenticator will consider the Authentication object when creating the CliAuthenticator 4) Only the LegacySecurityRealm (currently at least) will override createCliAuthenticator(CLICommand command, Authentication auth) and use the Authentication object passed in for the creation of its CliAuthenticator. No other SecurityRealms will be affected by these changes. 5) Update GroovyshCommand to include updates that appear to have been missed in JENKINS-3796 along with changes relative to this ticket.

          jpederzolli added a comment -

          proposed changes

          jpederzolli added a comment - proposed changes

          Code changed in hudson
          User: : jpederzolli
          Path:
          trunk/hudson/main/core/src/main/java/hudson/cli/CLICommand.java
          trunk/hudson/main/core/src/main/java/hudson/cli/CliManagerImpl.java
          trunk/hudson/main/core/src/main/java/hudson/cli/GroovyshCommand.java
          trunk/hudson/main/core/src/main/java/hudson/cli/declarative/CLIRegisterer.java
          trunk/hudson/main/core/src/main/java/hudson/model/Hudson.java
          trunk/hudson/main/core/src/main/java/hudson/security/LegacySecurityRealm.java
          trunk/hudson/main/core/src/main/java/hudson/security/SecurityRealm.java
          trunk/hudson/main/test/src/test/java/hudson/model/listeners/ItemListenerTest.java
          http://jenkins-ci.org/commit/31878
          Log:
          Issue: JENKINS-6587

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : jpederzolli Path: trunk/hudson/main/core/src/main/java/hudson/cli/CLICommand.java trunk/hudson/main/core/src/main/java/hudson/cli/CliManagerImpl.java trunk/hudson/main/core/src/main/java/hudson/cli/GroovyshCommand.java trunk/hudson/main/core/src/main/java/hudson/cli/declarative/CLIRegisterer.java trunk/hudson/main/core/src/main/java/hudson/model/Hudson.java trunk/hudson/main/core/src/main/java/hudson/security/LegacySecurityRealm.java trunk/hudson/main/core/src/main/java/hudson/security/SecurityRealm.java trunk/hudson/main/test/src/test/java/hudson/model/listeners/ItemListenerTest.java http://jenkins-ci.org/commit/31878 Log: Issue: JENKINS-6587

          Code changed in hudson
          User: : jpederzolli
          Path:
          trunk/www/changelog.html
          http://jenkins-ci.org/commit/31879
          Log:
          Issue: JENKINS-6587

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : jpederzolli Path: trunk/www/changelog.html http://jenkins-ci.org/commit/31879 Log: Issue: JENKINS-6587

          Code changed in hudson
          User: : kohsuke
          Path:
          trunk/hudson/main/core/src/main/java/hudson/cli/CLICommand.java
          trunk/hudson/main/core/src/main/java/hudson/cli/CliManagerImpl.java
          trunk/hudson/main/core/src/main/java/hudson/cli/GroovyshCommand.java
          trunk/hudson/main/core/src/main/java/hudson/cli/declarative/CLIRegisterer.java
          trunk/hudson/main/core/src/main/java/hudson/model/Hudson.java
          trunk/hudson/main/core/src/main/java/hudson/security/CliAuthenticator.java
          trunk/hudson/main/core/src/main/java/hudson/security/LegacySecurityRealm.java
          trunk/hudson/main/core/src/main/java/hudson/security/SecurityRealm.java
          trunk/hudson/main/remoting/src/main/java/hudson/remoting/Channel.java
          trunk/hudson/main/remoting/src/main/java/hudson/remoting/ChannelProperty.java
          trunk/hudson/main/test/src/test/java/hudson/model/listeners/ItemListenerTest.java
          http://jenkins-ci.org/commit/31900
          Log:
          JENKINS-6587 rolling back rev.31878. I think a better fix, given the current existing code and method signatures, is to expose the transport level authentication in a bit more implicit way.

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : kohsuke Path: trunk/hudson/main/core/src/main/java/hudson/cli/CLICommand.java trunk/hudson/main/core/src/main/java/hudson/cli/CliManagerImpl.java trunk/hudson/main/core/src/main/java/hudson/cli/GroovyshCommand.java trunk/hudson/main/core/src/main/java/hudson/cli/declarative/CLIRegisterer.java trunk/hudson/main/core/src/main/java/hudson/model/Hudson.java trunk/hudson/main/core/src/main/java/hudson/security/CliAuthenticator.java trunk/hudson/main/core/src/main/java/hudson/security/LegacySecurityRealm.java trunk/hudson/main/core/src/main/java/hudson/security/SecurityRealm.java trunk/hudson/main/remoting/src/main/java/hudson/remoting/Channel.java trunk/hudson/main/remoting/src/main/java/hudson/remoting/ChannelProperty.java trunk/hudson/main/test/src/test/java/hudson/model/listeners/ItemListenerTest.java http://jenkins-ci.org/commit/31900 Log: JENKINS-6587 rolling back rev.31878. I think a better fix, given the current existing code and method signatures, is to expose the transport level authentication in a bit more implicit way.

          Kohsuke Kawaguchi added a comment - - edited

          Just to be clear, my commit in rev.31900 includes the change I outlined. Come to think of it, I should have committed them as two separate commits.

          Kohsuke Kawaguchi added a comment - - edited Just to be clear, my commit in rev.31900 includes the change I outlined. Come to think of it, I should have committed them as two separate commits.

            jpederzolli jpederzolli
            jpederzolli jpederzolli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: