Skip to content

Commit

Permalink
🐛 fix SAML2 Config
Browse files Browse the repository at this point in the history
  • Loading branch information
haynescd committed Jan 22, 2024
1 parent ba7a7f0 commit a60a6c0
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.http.HttpStatus;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
Expand Down Expand Up @@ -41,13 +40,6 @@ public class Saml2SecurityConfig {
@Autowired(required = false)
private RelyingPartyRegistrationRepository relyingPartyRegistrationRepository;

@Autowired
public void configure(AuthenticationManagerBuilder builder) {
OpenSaml4AuthenticationProvider saml4AuthenticationProvider = new OpenSaml4AuthenticationProvider();
saml4AuthenticationProvider.setResponseAuthenticationConverter(rolesConverter());
builder.authenticationProvider(saml4AuthenticationProvider);
}

@Bean
public SecurityFilterChain samlFilterChain(HttpSecurity http) throws Exception {
return http
Expand All @@ -72,6 +64,13 @@ public SecurityFilterChain samlFilterChain(HttpSecurity http) throws Exception {
.build();
}

@Bean
public OpenSaml4AuthenticationProvider openSaml4AuthenticationProvider() {
OpenSaml4AuthenticationProvider authenticationProvider = new OpenSaml4AuthenticationProvider();
authenticationProvider.setResponseAuthenticationConverter(rolesConverter());
return authenticationProvider;
}

private Converter<OpenSaml4AuthenticationProvider.ResponseToken, Saml2Authentication> rolesConverter() {

Converter<OpenSaml4AuthenticationProvider.ResponseToken, Saml2Authentication> delegate =
Expand Down

0 comments on commit a60a6c0

Please sign in to comment.