Validating the authentication token in the REST controllers
In this section, we will learn about securing the backend of our banking application. Specifically, we now need to configure our application to secure the REST endpoints and validate the tokens that will be passed as Authorization
headers to our endpoints. The validation will be delegated to a filter, which we will learn about in the next section.
The first step in securing our REST endpoints is to extend a WebSecurityConfigurerAdapter
class and configure it as follows:
@Configuration @EnableWebSecurity @EnableGlobalMethodSecurity( securedEnabled = true, jsr250Enabled = true, prePostEnabled = true ) public class SecurityConfig extends WebSecurityConfigurerAdapter { ... @Bean public TokenAuthenticationFilter tokenAuthenticationFilter() { ...