Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect to login page if refresh token has expired #475

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1376,10 +1376,12 @@
}

private void redirectToLoginUrl(HttpServletRequest req, HttpServletResponse res) throws IOException {
if (req.getSession(false) != null || Strings.isNullOrEmpty(req.getHeader("Authorization"))) {
if (req != null && (req.getSession(false) != null || Strings.isNullOrEmpty(req.getHeader("Authorization")))) {

Check warning on line 1379 in src/main/java/org/jenkinsci/plugins/oic/OicSecurityRealm.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 1379 is only partially covered, 2 branches are missing
req.getSession().invalidate();
}
res.sendRedirect(Jenkins.get().getSecurityRealm().getLoginUrl());
if (res != null) {

Check warning on line 1382 in src/main/java/org/jenkinsci/plugins/oic/OicSecurityRealm.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 1382 is only partially covered, one branch is missing
res.sendRedirect(Jenkins.get().getSecurityRealm().getLoginUrl());
}
}

public boolean isExpired(OicCredentials credentials) {
Expand Down Expand Up @@ -1475,7 +1477,7 @@
return false;
}
LOGGER.log(Level.FINE, "Failed to refresh expired token", e);
redirectToLoginUrl(Stapler.getCurrentRequest(), Stapler.getCurrentResponse());
redirectToLoginUrl(httpRequest, httpResponse);
return false;
}
LOGGER.log(Level.WARNING, "Failed to refresh expired token", e);
Expand Down
Loading