Skip to content

Commit

Permalink
Resuse the original user principal to avoid crumb issues.
Browse files Browse the repository at this point in the history
as it has been observed that the case of a user may change during a
refreesh flow even though they are the same user, the crumb uses the
Authentications name (principal), which would be different as we use the
returned value.
Rather than using the new value, after checking it is the same id
(according to the ID Strategy) we use the original so that the crumb can
be matched.

maybe fixes: #411
  • Loading branch information
jtnord committed Oct 11, 2024
1 parent 51d456d commit 22577a1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/jenkinsci/plugins/oic/OicSecurityRealm.java
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,12 @@ private boolean refreshExpiredToken(
HttpServletResponse.SC_UNAUTHORIZED, "User name was not the same after refresh request");
return false;
}
// the username may have changed case during a call, but still be the same user (as we have checked the
// idStrategy)
// we need to keep using exactly the same principal otherwise there is a potential for crumbs not to match.
// whilst we could do some normalization of the username, just use the original (expected) username
// see https://github.com/jenkinsci/oic-auth-plugin/issues/411
username = expectedUsername;

if (failedCheckOfTokenField(idToken)) {
throw new FailedCheckOfTokenException(client.getConfiguration().findLogoutUrl());
Expand Down

0 comments on commit 22577a1

Please sign in to comment.