Java-Based Spring Security Configuration: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 25: Line 25:
   @Override
   @Override
   protected void configure(AuthenticationManagerBuilder auth) throws Exception {
   protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    ...
  }
  @Override
  protected void configure(HttpSecurity http) throws Exception {
     ...
     ...
   }
   }

Revision as of 21:22, 10 November 2018

External

Internal

Overview

This article describes Java-based Spring Security configuration. This method can be used to configure the following security aspects:

Configuration Class

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

  @Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    ...
  }

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    ...
  }
}

Securing Web Requests

WebSecurityConfigurerAdapter can be used t specify which web request should be secured and which not. This configuration is specified using the following method: