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

User.impersonate throws ClassCastException when using GitHub auth

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core, github-oauth-plugin
    • None
    • Jenkins 1.580.1

      SEVERE: Executor threw an exception
      java.lang.ClassCastException: org.acegisecurity.providers.UsernamePasswordAuthenticationToken cannot be cast to org.jenkinsci.plugins.GithubAuthenticationToken
      at org.jenkinsci.plugins.GithubSecurityRealm.loadUserByUsername(GithubSecurityRealm.java:542)
      at org.jenkinsci.plugins.GithubSecurityRealm$2.loadUserByUsername(GithubSecurityRealm.java:494)
      at jenkins.security.ImpersonatingUserDetailsService.loadUserByUsername(ImpersonatingUserDetailsService.java:32)
      at hudson.model.User.impersonate(User.java:282)

          [JENKINS-25791] User.impersonate throws ClassCastException when using GitHub auth

          Joe Arasin added a comment -

          I'm using a pubkey that was added to my user account. I'll give password a try

          Joe Arasin added a comment - I'm using a pubkey that was added to my user account. I'll give password a try

          Daniel Beck added a comment - - edited

          (Edited: nevermind, wrong context)

          Daniel Beck added a comment - - edited (Edited: nevermind, wrong context)

          Joe Arasin added a comment -

          Hmm, I can't even manage to get the ssh server to prompt me for a password at all. It seems like it's only willing to do key authentication.

          Joe Arasin added a comment - Hmm, I can't even manage to get the ssh server to prompt me for a password at all. It seems like it's only willing to do key authentication.

          Sam Gleske added a comment -

          Okay, I wasn't sure. I'll try to figure this out this week.

          Sam Gleske added a comment - Okay, I wasn't sure. I'll try to figure this out this week.

          Joe Arasin added a comment -

          Thanks!

          Joe Arasin added a comment - Thanks!

          Alfredo Deza added a comment - - edited

          After upgrading to 2.3 we are hitting this same issue. Some things that are worth noting:

          • Issue seems intermittent (can't reproduce consistently)
          • We are using Jenkins 2.3 and breakage started by upgrading to 2.3
          • Our stacktrace looks the same
          • It happens even if the build is successful, at the very end:

          Archiving artifacts
          FATAL: org.acegisecurity.providers.UsernamePasswordAuthenticationToken cannot be cast to org.jenkinsci.plugins.GithubAuthenticationToken
          java.lang.ClassCastException: org.acegisecurity.providers.UsernamePasswordAuthenticationToken cannot be cast to org.jenkinsci.plugins.GithubAuthenticationToken
          at org.jenkinsci.plugins.GithubSecurityRealm.loadUserByUsername(GithubSecurityRealm.java:644)
          at hudson.model.User$UserIDCanonicalIdResolver.resolveCanonicalId(User.java:1048)
          at hudson.model.User.get(User.java:394)
          at hudson.model.User.get(User.java:363)
          at hudson.plugins.git.GitChangeSet.findOrCreateUser(GitChangeSet.java:374)
          at hudson.plugins.git.GitChangeSet.getAuthor(GitChangeSet.java:435)
          at hudson.model.AbstractBuild.getCulprits(AbstractBuild.java:350)
          at hudson.model.AbstractBuild.getCulprits(AbstractBuild.java:346)
          at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:672)
          at hudson.model.Run.execute(Run.java:1763)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:98)
          at hudson.model.Executor.run(Executor.java:410)
          Finished: FAILURE

          Alfredo Deza added a comment - - edited After upgrading to 2.3 we are hitting this same issue. Some things that are worth noting: Issue seems intermittent (can't reproduce consistently) We are using Jenkins 2.3 and breakage started by upgrading to 2.3 Our stacktrace looks the same It happens even if the build is successful, at the very end: Archiving artifacts FATAL: org.acegisecurity.providers.UsernamePasswordAuthenticationToken cannot be cast to org.jenkinsci.plugins.GithubAuthenticationToken java.lang.ClassCastException: org.acegisecurity.providers.UsernamePasswordAuthenticationToken cannot be cast to org.jenkinsci.plugins.GithubAuthenticationToken at org.jenkinsci.plugins.GithubSecurityRealm.loadUserByUsername(GithubSecurityRealm.java:644) at hudson.model.User$UserIDCanonicalIdResolver.resolveCanonicalId(User.java:1048) at hudson.model.User.get(User.java:394) at hudson.model.User.get(User.java:363) at hudson.plugins.git.GitChangeSet.findOrCreateUser(GitChangeSet.java:374) at hudson.plugins.git.GitChangeSet.getAuthor(GitChangeSet.java:435) at hudson.model.AbstractBuild.getCulprits(AbstractBuild.java:350) at hudson.model.AbstractBuild.getCulprits(AbstractBuild.java:346) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:672) at hudson.model.Run.execute(Run.java:1763) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410) Finished: FAILURE

          See also JENKINS-34775, for the breakage caused by the fix for SECURITY-243.

          Christopher Orr added a comment - See also JENKINS-34775 , for the breakage caused by the fix for SECURITY-243 .

          Sam Gleske added a comment -

          This is going to require someone to patch who is more expert than I at development. To date I've mostly just merged other people's pull requests and made releases (though I have made minor improvements here and there).

          Hopefully, someone is willing to step up and contribute a fix. I'll work on it when I can but I imagine it will take a huge time investment from me (more than I have). Though, if a fix is proposed I have no problem reviewing it, merging, and releasing.

          Sam Gleske added a comment - This is going to require someone to patch who is more expert than I at development. To date I've mostly just merged other people's pull requests and made releases (though I have made minor improvements here and there). Hopefully, someone is willing to step up and contribute a fix. I'll work on it when I can but I imagine it will take a huge time investment from me (more than I have). Though, if a fix is proposed I have no problem reviewing it, merging, and releasing.

          James Nord added a comment -

          reportedly fixed in 0.24.

          James Nord added a comment - reportedly fixed in 0.24.

          Sam Gleske added a comment -

          Based on James Nord's comment.

          Sam Gleske added a comment - Based on James Nord's comment.

            sag47 Sam Gleske
            rsandell rsandell
            Votes:
            6 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: