Advertisement
Guest User

SAML2/JWT

a guest
Nov 11th, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1.  
  2. @Bean
  3. protected SecurityFilterChain filterChain(final HttpSecurity http) throws Exception {
  4. http.cors()
  5. .and()
  6. .csrf()
  7. .disable()
  8. .authorizeRequests()
  9. .antMatchers(SECURITY_WHITELIST)
  10. .permitAll()
  11. .anyRequest()
  12. .authenticated()
  13. .and()
  14. .httpBasic()
  15. .and()
  16. .exceptionHandling()
  17. .authenticationEntryPoint(authenticationEntryPoint).and().sessionManagement()
  18. .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
  19. http.addFilterBefore(tokenAuthorizationFilter, UsernamePasswordAuthenticationFilter.class);
  20. return http.build();
  21. }
  22.  
  23. @Bean
  24. protected SecurityFilterChain samlFilterChain(final HttpSecurity http) throws Exception {
  25. OpenSamlAuthenticationProvider authenticationProvider = new OpenSamlAuthenticationProvider();
  26. authenticationProvider.setResponseAuthenticationConverter(groupsConverter());
  27.  
  28. http.csrf().disable() //todo !! check
  29. .authorizeHttpRequests(authorize -> authorize
  30. .antMatchers(DEFAULT_OKTA_URL)
  31. .permitAll()
  32. .anyRequest().authenticated()
  33. )
  34. .saml2Login(saml2 -> saml2
  35. .authenticationManager(new ProviderManager(authenticationProvider))
  36. )
  37. .saml2Login()
  38. .successHandler(successRedirectHandler())
  39. .failureHandler(failureRedirectHandler())
  40. .and()
  41. .saml2Logout(Customizer.withDefaults());
  42.  
  43. return http.build();
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement