vaadin + spring security + cas + springboot

Hello,

I struggle setting up cas and vaadin. I have read many articles, but I didn’t find how to make it work. I am using springboot, and I have no ‘xml conf file’. All conf is in the java and application.yml (contrary to https://vaadin.com/forum/thread/2228650 for example)

My application is ‘almost’ working. I log into cas server, then I am redirected back to my app… but I am reconized as ‘anonymousUSer’…

Here is my conf:

@EnableWebSecurity
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private AuthenticationProvider authenticationProvider;
    
    @Autowired
    private AuthenticationEntryPoint authenticationEntryPoint;
    
    @Override
    protected void configure(HttpSecurity http) throws Exception {
      http
      	.csrf().disable()
        .authorizeRequests()
        .regexMatchers("/secured.*", "/")
        .authenticated()
        .and()
        .authorizeRequests()
        .regexMatchers("/frontend.*", "/VAADIN.*", "/APP.*", "/UIDL.*")
        .permitAll()
        .and()
        .httpBasic()
        .authenticationEntryPoint(authenticationEntryPoint);
   
    }
    
    @Override
    protected void configure(AuthenticationManagerBuilder auth) 
      throws Exception {
        auth.authenticationProvider(authenticationProvider);
    }
     
    @Override
    protected AuthenticationManager authenticationManager() throws Exception {
        return new ProviderManager(
          Arrays.asList(authenticationProvider));
    }
     
    @Bean
    public CasAuthenticationFilter casAuthenticationFilter(ServiceProperties sP) 
      throws Exception {
        CasAuthenticationFilter filter = new CasAuthenticationFilter();
        filter.setServiceProperties(sP);
        filter.setAuthenticationManager(authenticationManager());
        return filter;
    }
      
    @Bean
    public ServiceProperties serviceProperties() {
        ServiceProperties serviceProperties = new ServiceProperties();
        serviceProperties.setService("http://localhost:8080");
        serviceProperties.setSendRenew(false);
        return serviceProperties;
    }
     
    @Bean
    @Primary
    public AuthenticationEntryPoint authenticationEntryPoint(
      ServiceProperties sP) {
      
        CasAuthenticationEntryPoint entryPoint
          = new CasAuthenticationEntryPoint();
        entryPoint.setLoginUrl("https://kas.unc.nc/cas/login");
        entryPoint.setServiceProperties(sP);
        return entryPoint;
    }
     
    @Bean
    public TicketValidator ticketValidator() {
        return new Cas30ServiceTicketValidator(
          "https://kas.unc.nc/cas/serviceValidate");
    }
     
    @Bean
    public CasAuthenticationProvider casAuthenticationProvider() {      
        CasAuthenticationProvider provider = new CasAuthenticationProvider();
        provider.setServiceProperties(serviceProperties());
        provider.setTicketValidator(ticketValidator());
        provider.setUserDetailsService(
          s -> new User("casuser", "Mellon", true, true, true, true,
            AuthorityUtils.createAuthorityList("ROLE_ADMIN")));
        provider.setKey("CAS_PROVIDER_LOCALHOST_9000");
        return provider;
    }
    
    
    
  }
  1. What is wrong here? why am I always logged as ‘anonymousUser’ ?
  2. I don’t understand this bit of code:
  provider.setUserDetailsService(
        s -> new User("casuser", "Mellon", true, true, true, true,
          AuthorityUtils.createAuthorityList("ROLE_ADMIN")));
      provider.setKey("CAS_PROVIDER_LOCALHOST_9000");

What can I replace it with ?

PS: some more detail on stackoverflow: https://stackoverflow.com/questions/52248976/spring-cas-sso-err-too-many-redirects

I have the same problem, i’m always logged as anonymousUser. Did you solved it?
Thanks

I having the same issue… did you solved it?