Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-34775] Don't cast inconvertible un/pw token
Fixes JENKINS-34775. The loadUserByUsername method expects to be able to get the current user's token with `SecurityContextHolder.getContext().getAuthentication()`, and assumes this method will return a GithubAuthenticationToken. When it returns a UserPasswordAuthenticationToken instead, a fatal cast was performed. We now handle the case where the current authentication context contains a UserPasswordAuthenticationToken (by throwing an exception - so, not successfully handled, but this prevents the loadUserByUsername failure bubbling up to become a job failure).
- Loading branch information