-
Notifications
You must be signed in to change notification settings - Fork 479
Issue/466/handle auth details #467
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,10 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ | |
context.setLocalEntityEndpoint(SAMLUtil.getEndpoint(context.getLocalEntityRoleMetadata().getEndpoints(), context.getInboundSAMLBinding(), context.getInboundMessageTransport(), uriComparator)); | ||
|
||
SAMLAuthenticationToken token = new SAMLAuthenticationToken(context); | ||
|
||
// Allow subclasses to set the "details" property | ||
setDetails(request, token); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In lieu of calling a new method here, I'd recommend it simply call |
||
|
||
return getAuthenticationManager().authenticate(token); | ||
|
||
} catch (SAMLException e) { | ||
|
@@ -107,6 +111,19 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ | |
|
||
} | ||
|
||
/** | ||
* Provided so that subclasses may configure what is put into the authentication | ||
* request's details property. | ||
* | ||
* @param request that an authentication request is being created for | ||
* @param authRequest the authentication request object that should have its details | ||
* set | ||
*/ | ||
protected void setDetails(HttpServletRequest request, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to introduce a new API in a maintenance release. Since no further minor releases are planned, let's leave this out. Truthfully, it's likely not needed anyway since the user already gets full control by wiring an |
||
SAMLAuthenticationToken authRequest) { | ||
authRequest.setDetails(authenticationDetailsSource.buildDetails(request)); | ||
} | ||
|
||
/** | ||
* Name of the profile this used for authentication. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,8 @@ public void testCorrectPass() throws Exception { | |
final Capture<SAMLMessageContext> context = new Capture<SAMLMessageContext>(); | ||
expect(request.getRequestURL()).andReturn(new StringBuffer("http://localhost:8081/spring-security-saml2-webapp/saml/SSO")); | ||
expect(request.getQueryString()).andReturn(null); | ||
expect(request.getRemoteAddr()).andReturn(null); | ||
expect(request.getSession(false)).andReturn(null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check the whitespacing here. |
||
expect(processor.retrieveMessage(capture(context))).andAnswer(new IAnswer<SAMLMessageContext>() { | ||
public SAMLMessageContext answer() throws Throwable { | ||
context.getValue().setInboundSAMLBinding(org.opensaml.common.xml.SAMLConstants.SAML2_POST_BINDING_URI); | ||
|
@@ -230,4 +232,4 @@ private void verifyMock() { | |
verify(processor); | ||
verify(session); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, I don't think that we can main this change inside of a maintenance release since it's possible that there are applications that are calling
getDetails
and expecting theuserDetails
object to come back. By changing it to the result ofAuthenticationDetailsSource
, we'd break those applications.Instead, what an application would probably need to do is create a custom authentication provider like so: