Skip to content

Commit 0176b6d

Browse files
Christof Schoellkohsuke
Christof Schoell
authored andcommittedNov 7, 2014
return authentication object instead of null if authentication is not required - otherwise valid login fails with basic authentication
1 parent 95c73c3 commit 0176b6d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed
 

‎core/src/main/java/jenkins/security/BasicHeaderRealPasswordAuthenticator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Authentication authenticate(HttpServletRequest req, HttpServletResponse r
5050
return null;
5151

5252
if (!authenticationIsRequired(username))
53-
return null;
53+
return SecurityContextHolder.getContext().getAuthentication();
5454

5555
UsernamePasswordAuthenticationToken authRequest =
5656
new UsernamePasswordAuthenticationToken(username, password);

‎test/src/test/java/jenkins/security/BasicHeaderProcessorTest.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,15 @@ public void testVariousWaysToCall() throws Exception {
5656
// call with incorrect password
5757
makeRequestAndFail("foo:bar");
5858

59-
// if the session cookie is valid, then basic header won't be needed
59+
6060
wc.login("bar");
61+
62+
// if the session cookie is valid, then basic header won't be needed
6163
makeRequestWithAuthAndVerify(null, "bar");
6264

65+
// if the session cookie is valid, and basic header is set anyway login should not fail either
66+
makeRequestWithAuthAndVerify("bar:bar", "bar");
67+
6368
// but if the password is incorrect, it should fail, instead of silently logging in as the user indicated by session
6469
makeRequestAndFail("foo:bar");
6570
}

0 commit comments

Comments
 (0)