Skip to content

Commit e0c3480

Browse files
committed
Revert "[JENKINS-72268] Missing permission due to desync with cache (#256)"
This reverts commit 0646c4a.
1 parent 0646c4a commit e0c3480

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/main/java/org/jenkinsci/plugins/GithubAuthenticationToken.java

-3
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,6 @@ private GHMyself loadMyself(@NonNull String token) throws IOException {
504504
// Also stick into usersByIdCache (to have latest copy)
505505
String username = ghMyself.getLogin();
506506
usersByIdCache.put(username, new GithubUser(ghMyself));
507-
} else {
508-
// force creation of the gh variable, esp. in case of impersonation
509-
getGitHub();
510507
}
511508
} catch (IOException e) {
512509
LOGGER.log(Level.INFO, e.getMessage(), e);

src/main/java/org/jenkinsci/plugins/GithubSecurityRealm.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -753,15 +753,10 @@ public int hashCode() {
753753
@Override
754754
public GroupDetails loadGroupByGroupname(String groupName)
755755
throws UsernameNotFoundException, DataAccessException {
756-
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
757-
if (authentication == null) {
758-
throw new UsernameNotFoundException("No known group: " + groupName);
759-
}
760-
if (!(authentication instanceof GithubAuthenticationToken)) {
761-
throw new UserMayOrMayNotExistException("The received token is not a GitHub one");
762-
}
756+
GithubAuthenticationToken authToken = (GithubAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
763757

764-
GithubAuthenticationToken authToken = (GithubAuthenticationToken) authentication;
758+
if(authToken == null)
759+
throw new UsernameNotFoundException("No known group: " + groupName);
765760

766761
try {
767762
int idx = groupName.indexOf(GithubOAuthGroupDetails.ORG_TEAM_SEPARATOR);

0 commit comments

Comments
 (0)