Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Issue/466/handle auth details #467

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dellekappa
Copy link

No description provided.

Giulio Ruggeri added 3 commits November 15, 2019 19:43
Fixed line separator issue
Fixed line separator issue
…nto issue/466/handle-auth-details

# Conflicts:
#	core/src/main/java/org/springframework/security/saml/SAMLAuthenticationProvider.java
#	core/src/main/java/org/springframework/security/saml/SAMLProcessingFilter.java
#	core/src/test/java/org/springframework/security/saml/SAMLAuthenticationProviderTest.java
#	core/src/test/java/org/springframework/security/saml/SAMLProcessingFilterTest.java
Copy link
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @dellekappa, for the PR! I've left some feedback inline.

* @param authRequest the authentication request object that should have its details
* set
*/
protected void setDetails(HttpServletRequest request,
Copy link
Contributor

Choose a reason for hiding this comment

The 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 AuthenticationDetailsSource.

@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The 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 this.token.setDetails(details) directly.

@@ -121,7 +121,7 @@ public Authentication authenticate(Authentication authentication) throws Authent

SAMLCredential authenticationCredential = excludeCredential ? null : credential;
ExpiringUsernameAuthenticationToken result = new ExpiringUsernameAuthenticationToken(expiration, principal, authenticationCredential, entitlements);
result.setDetails(userDetails);
result.setDetails(authentication.getDetails());
Copy link
Contributor

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 the userDetails object to come back. By changing it to the result of AuthenticationDetailsSource, we'd break those applications.

Instead, what an application would probably need to do is create a custom authentication provider like so:

public class MyAuthenticationProvider implements AuthenticationProvider {
    private final SAMLAuthenticationProvider delegate;

    // .. constructor

    @Override
    public Authentication authenticate(Authentication authentication) {
        ExpiringUsernameAuthenticationToken result = (ExpiringUsernameAuthenticationToken) 
                this.delegate.authenticate(authentication);
        result.setDetails(authentication.getDetails());
        return result;
    }
}

@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the whitespacing here.

@jzheaux jzheaux self-assigned this Jun 10, 2020
@jzheaux jzheaux added status: waiting-for-feedback We need additional information before we can continue in: core An issue in spring-security-saml-core labels Jun 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in: core An issue in spring-security-saml-core status: waiting-for-feedback We need additional information before we can continue
Development

Successfully merging this pull request may close these issues.

2 participants