Code Monkey home page Code Monkey logo

Comments (2)

rwinch avatar rwinch commented on June 11, 2024

Duplicate of gh-203

from spring-security-kerberos.

StephMirabel avatar StephMirabel commented on June 11, 2024

Thanks a lot for the update! I confirm that the following solution within filterChain() based on your updated sample, is working fine. Since I'm securing a REST server, I don't need login/logout forms. However, I need to disable CSRF to allow POST operations.

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
	ProviderManager providerManager = new ProviderManager(kerberosAuthenticationProvider(),
		kerberosServiceAuthenticationProvider());

	http
	  .authorizeHttpRequests((authz) -> authz
		  // do not authenticate clients on the /info endpoint
		  .requestMatchers("/info").permitAll()
		  // always permit /error endpoint (default redirect for rendering error messages)
		  .requestMatchers("/error").permitAll()
		  // require authentication without role constraint on any other endpoint
		  .anyRequest().authenticated())
	  
	  // disabling cross site request forgery filter to allow POST requests
	  .csrf((csrf) -> csrf.disable())
	  
	  // exception handling for Kerberos negotiate challenge to the client
	  .exceptionHandling(((exceptions) -> exceptions
		  .authenticationEntryPoint(spnegoEntryPoint())))
	  
	  // add Kerberos authenticator knowing the expected users
	  .authenticationProvider(kerberosAuthenticationProvider())
	  
	  // add validator of Kerberos service tickets
	  .authenticationProvider(kerberosServiceAuthenticationProvider())
	  
	  // add filter which processes the "Authorization: Negotiate" header sent by the client
	  // containing the service ticket
	  .addFilterBefore(
		  spnegoAuthenticationProcessingFilter(providerManager),
		  BasicAuthenticationFilter.class);
	return http.build();
    }

from spring-security-kerberos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.