spring-security-kerberos
spring-security-kerberos copied to clipboard
Migrate samples to spring-security 6.x
It would be nice to have the spring-security-kerberos-samples working with spring-security version 6.x.
Some adaptations are required. E.g. in WebSecurityConfig.filterChain() the following changes worked for me in the sec-server-spnego-form-auth sample:
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
KerberosAuthenticationProvider kerberosAuthenticationProvider = kerberosAuthenticationProvider();
KerberosServiceAuthenticationProvider kerberosServiceAuthenticationProvider = kerberosServiceAuthenticationProvider();
ProviderManager providerManager = new ProviderManager(kerberosAuthenticationProvider,
kerberosServiceAuthenticationProvider);
http
.authorizeHttpRequests((authz) -> authz
.requestMatchers("/", "/home").permitAll()
.anyRequest().authenticated()
)
.exceptionHandling(Customizer.withDefaults())
.httpBasic(httpSecurityHttpBasicConfigurer ->
httpSecurityHttpBasicConfigurer.authenticationEntryPoint(spnegoEntryPoint()))
.formLogin()
.loginPage("/login").permitAll()
.and()
.logout()
.permitAll()
.and()
.authenticationProvider(kerberosAuthenticationProvider())
.authenticationProvider(kerberosServiceAuthenticationProvider())
.addFilterBefore(spnegoAuthenticationProcessingFilter(providerManager),
BasicAuthenticationFilter.class);
return http.build();
}