Describe the bug A call to saml2Login().relyingPartyRegistrationRepository(...).and() does not return a type that can be further configured with spring security.

To Reproduce

public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    protected void configure(HttpSecurity http) throws Exception {
        http
            .saml2Login()
            .relyingPartyRegistrationRepository(relyingPartyRegistrationRepository())
            .and() // <-- A SecurityBuilder object is returned here instead of an HttpSecurity object
            .logout(); // <-- fails due to incorrect object returned by and()
    }
}

Note that relyingPartyRegistrationRepository appears to be the only saml configuration method that causes this problem.

I assume that this:

public Saml2LoginConfigurer relyingPartyRegistrationRepository(RelyingPartyRegistrationRepository repo) {

needs to be changed to this:

public Saml2LoginConfigurer<B> relyingPartyRegistrationRepository(RelyingPartyRegistrationRepository repo) {

Expected behavior Ability to configure other non-saml http security properties after configuring saml2 relying party registry.

Comment From: marcusdacoregio

Hi @dvanbler, thanks for bringing this to our attention.

Exactly, this should be changed to public Saml2LoginConfigurer<B> relyingPartyRegistrationRepository(RelyingPartyRegistrationRepository repo).

Are you able to submit a PR that fixes it?

Comment From: dvanbler

Pull request for this issue: gh-10256

Comment From: marcusdacoregio

Fixed via https://github.com/spring-projects/spring-security/commit/58d50888df2e2fd4b13bc1d873647dd10caee83f